# `Condukt.TraceContext`
[🔗](https://github.com/tuist/tuist/blob/condukt@3.0.0/condukt/lib/condukt/trace_context.ex#L1)

A lightweight carrier for [World Wide Web Consortium Trace Context](https://www.w3.org/TR/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.

# `capture`

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`

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`

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

# `new`

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`

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!()

---

*Consult [api-reference.md](api-reference.md) for complete listing*
