otelx

package
v1.95.2 Latest Latest
Warning

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

Go to latest
Published: May 4, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LayerKey = attribute.Key("chainloop.layer")

LayerKey is the span attribute key used to tag spans by architectural layer. Values: "service", "biz", "data", "interceptor", "middleware", "job", "consumer".

Functions

func RecordError

func RecordError(span trace.Span, err error)

RecordError records an error on the span and sets its status to Error.

func SetDisabledLayers

func SetDisabledLayers(layers map[string]bool)

SetDisabledLayers configures which layers should not produce spans. Call once at startup from the server initialization.

func Start

func Start(ctx context.Context, tracer *LayeredTracer, spanName string, attrs ...attribute.KeyValue) (context.Context, trace.Span)

Start begins a new span tagged with the chainloop.layer attribute. If the layer is disabled, returns a no-op span (zero cost).

Types

type LayeredTracer

type LayeredTracer struct {
	// ServiceName is the service prefix (e.g. "chainloop-controlplane").
	ServiceName string
	// Name is the full scope name (e.g. "biz/workflow").
	Name string
	// Layer is the architectural layer prefix (e.g. "biz", "data", "middleware").
	Layer string
}

LayeredTracer carries the layer name for automatic tagging and filtering. Created at package init time via Tracer(), but the disabled check happens lazily in Start so the config can load first.

func Tracer

func Tracer(serviceName, name string) *LayeredTracer

Tracer returns a LayeredTracer scoped to a chainloop service. The serviceName identifies the service ("chainloop-controlplane" or "chainloop-cas"). The name should follow "layer/component" (e.g. "biz/workflow", "data/organization"). Safe to call at package init time — the disabled check is deferred to span creation.

type TraceCarrier

type TraceCarrier struct {
	TraceContext map[string]string `json:"trace_context,omitempty"`
}

TraceCarrier holds W3C trace context for propagation across async boundaries. Embed this in job arg structs so the originating request's trace context is carried to the worker.

func InjectTraceContext

func InjectTraceContext(ctx context.Context) TraceCarrier

InjectTraceContext extracts the current span's trace context into a TraceCarrier. Call this when enqueueing a job to capture the originating request's trace.

Jump to

Keyboard shortcuts

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