Documentation
¶
Index ¶
- func Enabled() bool
- func InitTracer(ctx context.Context, serviceName, serviceVersion string) (func(), error)
- func InitTracerWithConfig(ctx context.Context, cfg *config.TelemetryConfig, ...) (func(), error)
- func NewLogProvider(ctx context.Context, cfg *config.TelemetryConfig, ...) (*sdklog.LoggerProvider, error)
- func NewLogSink(serviceName, serviceVersion string, provider log.LoggerProvider) logr.LogSink
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Enabled ¶
func Enabled() bool
Enabled returns true if OpenTelemetry tracing is active. Middleware should check this before doing any tracing work to avoid unnecessary overhead when tracing is disabled.
func InitTracer ¶
InitTracer initializes the OpenTelemetry tracer provider. Tracing is only enabled if OTEL_EXPORTER_OTLP_ENDPOINT is set. Check telemetry.Enabled() to determine if tracing is active.
func InitTracerWithConfig ¶
func InitTracerWithConfig(ctx context.Context, cfg *config.TelemetryConfig, serviceName, serviceVersion string) (func(), error)
InitTracerWithConfig initializes the OpenTelemetry tracer provider using the provided config. The config values can be overridden by environment variables. Check telemetry.Enabled() to determine if tracing is active.
func NewLogProvider ¶ added in v0.0.64
func NewLogProvider(ctx context.Context, cfg *config.TelemetryConfig, serviceName, serviceVersion string) (*sdklog.LoggerProvider, error)
NewLogProvider creates an OTLP-backed LoggerProvider that batches and exports log records. Returns nil when telemetry is disabled or no endpoint is configured. Errors are intended to be non-fatal.
This function does not use klog and is safe to call before the global klog logger is wired.
func NewLogSink ¶ added in v0.0.64
func NewLogSink(serviceName, serviceVersion string, provider log.LoggerProvider) logr.LogSink
NewLogSink creates a logr.LogSink that bridges klog output to the given OTel LoggerProvider. The provider can be a *sdklog.LoggerProvider for production or any log.LoggerProvider implementation (e.g. logtest.Recorder) for testing — the bridge treats them identically.
Types ¶
This section is empty.