telemetry

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2025 License: LGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetGlobalLogger

func GetGlobalLogger(component string) zerolog.Logger

GetGlobalLogger returns a component-specific logger using the global console logger.

func SetGlobalLogLevel

func SetGlobalLogLevel(level string)

SetGlobalLogLevel sets the global log level for console logging. Deprecated: Use proper telemetry configuration instead.

Types

type Config

type Config struct {
	// Enabled when false disables OpenTelemetry entirely.
	Enabled bool `env:"OTEL_ENABLED" envDefault:"true"`

	// Endpoint is the OTLP collector endpoint.
	Endpoint string `env:"OTEL_ENDPOINT" envDefault:"jaeger:4317"`

	// TraceSampleRate is the sampling rate for traces (0.0 to 1.0).
	TraceSampleRate float64 `env:"OTEL_TRACE_SAMPLE_RATE" envDefault:"1.0"`

	// Log level configuration ("debug", "info", "warn", "error").
	LogLevel string `env:"OTEL_LOG_LEVEL" envDefault:"info"`

	// Log format configuration ("json", "pretty").
	LogFormat string `env:"OTEL_LOG_FORMAT" envDefault:"json"`
}

type LogFormat

type LogFormat uint8

LogFormat represents the log output format.

const (
	LogFormatUndefined LogFormat = iota // Used as the zero value
	LogFormatJSON                       // Outputs structured JSON logs
	LogFormatPretty                     // Outputs human-readable console logs
)

func ParseLogFormat

func ParseLogFormat(s string) LogFormat

ParseLogFormat converts a string to LogFormat enum.

func (LogFormat) String

func (f LogFormat) String() string

type Options

type Options struct {
	ServiceName     string // Name of the service for telemetry
	Endpoint        string
	LogLevel        string
	LogFormat       LogFormat // Log output format
	TraceSampleRate float64
}

type Telemetry

type Telemetry struct {
	Logger zerolog.Logger
	Tracer trace.Tracer
	// contains filtered or unexported fields
}

func New

func New(opts Options) (Telemetry, error)

func (*Telemetry) GetLogger

func (t *Telemetry) GetLogger(component string) zerolog.Logger

GetLogger returns a component-specific logger.

func (*Telemetry) GetLoggerWithTrace

func (t *Telemetry) GetLoggerWithTrace(ctx context.Context, component string) zerolog.Logger

GetLoggerWithTrace returns a component-specific logger enriched with trace context.

func (*Telemetry) Shutdown

func (t *Telemetry) Shutdown(ctx context.Context) error

Shutdown gracefully shuts down the telemetry system.

Jump to

Keyboard shortcuts

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