observability

package
v1.12.1 Latest Latest
Warning

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

Go to latest
Published: May 15, 2026 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GRPCClientOption added in v1.12.0

func GRPCClientOption() grpc.DialOption

GRPCClientOption returns a gRPC dial option that installs the OTel stats handler so outbound calls inject trace context into metadata.

func GRPCServerOption added in v1.12.0

func GRPCServerOption() grpc.ServerOption

GRPCServerOption returns a gRPC server option that installs the OTel stats handler so server spans pick up trace context from inbound metadata.

func InstallTraceContextHook added in v1.12.0

func InstallTraceContextHook(log *logrus.Logger)

InstallTraceContextHook attaches the trace-context hook to a logger. Call once at startup; Logrus does not deduplicate hooks.

func MergeContexts added in v0.0.179

func MergeContexts(parent context.Context, contexts ...context.Context) context.Context

func NewHTTPTraceProvider

func NewHTTPTraceProvider(ctx context.Context, res *resource.Resource, httpOpts []otlptracehttp.Option, opts ...trace.TracerProviderOption) (*trace.TracerProvider, error)

func NewResource

func NewResource(serviceName, serviceVersion string) (*resource.Resource, error)

func RegisterPropagator added in v1.12.0

func RegisterPropagator()

RegisterPropagator installs the W3C trace-context + baggage propagator as the global OTel TextMapPropagator.

func Setup added in v1.12.0

func Setup(
	ctx context.Context,
	log *logrus.Logger,
	serviceName, serviceVersion string,
	traceCfg *TracingConfig,
) (shutdown func(context.Context) error, err error)

Setup bootstraps OTel traces and the W3C propagator for a component. Logs are emitted to stdout with trace_id/span_id fields and shipped out-of-process by a local agent. Returns a shutdown func.

func SetupOTelSDK

func SetupOTelSDK(ctx context.Context, tracerProvider *trace.TracerProvider) (shutdown func(context.Context) error, err error)

SetupOTelSDK bootstraps the OpenTelemetry pipeline. If it does not return an error, make sure to call shutdown for proper cleanup.

func Tracer

func Tracer() otrace.Tracer

Types

type ContextualLogger added in v1.12.0

type ContextualLogger interface {
	logrus.FieldLogger
	WithContext(ctx context.Context) *logrus.Entry
}

ContextualLogger extends logrus.FieldLogger with WithContext so call sites that have a context.Context can attach it to log entries. Both *logrus.Logger and *logrus.Entry satisfy this interface.

type SamplingConfig added in v0.0.179

type SamplingConfig struct {
	Rate float64 `yaml:"rate" default:"0.01"`
}

type TraceContextHook added in v1.12.0

type TraceContextHook struct{}

TraceContextHook is a logrus hook that stamps the active OTel span's trace_id and span_id onto each log entry that carries a context.

func (TraceContextHook) Fire added in v1.12.0

func (TraceContextHook) Fire(entry *logrus.Entry) error

Fire enriches the entry with trace_id and span_id when its context carries a valid span.

func (TraceContextHook) Levels added in v1.12.0

func (TraceContextHook) Levels() []logrus.Level

Levels reports the levels this hook fires on.

type TracingConfig

type TracingConfig struct {
	Enabled     bool                       `yaml:"enabled" default:"false"`
	Endpoint    string                     `yaml:"endpoint" default:""`
	URLPath     string                     `yaml:"urlPath" default:""`
	Timeout     human.Duration             `yaml:"timeout" default:"15s"`
	Compression bool                       `yaml:"compression" default:"true"`
	Headers     map[string]string          `yaml:"headers"`
	Insecure    bool                       `yaml:"insecure" default:"false"`
	Retry       *otlptracehttp.RetryConfig `yaml:"retry"`
	TLS         *tls.Config                `yaml:"tls"`
	Sampling    SamplingConfig             `yaml:"sampling"`
}

func (*TracingConfig) AsOTelOpts

func (t *TracingConfig) AsOTelOpts() []otlptracehttp.Option

func (*TracingConfig) Validate

func (t *TracingConfig) Validate() error

Jump to

Keyboard shortcuts

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