Documentation
¶
Overview ¶
Package temporaltrace defines the OpenTelemetry tracing contract for Temporal activity execution in loom-mcp powered runtimes.
Contract:
- Temporal activities execute in a distinct trace domain from synchronous request handling (HTTP/gRPC). Each activity execution starts a new root span (new trace ID) to avoid long-lived traces that fragment in collectors and sampling pipelines.
- If an activity is causally triggered by an upstream request trace, the upstream trace is preserved via an OTel link, not parenthood. This keeps trace trees semantically honest while retaining navigability across domains.
- Control-plane and retry scheduling are not "children" in the request tree. Durable scheduling becomes a link between traces.
Index ¶
- Constants
- func NewActivityInterceptor() interceptor.WorkerInterceptor
- func NewLinkPropagator() workflow.ContextPropagator
- func OriginTraceParent(ctx context.Context) (string, bool)
- func ParseTraceParent(traceparent string) (trace.SpanContext, error)
- func TraceParent(ctx context.Context) string
- func WithOriginTraceParent(ctx context.Context, traceparent string) context.Context
- type ActivityInterceptor
- func (i *ActivityInterceptor) InterceptActivity(ctx context.Context, next interceptor.ActivityInboundInterceptor) interceptor.ActivityInboundInterceptor
- func (i *ActivityInterceptor) InterceptWorkflow(ctx workflow.Context, next interceptor.WorkflowInboundInterceptor) interceptor.WorkflowInboundInterceptor
- type LinkPropagator
- func (p *LinkPropagator) Extract(ctx context.Context, reader workflow.HeaderReader) (context.Context, error)
- func (p *LinkPropagator) ExtractToWorkflow(ctx workflow.Context, reader workflow.HeaderReader) (workflow.Context, error)
- func (p *LinkPropagator) Inject(ctx context.Context, writer workflow.HeaderWriter) error
- func (p *LinkPropagator) InjectFromWorkflow(ctx workflow.Context, writer workflow.HeaderWriter) error
Constants ¶
const ( // HeaderTraceParent is the Temporal header key that carries the upstream W3C // traceparent string for trace-linking. HeaderTraceParent = "ck.traceparent" )
Variables ¶
This section is empty.
Functions ¶
func NewActivityInterceptor ¶
func NewActivityInterceptor() interceptor.WorkerInterceptor
NewActivityInterceptor returns a worker interceptor that starts a new root span for each activity execution and links it to the origin trace (when present).
func NewLinkPropagator ¶
func NewLinkPropagator() workflow.ContextPropagator
NewLinkPropagator returns a Temporal context propagator that carries the origin traceparent string across workflow/activity headers.
func OriginTraceParent ¶
OriginTraceParent returns the origin traceparent string stored by WithOriginTraceParent, if any.
func ParseTraceParent ¶
func ParseTraceParent(traceparent string) (trace.SpanContext, error)
ParseTraceParent parses a W3C traceparent header into a remote span context.
This function enforces the core traceparent validity rules (shape, hex encoding, non-zero trace/span IDs). If traceparent is invalid, it returns an error to surface contract violations early.
func TraceParent ¶
TraceParent returns the W3C traceparent string for the active span in ctx. Returns an empty string if no active span exists.
Types ¶
type ActivityInterceptor ¶
type ActivityInterceptor struct {
interceptor.WorkerInterceptorBase
Tracer trace.Tracer
}
ActivityInterceptor starts a new root span for each activity execution and attaches an OTel link to the origin trace (when present).
func (*ActivityInterceptor) InterceptActivity ¶
func (i *ActivityInterceptor) InterceptActivity(ctx context.Context, next interceptor.ActivityInboundInterceptor) interceptor.ActivityInboundInterceptor
func (*ActivityInterceptor) InterceptWorkflow ¶
func (i *ActivityInterceptor) InterceptWorkflow(ctx workflow.Context, next interceptor.WorkflowInboundInterceptor) interceptor.WorkflowInboundInterceptor
type LinkPropagator ¶
type LinkPropagator struct {
Converter converter.DataConverter
}
LinkPropagator carries an origin traceparent string through Temporal workflow/activity headers under HeaderTraceParent.
The payload is encoded with Temporal's data converter so it can safely flow across SDK versions and language boundaries.
func (*LinkPropagator) Extract ¶
func (p *LinkPropagator) Extract(ctx context.Context, reader workflow.HeaderReader) (context.Context, error)
func (*LinkPropagator) ExtractToWorkflow ¶
func (p *LinkPropagator) ExtractToWorkflow(ctx workflow.Context, reader workflow.HeaderReader) (workflow.Context, error)
func (*LinkPropagator) Inject ¶
func (p *LinkPropagator) Inject(ctx context.Context, writer workflow.HeaderWriter) error
func (*LinkPropagator) InjectFromWorkflow ¶
func (p *LinkPropagator) InjectFromWorkflow(ctx workflow.Context, writer workflow.HeaderWriter) error