Documentation
¶
Index ¶
Constants ¶
const ScopeName = "github.com/ingka-group/fastecho/"
ScopeName is the instrumentation scope name for fastecho's own spans.
Variables ¶
This section is empty.
Functions ¶
func SpanFunc ¶
SpanFunc runs fn inside a span named name, for tracing work that has no context.Context to thread. A panic in fn is recorded on the span and re-raised. With tracing off, fn still runs under a no-op span.
func StartSpan ¶
StartSpan starts a child span named after the calling function (formatted as package.Type.Method, e.g. "forecast.Service.Recompute") and returns the updated context and span; end it with defer span.End(). It uses the fctx-seeded tracer, falling back to the global provider. For a custom name, call SpanFunc or the OTel tracer API directly.
func WrapClient ¶
WrapClient decorates c's transport so every request propagates the caller's trace context (via otelhttp) and forwards fctx.RequestID as X-Request-Id. It mutates and returns c; a nil client is allocated. Only the transport changes.
func WrapTransport ¶
func WrapTransport(base http.RoundTripper) http.RoundTripper
WrapTransport wraps base (nil → http.DefaultTransport) with trace-context propagation and X-Request-Id forwarding. Use this when you hold a RoundTripper directly (e.g. instrumenting a generated client). Wrapping an already-wrapped transport is a no-op, so double-wrapping cannot stack duplicate spans.
Types ¶
type Config ¶
Config carries only wiring that has no env equivalent; behavior values (endpoint, sampling, exporter) come from OTEL_* env so there is one source of truth per setting.
type Providers ¶
type Providers struct {
TracerProvider trace.TracerProvider
MeterProvider metric.MeterProvider
// PrometheusGatherer is non-nil when OTEL_METRICS_EXPORTER=prometheus; the
// router serves it at /metrics on the main port. Nil otherwise.
PrometheusGatherer prometheus.Gatherer
// contains filtered or unexported fields
}
Providers holds the configured providers and a single shutdown closer.
func Init ¶
Init builds the providers from OTEL_* env and returns them with one shutdown. It registers each provider (and, with tracing, the propagator) as the process-global OTel singleton — but only for enabled signals, so skipping a signal leaves an application's own OTel setup untouched. Call PrintConfiguration to log what it resolved.
func (*Providers) PrintConfiguration ¶
func (p *Providers) PrintConfiguration()
PrintConfiguration prints the resolved telemetry configuration at startup. It reads the exported env (not stored state), so it is safe on any Providers value.