telemetry

package
v0.0.65 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

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

func InitTracer(ctx context.Context, serviceName, serviceVersion string) (func(), error)

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.

Jump to

Keyboard shortcuts

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