Documentation
¶
Overview ¶
Package tracing provides OpenTelemetry tracer initialization utilities.
Index ¶
Constants ¶
const ( // UptraceDriver is used to identify the Uptrace OpenTelemetry implementation. // See: https://uptrace.dev/get/opentelemetry-go UptraceDriver = "uptrace" // LogDriver identifies a basic tracer that writes span information to logs. LogDriver = "log" )
const ShutdownTimeout = 5 * time.Second
ShutdownTimeout ...
Variables ¶
var ( // ErrInvalidDriver indicates that the configured tracing driver name is not recognized or supported. ErrInvalidDriver = errors.New("invalid trace driver") )
Functions ¶
func New ¶
New initializes and returns the configured OpenTelemetry Tracer based on the application settings. If tracing is disabled in the configuration, it returns a no-op tracer.
func NewLogTracer ¶
NewLogTracer returns a new instance of Log tracer.
func NewNoOpTracer ¶
NewNoOpTracer initializes the OpenTelemetry global TracerProvider with a No-Operation (NoOp) provider.
A NoOp Tracer is used when tracing is explicitly disabled in the application configuration. It satisfies the OpenTelemetry interface but performs no tracing or data collection, ensuring that tracing calls in the application code do not cause errors or overhead.
Types ¶
type Log ¶
Log is a custom OpenTelemetry Tracer implementation primarily used for debugging. It embeds noop.Tracer to satisfy the trace.Tracer interface without performing standard OpenTelemetry collection/export logic. Instead, it logs the caller's function name and file location when a span is started.
func (*Log) Start ¶
func (t *Log) Start(ctx context.Context, _ string, _ ...trace.SpanStartOption) (context.Context, trace.Span)
Start implements the trace.Tracer interface method. Instead of creating a real distributed trace span, this method uses reflection (runtime.Caller) to determine the function and file line that called the tracer, and prints this information to the console for debugging purposes.