tracer

package
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2024 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Overview

Package tracer provides a global OpenTelemetry tracer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddEvent

func AddEvent(ctx context.Context, name string, attrs ...attribute.KeyValue)

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

func BindFlags(flags *pflag.FlagSet, cfg *Config)

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

func RootedCtx(ctx context.Context, traceID trace.TraceID) context.Context

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

func WithOTLP(endpoint string, headers map[string]string) func(*options)

WithOTLP returns an option to configure an OpenTelemetry tracing exporter for Jaeger.

func WithStdOut

func WithStdOut(w io.Writer) func(*options)

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.

type Identifiers

type Identifiers struct {
	Network  netconf.ID
	Service  string // halo/relayer/monitor
	Instance string // validator01/seed01
}

Identifiers defines the global tracer attributes That uniquely identifies the network/service/instance that produced each trace.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL