Documentation
¶
Overview ¶
Package trace provides OpenTelemetry tracing integration for Fiber.
Index ¶
- Constants
- func AddEvent(ctx context.Context, name string, attrs ...attribute.KeyValue)
- func FiberMiddleware() fiber.Handler
- func NewTracerProvider(lc fx.Lifecycle) (*sdktrace.TracerProvider, error)
- func RecordError(ctx context.Context, err error)
- func SetSpanAttributes(ctx context.Context, attrs ...attribute.KeyValue)
- func SpanFromFiber(c fiber.Ctx) oteltrace.Span
- func StartSpan(ctx context.Context, name string, attrs ...attribute.KeyValue) (context.Context, trace.Span)
- func Tracer(name string) trace.Tracer
Constants ¶
const SpanKey = "otel_span"
SpanKey is the key used to store the span in fiber.Ctx.Locals().
Variables ¶
This section is empty.
Functions ¶
func FiberMiddleware ¶
FiberMiddleware returns a Fiber v3 middleware that creates an OTel span for each request.
The span is named "HTTP {method} {route}" and includes standard HTTP semantic attributes. The span is stored in ctx.Locals() under SpanKey for downstream access. W3C TraceContext is extracted from incoming headers and propagated.
func NewTracerProvider ¶
func NewTracerProvider(lc fx.Lifecycle) (*sdktrace.TracerProvider, error)
NewTracerProvider creates and configures the global OpenTelemetry TracerProvider. It sets up an OTLP HTTP exporter and registers a shutdown hook via fx lifecycle.
func RecordError ¶
RecordError records an error on the current span in ctx.
func SetSpanAttributes ¶
SetSpanAttributes sets attributes on the span from the context if one exists.
func SpanFromFiber ¶
SpanFromFiber returns the current OTel span from a Fiber context.
Types ¶
This section is empty.