Skip to content

Explanation

Background and reasoning. Nothing here is needed to get telemetry flowing; all of it is useful when deciding whether this module fits, or when something behaves in a way that looks wrong until you know why.

Four ideas the rest of the documentation assumes

Typed values in, providers out. The module does no configuration parsing and no environment scanning of its own. You resolve a Settings from wherever your configuration lives; it turns that into a provider. Removing the coupling to a config framework is the reason the module exists separately at all.

One exporter, three destinations. logs, metrics and tracing each ask otelcore.Exporter for their own signal, so a collector, a slog logger or a writer serves all three without the signal packages knowing which it was given.

Recording an error is kept apart from exporting it. Building a provider happens once, at start-up, and needs the SDK and an exporter. Recording an error happens on every failure, often inside a library. spanerr therefore lives in its own package and imports only the OpenTelemetry APIs, so a library that records errors does not put an exporter into every binary that imports it. It is here at all because go/errors leaves the OpenTelemetry side of its error contract to this module: the kind, the origin stack and the hints that the SDK's RecordError cannot see.

An empty endpoint is intentional. It means "fall back to the standard OTEL_EXPORTER_OTLP_* environment variables", not "misconfigured". It is never treated as an error, in code or in documentation.