Documentation
¶
Index ¶
- func ContextField(ctx context.Context) zap.Field
- func Logger(ctx context.Context) (*zap.Logger, error)
- func LoggerOrDefault(ctx context.Context, def *zap.Logger) *zap.Logger
- func SetJobMetadata(ctx context.Context, meta JobMetadata) context.Context
- func SetLogger(ctx context.Context, l *zap.Logger) context.Context
- func SetLoggerWithSpan(ctx context.Context, l *zap.Logger) context.Context
- func SetTracerProvider(ctx context.Context, tp oteltrace.TracerProvider) context.Context
- func TracerProvider(ctx context.Context) oteltrace.TracerProvider
- type JobMetadata
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextField ¶ added in v0.19.915
ContextField builds a zap field whose Interface is the Go context. otelzap detects the context.Context value and uses it as the emit context, which is what makes trace_id / span_id land in the dedicated OTLP log record columns rather than as Map attributes. We use SkipType so the dev / stdout encoders do not try to print the context.
func LoggerOrDefault ¶ added in v0.19.915
LoggerOrDefault returns the logger stored on ctx, or the provided default when ctx has no logger or carries a nil one. Use this at the top of helpers that wrap an op.Tool span and want to use the new span-tagged logger when available without each callsite having to re-implement the lookup + fallback dance.
func SetJobMetadata ¶ added in v0.19.915
func SetJobMetadata(ctx context.Context, meta JobMetadata) context.Context
func SetLoggerWithSpan ¶ added in v0.19.915
SetLoggerWithSpan is the same as SetLogger but also decorates the logger with ContextField(ctx) so the otelzap bridge can extract span_id / trace_id from the current span on every emit. Use this whenever you store a logger into a context that carries a new span (jobloop step boundary, op.Start, per-handler logger setup) — without it, downstream log calls land in otel_log_records with empty span_id even though the trace tab has spans.
func SetTracerProvider ¶ added in v0.19.915
func TracerProvider ¶ added in v0.19.915
func TracerProvider(ctx context.Context) oteltrace.TracerProvider
TracerProvider returns the ctx-scoped TracerProvider if present, otherwise the OTEL global. Callers should always go through this helper rather than otel.GetTracerProvider() so that the lookup picks up the process-scoped provider stamped by jobloop.executeJob.
Types ¶
type JobMetadata ¶ added in v0.19.915
JobMetadata captures the runner identifiers a span / log record should carry regardless of where in the call tree it is emitted. We thread it via context so op.Start can stamp every span with these without each callsite repeating itself.
func GetJobMetadata ¶ added in v0.19.915
func GetJobMetadata(ctx context.Context) (JobMetadata, bool)