telemetry

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package telemetry wires up OpenTelemetry tracing and logging for the app.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseHeaders

func ParseHeaders(raw string) map[string]string

ParseHeaders parses the OTLP headers env-var format ("key1=value1,key2=value2") into a header map suitable for Config.Headers.

func Setup

func Setup(ctx context.Context, cfg Config) (shutdown func(context.Context) error, err error)

Setup wires up OpenTelemetry tracing and logging and installs an slog.Logger as the process default. It always logs to stdout; when cfg.Endpoint is set it additionally exports traces and logs over OTLP/HTTP.

The returned shutdown func flushes and closes any exporters that were created; call it (typically deferred) before the process exits.

Types

type Config

type Config struct {
	ServiceName    string
	ServiceVersion string

	// Endpoint is the OTLP/HTTP collector endpoint, e.g. "http://localhost:4318"
	// or "https://collector.example.com". If empty, OTLP export is disabled:
	// tracer.Start calls throughout the app fall back to OpenTelemetry's
	// built-in no-op tracer, and logging stays stdout-only.
	Endpoint string

	// Headers are sent with every OTLP export request, e.g. for collector
	// authentication.
	Headers map[string]string
}

Config controls where telemetry is exported to.

Jump to

Keyboard shortcuts

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