pkgctx

package
v0.19.921 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextField added in v0.19.915

func ContextField(ctx context.Context) zap.Field

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 Logger

func Logger(ctx context.Context) (*zap.Logger, error)

func LoggerOrDefault added in v0.19.915

func LoggerOrDefault(ctx context.Context, def *zap.Logger) *zap.Logger

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 SetLogger

func SetLogger(ctx context.Context, l *zap.Logger) context.Context

func SetLoggerWithSpan added in v0.19.915

func SetLoggerWithSpan(ctx context.Context, l *zap.Logger) context.Context

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 SetTracerProvider(ctx context.Context, tp oteltrace.TracerProvider) context.Context

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

type JobMetadata struct {
	RunnerJobID          string
	RunnerJobExecutionID string
	StepName             string
}

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)

Jump to

Keyboard shortcuts

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