Documentation ¶
Overview ¶
Package tracer provides a global OpenTelemetry tracer.
Index ¶
- func AddEvent(ctx context.Context, name string, attrs ...attribute.KeyValue)
- func BindFlags(flags *pflag.FlagSet, cfg *Config)
- func Init(ctx context.Context, ids Identifiers, cfg Config, opts ...func(*options)) (func(context.Context) error, error)
- func RootedCtx(ctx context.Context, traceID trace.TraceID) context.Context
- func Start(ctx context.Context, spanName string, opts ...trace.SpanStartOption) (context.Context, trace.Span)
- func StartChainHeight(ctx context.Context, network netconf.ID, chain string, height uint64, ...) (context.Context, trace.Span)
- func WithOTLP(endpoint string, headers map[string]string) func(*options)
- func WithStdOut(w io.Writer) func(*options)
- type Config
- type Identifiers
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddEvent ¶
AddEvent adds an event to the span in the given context with the specified name and attributes. See go.opentelemetry.io/otel/trace#Span.AddEvent for more details.
func BindFlags ¶
BindFlags binds the provided flags to the corresponding fields in the Config struct.
func Init ¶
func Init(ctx context.Context, ids Identifiers, cfg Config, opts ...func(*options)) (func(context.Context) error, error)
Init initializes the global tracer via the option(s) defaulting to a noop tracer. It returns a shutdown function.
func RootedCtx ¶
RootedCtx returns a copy of the parent context containing a tracing span context rooted to the trace ID. All spans started from the context will be rooted to the trace ID.
func Start ¶
func Start(ctx context.Context, spanName string, opts ...trace.SpanStartOption) (context.Context, trace.Span)
Start creates a span and a context.Context containing the newly-created span from the global tracer. See go.opentelemetry.io/otel/trace#Start for more details.
func StartChainHeight ¶
func StartChainHeight(ctx context.Context, network netconf.ID, chain string, height uint64, spanName string, opts ...trace.SpanStartOption) (context.Context, trace.Span)
StartChainHeight returns a context and span rooted to the network+network.Version+chain+height. This creates a new trace root and should generally only by xprovider or cprovider.
func WithOTLP ¶
WithOTLP returns an option to configure an OpenTelemetry tracing exporter for Jaeger.
func WithStdOut ¶
WithStdOut returns an option to configure an OpenTelemetry exporter for tracing telemetry to be written to an output destination as JSON.
Types ¶
type Config ¶
type Config struct { Endpoint string // E.g. "https://otlp-gateway-prod-us-east-0.grafana.net/otlp" Headers string // E.g. "Authorization=Basic NzQk..3O34" }
Config defines OTLP config for grafana cloud. See https://grafana.com/docs/grafana-cloud/monitor-applications/application-observability/setup/quickstart/go/
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns the default empty configuration for OTLP tracing.