Skip to main content
theauth-go ships a pluggable Tracer adapter. The library has zero hard dependency on OpenTelemetry or any other tracing vendor. You wire your own adapter at startup.

How the adapter works

The library calls hooks.Tracer.Start(ctx, spanName, attrs...) at the entry point of every instrumented operation, then records the outcome with span.RecordError(err) (on failure) and span.SetAttributes(...) before calling span.End(). The Tracer and Span interfaces are defined in theauth.Tracer and theauth.Span (re-exported from internal/observability).

Write an OpenTelemetry adapter

Wire the adapter

Span catalog

See Spans Reference for the full list of span names and their attributes. Span names are also exported as constants (theauth.SpanOAuthToken, etc.) so dashboards can reference them by symbol.

Example adapter

A reference OpenTelemetry adapter ships in the repository at examples/observability-otel/. It is not a published package; copy it into your codebase and adjust as needed.

Adding metrics alongside tracing

To add Prometheus metrics alongside OpenTelemetry traces, also wire a Metrics adapter. See the Hooks struct:
See Metrics Reference for the full metric catalog.
Last modified on October 7, 2026