trace

package
v0.0.0-...-dc92ef2 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextWithSpan

func ContextWithSpan(ctx context.Context) context.Context

ContextWithSpan .

func GetTracerProvider

func GetTracerProvider() *sdktrace.TracerProvider

GetTracerProvider returns the current tracer provider

func Go

func Go(ctx context.Context, fn func())

Go .

func GoWithContext

func GoWithContext(ctx context.Context, fn func(ctx context.Context))

GoWithContext .

func Init

func Init(cfg TraceConfig) error

Init initializes OpenTelemetry tracing with the given configuration

func RunWithTrace

func RunWithTrace(ctx context.Context, fn func(ctx context.Context))

RunWithTrace .

func Shutdown

func Shutdown(ctx context.Context) error

Shutdown gracefully shuts down the tracer provider

Types

type BatchConfig

type BatchConfig struct {
	// MaxQueueSize is the maximum queue size
	MaxQueueSize int `mapstructure:"maxQueueSize"`
	// BatchTimeout is the timeout for batching spans
	BatchTimeout time.Duration `mapstructure:"batchTimeout"`
	// ExportTimeout is the timeout for exporting spans
	ExportTimeout time.Duration `mapstructure:"exportTimeout"`
	// MaxExportBatchSize is the maximum batch size for export
	MaxExportBatchSize int `mapstructure:"maxExportBatchSize"`
}

BatchConfig configures the batch span processor

type TraceConfig

type TraceConfig struct {
	// Enabled enables or disables tracing
	Enabled bool `mapstructure:"enabled"`
	// ServiceName is the name of the service
	ServiceName string `mapstructure:"serviceName"`
	// ServiceVersion is the version of the service
	ServiceVersion string `mapstructure:"serviceVersion"`
	// ExporterType specifies the exporter type: "jaeger", "otlp-grpc", "otlp-http", or "none"
	ExporterType string `mapstructure:"exporterType"`
	// Endpoint is the endpoint URL for the exporter
	// For Jaeger: http://localhost:14268/api/traces
	// For OTLP gRPC: localhost:4317
	// For OTLP HTTP: http://localhost:4318
	Endpoint string `mapstructure:"endpoint"`
	// Insecure allows insecure connections (for development)
	Insecure bool `mapstructure:"insecure"`
	// Headers are additional headers to send with the trace export
	Headers map[string]string `mapstructure:"headers"`
	// BatchConfig configures the batch span processor
	BatchConfig BatchConfig `mapstructure:"batch"`
}

TraceConfig represents the configuration for OpenTelemetry tracing

func (*TraceConfig) SetDefaults

func (c *TraceConfig) SetDefaults()

SetDefaults sets default values for the configuration

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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