Condukt.TraceContext (Condukt v3.0.0)

Copy Markdown View Source

A lightweight carrier for World Wide Web Consortium Trace Context headers.

Condukt does not start traces or export telemetry. Applications can opt in to propagation by passing a context through :trace_context, or by storing one in the calling process with put_current/1. Native model calls then receive a fresh child traceparent, optional tracestate, and a baggage entry that identifies the opaque Condukt session.

context = Condukt.TraceContext.new()

Condukt.run(MyApp.Agent, "Summarize this report.",
  trace_context: context
)

This module only carries identifiers. It has no dependency on, or runtime requirement for, an OpenTelemetry implementation.

Summary

Functions

Captures the context selected by request options or the calling process.

Returns a fresh child context for one outbound operation.

Removes the current process context.

Returns the context associated with the current process, if any.

Extracts a trace context from World Wide Web Consortium propagation headers.

Creates a trace context suitable for a Condukt run.

Stores a trace context in the current process and returns it.

Binds the current OpenTelemetry trace to the calling process.

Functions

capture(opts)

Captures the context selected by request options or the calling process.

trace_context: true starts a new root context when the process has none. trace_context: false disables propagation for that run. Omitting the option uses current/0, so applications can bind their own tracing integration once around a request handler.

child(context)

Returns a fresh child context for one outbound operation.

clear_current()

Removes the current process context.

current()

Returns the context associated with the current process, if any.

from_headers(headers)

Extracts a trace context from World Wide Web Consortium propagation headers.

new(opts \\ [])

Creates a trace context suitable for a Condukt run.

Supplying :trace_id and :span_id is useful when adapting a context from another tracing implementation. :tracestate and :baggage are forwarded unchanged, apart from Condukt replacing its own session baggage entry.

put_current(context)

Stores a trace context in the current process and returns it.

Condukt captures this value at the public run or stream boundary before it crosses process boundaries.

put_current_from_otel!()

Binds the current OpenTelemetry trace to the calling process.

This is an optional integration point. It dynamically invokes the OpenTelemetry text-map propagator, so using Condukt does not require an OpenTelemetry dependency. When the application has no active OpenTelemetry trace, it clears any Condukt trace context and returns nil.

Condukt.TraceContext.put_current_from_otel!()