traceutil

package
v0.6.13 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package traceutil adapts framingo's explicit model.Tracer handle to the plain OpenTelemetry interfaces that third-party instrumentation expects.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fail added in v0.6.13

func Fail(span trace.Span, err error) error

Fail records err on the span, marks it failed, ends it, and hands err back - so an error return stays one line:

return nil, traceutil.Fail(span, errors.Wrap(err))

The success path ends the span itself with a plain span.End(). Every return must do one or the other: a path that does neither leaks an unended span that never exports.

func LiveProvider

func LiveProvider(t model.Tracer) trace.TracerProvider

LiveProvider adapts a model.Tracer into a trace.TracerProvider that re-resolves the real provider on every span instead of holding one.

Instrumentation libraries almost all take a TracerProvider and read provider.Tracer(...) once, at construction. Handing them model.Tracer's provider directly would pin their spans to whichever provider happened to be live at wiring time - and a tracing-service restart retires that one, which then drops every span it is given without erroring. Use this wherever a library wants a TracerProvider:

tracing.WithTracerProvider(traceutil.LiveProvider(t))

Start resolves through model.Tracer on each call, which costs a lock and a map lookup in the SDK's tracer cache. Immaterial at database-statement rates; worth measuring before putting it on a per-request path.

func Start added in v0.6.13

func Start(ctx context.Context, scope, name string, opts ...trace.SpanStartOption) (context.Context, trace.Span)

Start begins a child span from the provider already bound to ctx's span - the handle-free path for business code. The middleware's request span carries the live provider, so no service holds a tracer; a context without a recording span (tracing off, unit tests) yields a noop span.

Types

This section is empty.

Jump to

Keyboard shortcuts

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