telemetry

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package telemetry provides OpenTelemetry SDK setup for tracing and metrics.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ServiceName    string
	ServiceVersion string
	TraceWriter    io.Writer // nil = discard (used when no OTLP endpoint)
	MetricWriter   io.Writer // nil = discard (used when Prometheus is disabled)

	// OTLP exporter settings (empty = use stdout fallback)
	OTLPEndpoint string // gRPC endpoint, e.g. "localhost:4317"
	OTLPInsecure bool   // use insecure connection (no TLS)

	// Prometheus metrics (when enabled, exposes /metrics for scraping)
	PrometheusEnabled bool
}

Config holds optional settings for telemetry initialization.

type Result

type Result struct {
	Shutdown          func(context.Context) error
	PrometheusHandler *prometheus.Exporter // nil when Prometheus is disabled
}

Result holds references needed after Init (e.g. Prometheus handler).

func Init

func Init(ctx context.Context, cfg Config) (*Result, error)

Init initializes the global TracerProvider and MeterProvider. When OTLPEndpoint is set, traces are exported via OTLP gRPC (e.g. to Jaeger). When PrometheusEnabled is true, metrics are exposed via a Prometheus scrape endpoint. Falls back to stdout exporters when neither is configured.

Jump to

Keyboard shortcuts

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