tracing

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2026 License: MIT Imports: 15 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddAttributeToSpan added in v1.4.0

func AddAttributeToSpan(span trace.Span, name string, val any)

AddAttributeToSpan attach any supportable value to span

func AddEventWithCodeLocation added in v1.0.19

func AddEventWithCodeLocation(span trace.Span, message string)

AddEventWithCodeLocation creates event in span with current code location

func AttachCodeLocationToSpan

func AttachCodeLocationToSpan(span trace.Span)

AttachCodeLocationToSpan attach current code location to span

func ConfigureHTTP

func ConfigureHTTP(cfg HTTPConfig, extraAttributes ...attribute.KeyValue) (err error)

ConfigureHTTP fine tunes jaeger exporter to deliver spans via compact thrift protocol to collector http endpoint

func ConfigureOTLPoverHTTP added in v1.0.27

func ConfigureOTLPoverHTTP(ctx context.Context, cfg OTLPoverHTTPConfig, extraAttributes ...attribute.KeyValue) (err error)

ConfigureOTLPoverHTTP fine tunes OTLP HTTP exporter to deliver spans via OTLP over HTTP protocol to collector http endpoint

func ConfigureUDP

func ConfigureUDP(cfg UDPConfig, extraAttributes ...attribute.KeyValue) (err error)

ConfigureUDP fine tunes jaeger exporter to deliver spans via compact thrift protocol to agent udp listener

func Shutdown added in v1.0.27

func Shutdown(ctx context.Context) (err error)

Shutdown forces exporter to save all spans and turn off.

func Start

func Start(cfg Config, extraAttributes ...attribute.KeyValue) (err error)

Start starts telemetry exporter

func StartWithContext added in v1.3.0

func StartWithContext(ctx context.Context, cfg Config, extraAttributes ...attribute.KeyValue) (err error)

StartWithContext starts telemetry exporter with context provided

func Wait

func Wait(ctx context.Context) (err error)

Wait allows span exporter to inhibit application shutdown until it sends all traces.

Types

type Config

type Config struct {
	// Protocol sets how we send spans to jaeger - over udp or over http
	Protocol string `yaml:"protocol" validate:"required,oneof=udp http UDP HTTP otlp_http OTLP_HTTP"`

	// Host - sets hostname of Jaeger agent, overrides environment value of OTEL_EXPORTER_JAEGER_AGENT_HOST.
	// Default value is `localhost`
	Host string `yaml:"host"`
	// Port - sets port where Jaeger agent listens, overrides environment value of OTEL_EXPORTER_JAEGER_AGENT_PORT.
	// Default value is `6831`
	Port string `yaml:"port"`

	// Endpoint is the URL for the Jaeger collector that spans are sent to,
	// overrides value of environment variable OTEL_EXPORTER_JAEGER_ENDPOINT.
	// Default value is `http://localhost:14268/api/traces`
	Endpoint string `yaml:"endpoint"`
	// Username used for basic authorization to access Jaeger collector. Setting value overrides environment
	// variable OTEL_EXPORTER_JAEGER_USER. Default is empty
	Username string `yaml:"username"`
	// Password  used for basic authorization to access Jaeger collector. Setting value overrides environment
	// variable OTEL_EXPORTER_JAEGER_PASSWORD. Default is empty
	Password string `yaml:"password"`

	// OTLPEndpoint sets HTTP OTLP collector url, overrides value of environment variable of OTEL_EXPORTER_OTLP_TRACES_ENDPOINT
	// Default is  "https://localhost:4318/v1/traces". See full documentation for environment options supported:
	// https://pkg.go.dev/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp#pkg-overview
	OTLPEndpoint string `yaml:"otlp_endpoint"`

	// Insecure allows insecure connections over HTTP protocol where connection via HTTPS are preferred
	Insecure bool `yaml:"insecure"`
	// Ratio sets percent of spans to record, where 1 - means every span is recorded, 0 - no spans recorded and .05 means only 5% of spans are recorded
	Ratio float64 `yaml:"ratio" validate:"required,lte=1,gte=0"`

	/*
	   Extra trace provider options like samplers and so on applied for all exporters
	*/
	// TraceProviderOptions allows to add extra tracer provider options like custom sampler and so on
	TraceProviderOptions []tracesdk.TracerProviderOption `yaml:"-"`
}

Config is universal config being used to tune tracing

func (*Config) String added in v1.3.0

func (c *Config) String() string

type HTTPConfig

type HTTPConfig struct {
	Endpoint string  `yaml:"endpoint"`
	Username string  `yaml:"username"`
	Password string  `yaml:"password"`
	Ratio    float64 `yaml:"ratio" validate:"lte=1,gte=0"`
	// TraceProviderOptions allows to add extra tracer provider options like custom sampler and so on
	TraceProviderOptions []tracesdk.TracerProviderOption `yaml:"-"`
}

HTTPConfig is used to fine tune jaeger exporter to deliver spans via compact thrift protocol to collector http endpoint

type OTLPoverHTTPConfig added in v1.0.27

type OTLPoverHTTPConfig struct {
	Endpoint             string                          `yaml:"endpoint"`
	Compression          bool                            `yaml:"compression"`
	Ratio                float64                         `yaml:"ratio" validate:"lte=1,gte=0"`
	Headers              map[string]string               `yaml:"headers"`
	Opts                 []otlptracehttp.Option          `yaml:"-"`
	Insecure             bool                            `yaml:"insecure"`
	TraceProviderOptions []tracesdk.TracerProviderOption `yaml:"-"`
}

OTLPoverHTTPConfig is used to fine http otlp exporter to deliver spans via OTLP over HTTP protocol

type UDPConfig

type UDPConfig struct {
	// Host - sets hostname of Jaeger agent, overrides environment value of OTEL_EXPORTER_JAEGER_AGENT_HOST.
	// Default value is `localhost`
	Host string `yaml:"host"`
	// Port - sets port where Jaeger agent listens, overrides environment value of OTEL_EXPORTER_JAEGER_AGENT_PORT.
	// Default value is `6831`
	Port string `yaml:"port"`
	// Ratio sets percent of spans to record, where 1 - means every span is recorded, 0 - no spans recorded and .05 means only 5% of spans are recorded
	Ratio float64 `yaml:"ratio" validate:"required,lte=1,gte=0"`
	// TraceProviderOptions allows to add extra tracer provider options like custom sampler and so on
	TraceProviderOptions []tracesdk.TracerProviderOption `yaml:"-"`
}

UDPConfig is used to fine tune jaeger exporter to deliver spans via compact thrift protocol to agent udp listener

Jump to

Keyboard shortcuts

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