Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ unit-tests-dig:
cd platform/view/sdk/dig; go test -cover ./...
cd platform/fabric/sdk/dig; go test -cover ./...

run-optl:
run-otlp:
cd platform/view/services/tracing; docker-compose up -d

INTEGRATION_TARGETS =
Expand Down
10 changes: 5 additions & 5 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,14 @@ fsc:

# ------------------- Tracing Configuration -------------------------
tracing:
# Type of provider to be used: none (default), file, optl, console
provider: optl
# Type of provider to be used: none (default), file, otlp, console
provider: otlp
# Tracer configuration when provider == 'file'
file:
# The file where the traces are going to be stored
path: /path/to/client/trace.out
# Tracer configuration when provider == 'optl'
optl:
# Tracer configuration when provider == 'otlp'
otlp:
# The address of collector where we should send the traces
address: 127.0.0.1:8125
sampling:
Expand Down Expand Up @@ -432,7 +432,7 @@ CORE_LOGGING_LEVEL=debug
CORE_FSC_P2P_LISTENADDRESS=/ip4/0.0.0.0/tcp/9001
CORE_FSC_IDENTITY_KEY_FILE=/my/private.key
CORE_FSC_KVS_PERSISTENCE_OPTS_DATASOURCE=/mydb.sqlite
CORE_FSC_TRACING_OPTL_ADDRESS=jaeger.example.com:4318
CORE_FSC_TRACING_OTLP_ADDRESS=jaeger.example.com:4318
CORE_FABRIC_MYNETWORK_KEEPALIVE_TIMEOUT=120s
```

Expand Down
6 changes: 3 additions & 3 deletions docs/platform/view/monitoring.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ FSC defines the following implementations, although custom implementations can b
* **NoOp:** Disables the tracer, when `fsc.tracing.provider = none`
* **Console:** Exports (prints) the traces on the console, when `fsc.tracing.provider = console`
* **File:** Exports (stores) the traces into the file `fsc.tracing.file.path`, when `fsc.tracing.provider = file`
* **OTPL:** Exports (sends) the traces to an OTPL collector that listens on the port `fsc.tracing.optl.address` when `fsc.tracing.provider = optl`
* **OTLP:** Exports (sends) the traces to an OTLP collector that listens on the port `fsc.tracing.otlp.address` when `fsc.tracing.provider = otlp`

These supported tracer providers can be instantiated using `tracing.NewTracerProviderFromConfig`.
Using this constructor, along with the type of the exporter, we can also specify other parameters, like the sampling rate.
Expand All @@ -159,7 +159,7 @@ Whenever we start spans, we keep track of the count and the duration of the oper

### Adding traces

The base unit of the traces are the spans. A span represents a unit of work. In our code, we only start new spans and then these spans are linked to compose traces by the remote agent (in case we use OTPL as provider).
The base unit of the traces are the spans. A span represents a unit of work. In our code, we only start new spans and then these spans are linked to compose traces by the remote agent (in case we use OTLP as provider).

1. For instance, in the case of a transfer, the transfer operation is conceptually a trace. The first span of this trace can be created on the end user that initiates the client (e.g. alice).
2. When the request arrives to the recipient (e.g. bob), another span can be initiated when the corresponding view is invoked.
Expand Down Expand Up @@ -300,5 +300,5 @@ Reading single spans from the console or a file is cumbersome and this is why we
* visualize the traces on a UI

Although these components are separate and have distinct responsibilities, there is a docker image that combines all of them: `jaegertracing/all-in-one:latest`.
The `jaeger_collector` sub-image listens on a port for new spans. The application exports (sends) the spans to that endpoint (defined in `fsc.tracing.optl.address`).
The `jaeger_collector` sub-image listens on a port for new spans. The application exports (sends) the spans to that endpoint (defined in `fsc.tracing.otlp.address`).
The `jaeger_ui` serves an application with querying and trace-visualization capabilities.
4 changes: 2 additions & 2 deletions integration/fabric/iou/topology.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func Topology(opts *Opts) []api.Topology {
// fscTopology.SetLogging("debug", "")

// fscTopology.SetLogging("debug", "")
fscTopology.EnableTracing(tracing.Otpl)
fscTopology.EnableTracing(tracing.Otlp)

// Add the approver FSC node.
fscTopology.AddNodeByName("approver1").
Expand Down Expand Up @@ -88,7 +88,7 @@ func Topology(opts *Opts) []api.Topology {
// Monitoring
monitoringTopology := monitoring.NewTopology()
monitoringTopology.EnablePrometheusGrafana()
monitoringTopology.EnableOPTL()
monitoringTopology.EnableOTLP()

// Add Fabric SDK to FSC Nodes
fscTopology.AddSDK(opts.SDK)
Expand Down
4 changes: 2 additions & 2 deletions integration/fabricx/iou/topology.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func Topology(sdk node.SDK, commType fsc.P2PCommunicationType, replicationOpts *
fscTopology.SetLogging("grpc=error:fabricx=info:info", "")

// fscTopology.SetLogging("debug", "")
// fscTopology.EnableOPTLTracing()
// fscTopology.EnableOTLPTracing()

// Add the approver FSC node.
fscTopology.AddNodeByName("approver1").
Expand Down Expand Up @@ -76,7 +76,7 @@ func Topology(sdk node.SDK, commType fsc.P2PCommunicationType, replicationOpts *

// Monitoring
// monitoringTopology := monitoring.NewTopology()
// monitoringTopology.EnableOPTL()
// monitoringTopology.EnableOTLP()

// Add Fabric SDK to FSC Nodes
fscTopology.AddSDK(sdk)
Expand Down
4 changes: 2 additions & 2 deletions integration/fsc/stoprestart/topology.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func Topology(commType fsc.P2PCommunicationType, replicationOpts *integration.Re
// Create an empty FSC topology
topology := fsc.NewTopology()
topology.P2PCommunicationType = commType
topology.EnableTracing(tracing.Otpl)
topology.EnableTracing(tracing.Otlp)
topology.EnablePrometheusMetrics()

topology.AddNodeByName("alice").
Expand All @@ -35,7 +35,7 @@ func Topology(commType fsc.P2PCommunicationType, replicationOpts *integration.Re

monitoringTopology := monitoring.NewTopology()
// monitoringTopology.EnablePrometheusGrafana()
monitoringTopology.EnableOPTL()
monitoringTopology.EnableOTLP()

return []api.Topology{topology, monitoringTopology}
}
8 changes: 4 additions & 4 deletions integration/nwo/fsc/fsc.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
runner2 "github.com/hyperledger-labs/fabric-smart-client/integration/nwo/common/runner"
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/fsc/commands"
node2 "github.com/hyperledger-labs/fabric-smart-client/integration/nwo/fsc/node"
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/monitoring/optl"
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/monitoring/otlp"
"github.com/hyperledger-labs/fabric-smart-client/platform/common/services/logging"
"github.com/hyperledger-labs/fabric-smart-client/platform/common/utils"
"github.com/hyperledger-labs/fabric-smart-client/platform/common/utils/collections"
Expand Down Expand Up @@ -243,8 +243,8 @@ func (p *Platform) PostRun(bool) {
File: tracing2.FileConfig{
Path: "./client-trace.out",
},
Otpl: tracing2.OtplConfig{
Address: fmt.Sprintf("0.0.0.0:%d", optl.JaegerCollectorPort),
Otlp: tracing2.OtlpConfig{
Address: fmt.Sprintf("0.0.0.0:%d", otlp.JaegerCollectorPort),
},
})
if err != nil {
Expand Down Expand Up @@ -528,7 +528,7 @@ func (p *Platform) GenerateCoreConfig(peer *node2.Replica) {
"Resolvers": func() []*Resolver { return resolvers },
"WebEnabled": func() bool { return p.Topology.WebEnabled },
"TracingEndpoint": func() string {
return utils.DefaultString(p.Topology.Monitoring.TracingEndpoint, fmt.Sprintf("0.0.0.0:%d", optl.JaegerCollectorPort))
return utils.DefaultString(p.Topology.Monitoring.TracingEndpoint, fmt.Sprintf("0.0.0.0:%d", otlp.JaegerCollectorPort))
},
"SamplingRatio": func() float64 { return p.Topology.Monitoring.TracingSamplingRatio },
}).
Expand Down
6 changes: 3 additions & 3 deletions integration/nwo/fsc/node/core_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,14 @@ fsc:
files:
- {{ .NodeLocalTLSDir Peer }}/ca.crt
tracing:
# Type of provider to be used: none (default), file, optl, console
# Type of provider to be used: none (default), file, otlp, console
provider: {{ Topology.Monitoring.TracingType }}
# Tracer configuration when provider == 'file'
file:
# The file where the traces are going to be stored
path: {{ .NodeDir Replica }}/trace.out
# Tracer configuration when provider == 'optl'
optl:
# Tracer configuration when provider == 'otlp'
otlp:
# The address of collector where we should send the traces
address: {{ TracingEndpoint }}
sampling:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package optl
package otlp

const ConfigTemplate = `receivers:
otlp:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package optl
package otlp

