telemetry

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: AGPL-3.0 Imports: 19 Imported by: 0

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

View Source
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

func Client(c *http.Client) *http.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

func Meter() metric.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

func Outcome(err error) string

Outcome is "error" for a non-nil err and "ok" otherwise — the bounded outcome label every platform metric uses.

func RecordError

func RecordError(span trace.Span, err error)

RecordError marks span as failed with err. A nil err is a no-op.

func Setup

func Setup(ctx context.Context) (func(context.Context) error, error)

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 Tracer

func Tracer() trace.Tracer

Tracer returns the platform's tracer from the global provider.

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.

Jump to

Keyboard shortcuts

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