observability¶
OpenTelemetry providers for Go services. Build OTLP providers for logs, metrics
and traces from one typed config, with validated endpoints and a fallback to the
standard OTEL_EXPORTER_OTLP_* environment variables.
gitlab.com/phpboyscout/go/observability sets up OpenTelemetry export for a service
without bringing a framework along. Resolve a typed
Settings
once, then hand it to the logs, metrics and tracing provider factories. It is
the observability layer extracted from
go-tool-base.
Why¶
- Framework-free, OTel-native. It carries the OpenTelemetry SDK, because that is
its job. Apart from the OpenTelemetry modules, the only module it imports is
go/errors, and adepfootprint_test.goguard forbids go-tool-base, Viper, Cobra, pflag, Charm and the AWS, GCP and Azure SDKs. - Typed values in, providers out.
otelcoreworks from a typedSettings; you own how those are sourced.ResolveSettingsmerges a shared config with per-signal overrides, so one endpoint serves all three signals with targeted exceptions. - Telemetry goes where you point it. A collector over OTLP/HTTP, readable lines
through any
slog.Logger, or OTLP JSON lines in a file, chosen with one field. - Errors render onto spans.
spanerrrecords a go/errors error on the active span with its kind, origin stack and hints, using the OpenTelemetry APIs only. See Record an error on a span. - Env fallback. An empty
Endpointis intentional, not an error: the SDK then reads the standardOTEL_EXPORTER_OTLP_*variables. See the config model.
What it does not do¶
Worth reading before you go looking for something that is not here. It builds
OTLP/HTTP, slog and OTLP JSON file exporters only: no gRPC and no Prometheus. It starts no spans
and records nothing until you call it, so there is no automatic HTTP, gRPC or runtime
instrumentation.
It registers nothing globally, and it does not honour Settings.Enabled,
OTEL_TRACES_SAMPLER or OTEL_METRIC_EXPORT_INTERVAL.
The full list, with the reasoning, is on What this module does not do.
Where next¶
- Getting started: a tracer provider in a dozen lines.
- Instrument a small service: rate, errors and duration for an operation, a database and a cache, read in your terminal.
- Export all three signals: traces, metrics and logs to a local collector you can watch.
- How-to guides: wire the signals, correlate logs with traces, record an error on a span, diagnose telemetry that never arrives.
- Reference: configuration keys,
provider options and defaults, the
OTEL_*contract, and every error. - Explanation: the config model, the limitations, and the OTel version lockstep.
- API reference: full godoc on pkg.go.dev.
Part of the phpboyscout Go toolkit, a set of small, framework-free Go modules extracted from go-tool-base.
Further reading¶
The blog collects its posts on this subject under the Observability tag. For a guided start, Add OpenTelemetry traces, metrics and logs to a Go service wires these providers into a running service, as part of the Building a web service in Go route.
Ask phpbotscout

He answers questions about the projects over on the Discord, citing the docs where they already cover it, and offering to raise an issue where they don't. Bring a bug, an idea, or a questionable engineering decision.