Documentation
¶
Index ¶
- func Fields(ctx context.Context) []zap.Field
- func From(ec echo.Context) context.Context
- func Logger(ctx context.Context) *zap.Logger
- func Middleware(logger *zap.Logger, tracer trace.Tracer) echo.MiddlewareFunc
- func MustLogger(ctx context.Context) *zap.Logger
- func NewRequestID() string
- func RequestID(ctx context.Context) string
- func Tracer(ctx context.Context) trace.Tracer
- func TracerFrom(ctx context.Context) (trace.Tracer, bool)
- func WithLogger(ctx context.Context, l *zap.Logger) context.Context
- func WithNewRequestID(ctx context.Context) context.Context
- func WithRequestID(ctx context.Context, id string) context.Context
- func WithTracer(ctx context.Context, t trace.Tracer) context.Context
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Fields ¶ added in v0.16.0
Fields returns the correlation fields for ctx, shared by middleware, the recover handler, and worker seeds. They are discrete, indexable log fields (not the traceparent wire header) so the backend can query by trace_id.
func From ¶
From returns the request-scoped context.Context from an echo.Context.
Call this once at the handler boundary; downstream code should accept context.Context, not echo.Context.
func Logger ¶
Logger returns the request-scoped *zap.Logger from ctx. Returns a no-op logger if none was registered.
func Middleware ¶
Middleware injects logger, tracer, and request ID into the request's context.Context, making them available via Logger, Tracer, and RequestID.
tracer may be nil (tracing disabled). Tracer returns a no-op fallback.
func MustLogger ¶
MustLogger returns the request-scoped *zap.Logger from ctx. Panics if no logger is present. Use in code that must fail fast when context is misconfigured.
func NewRequestID ¶ added in v0.16.0
func NewRequestID() string
NewRequestID returns a fresh UUIDv4 request id
func Tracer ¶
Tracer returns the OTel tracer from ctx. Returns a no-op tracer if none was registered, no spans are produced.
func TracerFrom ¶ added in v0.16.0
TracerFrom returns the tracer stored in ctx and whether one was set, for callers that want their own fallback instead of Tracer's no-op.
func WithLogger ¶
WithLogger stores the logger in ctx.
func WithNewRequestID ¶ added in v0.16.0
WithNewRequestID stores a fresh request id in ctx. Use it to seed correlation for work that has no inbound request (background jobs, cron).
func WithRequestID ¶
WithRequestID stores the request ID in ctx.
Types ¶
This section is empty.