telemetry

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2026 License: MIT Imports: 16 Imported by: 0

README

internal/telemetry

Logic overview

The telemetry package configures OpenTelemetry tracing behavior.

  • Supports operational trace modes: off, sampled, errors, detailed.
  • Applies sampler strategy based on configured mode and sample ratio.
  • Stores active mode globally so dependency clients can omit detailed spans unless detailed is enabled.
  • Registers a global tracer provider.
  • Optionally wires an OTLP/HTTP trace exporter when OTLPEndpoint is configured.
  • Exposes shutdown hook for graceful provider flush/cleanup.

API reference

Types
  • Config: telemetry config input (Enabled, ServiceName, OTLPEndpoint, TraceMode, TraceSampleRatio).
  • Runtime: initialized telemetry runtime (TracerProvider, Shutdown).
Functions
  • Setup(cfg Config) (Runtime, error): initializes global tracing provider and returns runtime handles.
  • TraceMode() string: returns normalized active trace mode.
  • ShouldTraceDependencies() bool: returns true only when detailed dependency spans should be emitted.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ShouldTraceDependencies

func ShouldTraceDependencies() bool

ShouldTraceDependencies reports if detailed dependency spans should be emitted.

func TraceMode

func TraceMode() string

TraceMode reports the configured global trace mode.

Types

type Config

type Config struct {
	Enabled          bool
	ServiceName      string
	OTLPEndpoint     string
	TraceMode        string
	TraceSampleRatio float64
}

Config configures OpenTelemetry tracing setup.

type Runtime

type Runtime struct {
	TracerProvider *sdktrace.TracerProvider
	Shutdown       func(ctx context.Context) error
}

Runtime contains initialized telemetry providers and lifecycle hooks.

func Setup

func Setup(cfg Config) (Runtime, error)

Setup initializes global OpenTelemetry tracing according to the provided configuration.

Jump to

Keyboard shortcuts

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