otel

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: BSD-3-Clause Imports: 19 Imported by: 0

Documentation

Overview

Package otel initializes the OpenTelemetry trace, metric, and log pipelines. It uses autoexport for environment-driven configuration of exporters, supporting all standard OTEL_* env vars per D-07.

Index

Constants

This section is empty.

Variables

SyncDuration records the duration of sync operations in seconds.

View Source
var SyncOperations metric.Int64Counter

SyncOperations counts sync operations by status (success/failed).

Functions

func InitMetrics

func InitMetrics() error

InitMetrics registers custom metric instruments for sync operations per D-05. HTTP metrics are handled automatically by otelhttp middleware (Plan 03).

func NewDualLogger

func NewDualLogger(stdout io.Writer, logProvider *sdklog.LoggerProvider) *slog.Logger

NewDualLogger creates a slog.Logger that sends every log record to both a JSON stdout handler and the OTel log pipeline via otelslog per D-03. This ensures logs are always visible on stdout even if the OTel backend is unavailable.

Types

type SetupInput

type SetupInput struct {
	ServiceName string
	SampleRate  float64
}

SetupInput holds configuration for initializing the OTel pipeline. SampleRate controls trace sampling (0.0 to 1.0) per D-02.

type SetupOutput

type SetupOutput struct {
	// Shutdown flushes all providers and must be called before program exit.
	Shutdown func(context.Context) error

	// LogProvider is exposed so the caller can create a dual slog handler
	// that bridges slog records into the OTel log pipeline.
	LogProvider *sdklog.LoggerProvider
}

SetupOutput holds the OTel shutdown function and LoggerProvider for creating the dual slog handler.

func Setup

func Setup(ctx context.Context, in SetupInput) (*SetupOutput, error)

Setup initializes TracerProvider, MeterProvider, and LoggerProvider using autoexport for environment-driven exporter selection per D-06, D-07. Individual signals can be disabled via OTEL_*_EXPORTER=none per D-04.

Jump to

Keyboard shortcuts

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