Documentation
¶
Overview ¶
Package telemetry installs OpenTelemetry tracing for a process and provides the instrumentation helpers the platform's clients share.
Setup reads the standard OTEL_* environment variables. With no OTLP endpoint configured it installs nothing, so a deployment without a collector pays only for non-recording spans. Spans are exported over OTLP gRPC; a span processor strips query strings from URL attributes before export, because partner URLs carry tokens there.
Transport wraps an outbound http.RoundTripper so each partner call is a client span. It does not inject trace headers: trace context stays inside the platform rather than leaking to third-party APIs.
Index ¶
- Constants
- func Client(c *http.Client) *http.Client
- func Enabled() bool
- func Meter() metric.Meter
- func Outcome(err error) string
- func RecordError(span trace.Span, err error)
- func Setup(ctx context.Context) (func(context.Context) error, error)
- func StartRoot(ctx context.Context, name string, attrs ...attribute.KeyValue) (context.Context, trace.Span)
- func Tracer() trace.Tracer
- func Transport(base http.RoundTripper) http.RoundTripper
Constants ¶
const ScopeName = "github.com/Shamba-Records-Limited/microvault"
ScopeName is the instrumentation scope for spans and metrics the platform creates itself.
Variables ¶
This section is empty.
Functions ¶
func Client ¶
Client returns a copy of c whose transport is wrapped with Transport. A nil c yields a client with only the wrapped default transport.
func Enabled ¶
func Enabled() bool
Enabled reports whether an OTLP endpoint is configured for traces or metrics.
func Meter ¶
Meter returns the platform's meter from the global provider. Instruments created before Setup bind to the real provider once it is installed.
func Outcome ¶
Outcome is "error" for a non-nil err and "ok" otherwise — the bounded outcome label every platform metric uses.
func RecordError ¶
RecordError marks span as failed with err. A nil err is a no-op.
func Setup ¶
Setup installs the W3C propagators and, when an endpoint is configured, a batching tracer provider and a periodic meter provider, both exporting over OTLP gRPC, plus Go runtime metrics. The returned shutdown flushes pending spans and metrics; it is a no-op when telemetry is disabled.
func StartRoot ¶
func StartRoot(ctx context.Context, name string, attrs ...attribute.KeyValue) (context.Context, trace.Span)
StartRoot starts a new root span for a unit of background work — one poller item, one sweep — so each gets its own trace instead of joining whatever the caller's context carried. Ending the returned span also records the work's duration, labelled by name, so name must come from a fixed set.
func Transport ¶
func Transport(base http.RoundTripper) http.RoundTripper
Transport wraps base so each request is a client span named by method and host. A nil base means http.DefaultTransport. Trace headers are not injected.
Types ¶
This section is empty.