tracing

package
v0.0.0-...-ba97115 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 31 Imported by: 37

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrBlankJaegerTraceConfiguration is an error to notify client to provide valid trace report agent or config server.
	ErrBlankJaegerTraceConfiguration = errors.New("no Jaeger trace report agent, config server, or collector endpoint specified")
)

Functions

func ExtractSampledTraceID

func ExtractSampledTraceID(ctx context.Context) (string, bool)

ExtractSampledTraceID works like ExtractTraceID but the returned bool is only true if the returned trace id is sampled.

func ExtractTraceID

func ExtractTraceID(ctx context.Context) (string, bool)

ExtractTraceID extracts the trace id, if any from the context.

func ExtractTraceSpanID

func ExtractTraceSpanID(ctx context.Context) (string, string, bool)

ExtractTraceSpanID extracts the trace id, span id if any from the context.

func KeyValueToOTelAttribute

func KeyValueToOTelAttribute(key string, val any) attribute.KeyValue

func NewFromEnv

func NewFromEnv(serviceName string, options ...jaegercfg.Option) (io.Closer, error)

NewFromEnv is a convenience function to allow tracing configuration via environment variables

Tracing will be enabled if one (or more) of the following environment variables is used to configure trace reporting: - JAEGER_AGENT_HOST - JAEGER_SAMPLER_MANAGER_HOST_PORT

func NewOTelFromEnv

func NewOTelFromEnv(serviceName string, logger log.Logger, opts ...OTelOption) (io.Closer, error)

NewOTelFromEnv is a convenience function to allow OpenTelemetry tracing configuration via environment variables. Refer to official OTel SDK configuration docs to see the available options. https://opentelemetry.io/docs/languages/sdk-configuration/general/

func NewOTelFromJaegerEnv deprecated

func NewOTelFromJaegerEnv(serviceName string) (io.Closer, error)

NewOTelFromJaegerEnv is a convenience function to allow OTel tracing configuration via Jaeger environment variables

Tracing will be enabled if one (or more) of the following environment variables is used to configure trace reporting: - JAEGER_AGENT_HOST - JAEGER_SAMPLER_MANAGER_HOST_PORT

Deprecated: use NewOTelOrJaegerFromEnv instead as it will automatically configure OTel auto exporter if Jaeger is not configured.

func NewOTelOrJaegerFromEnv

func NewOTelOrJaegerFromEnv(serviceName string, logger log.Logger, opts ...OTelOption) (io.Closer, error)

NewOTelOrJaegerFromEnv is a convenience function to allow OTel tracing configuration via environment variables. It will configure Jaeger exporter if any of the following environment variables are set: - JAEGER_AGENT_HOST - JAEGER_ENDPOINT - JAEGER_SAMPLER_MANAGER_HOST_PORT

Otherwise, it will initialize tracing with the OTel auto exporter using the environment variables defined in the OTel docs. If you want to explicitly disable OTel auto exporter, you can set the environment variable `OTEL_TRACES_EXPORTER` to `none`.

func NewResource

func NewResource(serviceName string, customAttributes []attribute.KeyValue) (*resource.Resource, error)

NewResource creates a new OpenTelemetry resource using the provided service name and custom attributes. This resource will be used for creating both tracers and meters, enriching telemetry data with context.

func OTelPropagatorsFromEnv

func OTelPropagatorsFromEnv() []propagation.TextMapPropagator

OTelPropagatorsFromEnv returns a slice of OpenTelemetry TextMapPropagators based on the OTEL_PROPAGATORS environment variable. If the environment variable is not set, it defaults to using TraceContext, Baggage, and Jaeger propagators. This implementation supports only `tracecontext`, `baggage`, and `jaeger` and `none` propagators. See docs in: https://opentelemetry.io/docs/languages/sdk-configuration/general/

func SpanFromContext

func SpanFromContext(ctx context.Context) (otelSpan trace.Span, opentracingSpan opentracing.Span, sampled bool)

Types

type JaegerDebuggingPropagator

type JaegerDebuggingPropagator struct{}

func (JaegerDebuggingPropagator) Extract

func (JaegerDebuggingPropagator) Fields

func (j JaegerDebuggingPropagator) Fields() []string

func (JaegerDebuggingPropagator) Inject

type JaegerDebuggingSampler

type JaegerDebuggingSampler struct {
	// contains filtered or unexported fields
}

func (*JaegerDebuggingSampler) Description

func (j *JaegerDebuggingSampler) Description() string

func (*JaegerDebuggingSampler) ShouldSample

type OTelOption

type OTelOption interface {
	// contains filtered or unexported methods
}

func WithPyroscopeDisabled

func WithPyroscopeDisabled() OTelOption

WithPyroscopeDisabled disables pyroscope profiling in the OpenTelemetry tracer.

func WithResourceAttributes

func WithResourceAttributes(attrs ...attribute.KeyValue) OTelOption

WithResourceAttributes allows to add custom attributes to the OpenTelemetry resource. This is useful to set, for example, the service version. Service name is already set by default.

func WithTracerProviderOptions

func WithTracerProviderOptions(opts ...tracesdk.TracerProviderOption) OTelOption

WithTracerProviderOptions allows to pass additional options to the OpenTelemetry TracerProvider.

type Span

type Span struct {
	// contains filtered or unexported fields
}

Span is either an OpenTracing span or an OpenTelemetry span. It could also be a noop span.

func StartSpanFromContext

func StartSpanFromContext(ctx context.Context, operation string, options ...SpanOption) (*Span, context.Context)

StartSpanFromContext starts a new opentracing span if opentracing is registered, otherwise it starts a new otel span.

func (*Span) Finish

func (s *Span) Finish()

func (*Span) LogError

func (s *Span) LogError(err error)

func (*Span) SetError

func (s *Span) SetError()

func (*Span) SetTag

func (s *Span) SetTag(name string, value any)

type SpanKindRPCClient

type SpanKindRPCClient struct{}

type SpanOption

type SpanOption interface {
	// contains filtered or unexported methods
}

Jump to

Keyboard shortcuts

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