import (
"context"
Expand Down Expand Up @@ -91,5 +91,5 @@ func (n *Extension) startJaeger() {
gomega.Expect(cli.ContainerStart(ctx, resp.ID, container.StartOptions{})).ToNot(gomega.HaveOccurred())

logger.Infof("Follow the traces on localhost:%d", JaegerUIPort)
gomega.Expect(docker.StartLogs(cli, resp.ID, "monitoring.optl.jaegertracing.container")).ToNot(gomega.HaveOccurred())
gomega.Expect(docker.StartLogs(cli, resp.ID, "monitoring.otlp.jaegertracing.container")).ToNot(gomega.HaveOccurred())
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package optl
package otlp

import (
"os"
Expand All @@ -21,8 +21,8 @@ type Platform interface {
GetContext() api.Context
ConfigDir() string
NetworkID() string
OPTL() bool
OPTLPort() int
OTLP() bool
OTLPPort() int
}

type Extension struct {
Expand All @@ -36,13 +36,13 @@ func NewExtension(platform Platform) *Extension {
}

func (n *Extension) CheckTopology() {
if !n.platform.OPTL() {
if !n.platform.OTLP() {
return
}
}

func (n *Extension) GenerateArtifacts() {
if !n.platform.OPTL() {
if !n.platform.OTLP() {
return
}

Expand All @@ -52,7 +52,7 @@ func (n *Extension) GenerateArtifacts() {
}

func (n *Extension) PostRun(bool) {
if !n.platform.OPTL() {
if !n.platform.OTLP() {
return
}

Expand All @@ -63,12 +63,12 @@ func (n *Extension) PostRun(bool) {
func (n *Extension) configFileDir() string {
return filepath.Join(
n.platform.ConfigDir(),
"optl",
"otlp",
)
}

func (n *Extension) configFilePath() string {
return filepath.Join(n.configFileDir(), "optl-collector-config.yaml")
return filepath.Join(n.configFileDir(), "otlp-collector-config.yaml")
}

func (n *Extension) jaegerHostsPath() string {
Expand Down
12 changes: 6 additions & 6 deletions integration/nwo/monitoring/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/common/docker"
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/monitoring/hle"
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/monitoring/monitoring"
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/monitoring/optl"
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/monitoring/otlp"
"github.com/hyperledger-labs/fabric-smart-client/integration/reporting/jaeger"
"github.com/hyperledger-labs/fabric-smart-client/integration/reporting/prometheus"
"github.com/hyperledger-labs/fabric-smart-client/platform/common/services/logging"
Expand Down Expand Up @@ -75,7 +75,7 @@ func New(reg api.Context, topology *Topology) *Platform {
}
p.AddExtension(hle.NewExtension(p))
p.AddExtension(monitoring.NewExtension(p))
p.AddExtension(optl.NewExtension(p))
p.AddExtension(otlp.NewExtension(p))

return p
}
Expand Down Expand Up @@ -180,10 +180,10 @@ func (p *Platform) GrafanaPort() int {
return p.topology.GrafanaPort
}

func (p *Platform) OPTL() bool {
return p.topology.OPTL
func (p *Platform) OTLP() bool {
return p.topology.OTLP
}

func (p *Platform) OPTLPort() int {
return p.topology.OPTLPort
func (p *Platform) OTLPPort() int {
return p.topology.OTLPPort
}
18 changes: 9 additions & 9 deletions integration/nwo/monitoring/topology.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ package monitoring

import (
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/monitoring/monitoring"
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/monitoring/optl"
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/monitoring/otlp"
)

type Topology struct {
Expand All @@ -19,8 +19,8 @@ type Topology struct {
PrometheusGrafana bool `yaml:"prometheus-grafana,omitempty"`
PrometheusPort int `yaml:"prometheus-port,omitempty"`
GrafanaPort int `yaml:"grafana-port,omitempty"`
OPTL bool `yaml:"optl,omitempty"`
OPTLPort int `yaml:"optl-port,omitempty"`
OTLP bool `yaml:"otlp,omitempty"`
OTLPPort int `yaml:"otlp-port,omitempty"`
JaegerQueryPort int `yaml:"jaeger-query-port"`
}

Expand All @@ -31,8 +31,8 @@ func NewTopology() *Topology {
HyperledgerExplorerPort: 8080,
PrometheusPort: monitoring.PrometheusPort,
GrafanaPort: 3000,
OPTLPort: 4319,
JaegerQueryPort: optl.JaegerQueryPort,
OTLPPort: 4319,
JaegerQueryPort: otlp.JaegerQueryPort,
}
}

Expand Down Expand Up @@ -64,10 +64,10 @@ func (t *Topology) SetGrafanaPort(port int) {
t.GrafanaPort = port
}

func (t *Topology) EnableOPTL() {
t.OPTL = true
func (t *Topology) EnableOTLP() {
t.OTLP = true
}

func (t *Topology) SetOPTLPort(port int) {
t.OPTLPort = port
func (t *Topology) SetOTLPPort(port int) {
t.OTLPPort = port
}
4 changes: 2 additions & 2 deletions integration/reporting/jaeger/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"context"
"fmt"

"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/monitoring/optl"
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/monitoring/otlp"
"github.com/hyperledger-labs/fabric-smart-client/pkg/utils/errors"
"github.com/hyperledger-labs/fabric-smart-client/platform/common/utils/collections/iterators"
"github.com/jaegertracing/jaeger-idl/proto-gen/api_v2"
Expand All @@ -25,7 +25,7 @@ type Reporter interface {
}

func NewLocalReporter() (*reporter, error) {
return NewReporter(fmt.Sprintf("0.0.0.0:%d", optl.JaegerQueryPort))
return NewReporter(fmt.Sprintf("0.0.0.0:%d", otlp.JaegerQueryPort))
}

func NewReporter(address string) (*reporter, error) {
Expand Down
16 changes: 8 additions & 8 deletions platform/view/services/tracing/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type TracerType string

const (
None TracerType = "none"
Otpl TracerType = "otpl"
Otlp TracerType = "otlp"
File TracerType = "file"
Console TracerType = "console"
ServiceName = "FSC"
Expand All @@ -40,7 +40,7 @@ var NoOp = Config{Provider: None}
type Config struct {
Provider TracerType `mapstructure:"provider"`
File FileConfig `mapstructure:"file"`
Otpl OtplConfig `mapstructure:"optl"`
Otlp OtlpConfig `mapstructure:"otlp"`
Sampling SamplingConfig `mapstructure:"sampling"`
}

Expand All @@ -52,7 +52,7 @@ type FileConfig struct {
Path string `mapstructure:"path"`
}

type OtplConfig struct {
type OtlpConfig struct {
Address string `mapstructure:"address"`
}

Expand All @@ -74,9 +74,9 @@ func newProviderFromConfig(c Config, serviceName string) (Provider, error) {
var exporter sdktrace.SpanExporter
var err error
switch c.Provider {
case Otpl:
logger.Debugf("OPTL tracer provider selected")
exporter, err = grpcExporter(&c.Otpl)
case Otlp:
logger.Debugf("OTLP tracer provider selected")
exporter, err = grpcExporter(&c.Otlp)
case File:
logger.Debugf("File tracing provider selected")
exporter, err = fileExporter(&c.File)
Expand Down Expand Up @@ -107,11 +107,11 @@ func fileExporter(c *FileConfig) (sdktrace.SpanExporter, error) {
return stdouttrace.New(stdouttrace.WithPrettyPrint(), stdouttrace.WithWriter(f))
}

func grpcExporter(c *OtplConfig) (sdktrace.SpanExporter, error) {
func grpcExporter(c *OtlpConfig) (sdktrace.SpanExporter, error) {
if c == nil || len(c.Address) == 0 {
return nil, errors.New("empty url")
}
logger.Debugf("Tracing enabled: optl")
logger.Debugf("Tracing enabled: otlp")
return otlptrace.New(context.Background(), otlptracegrpc.NewClient(otlptracegrpc.WithInsecure(), otlptracegrpc.WithEndpoint(c.Address)))
}

Expand Down