Skip to content
Judgment Labs
Esc
↑↓navigate↵open⌘Jpreview
On this page

Propagation

get_global_textmap()

Return the active composite propagator (W3C TraceContext + Judgment Baggage).

def get_global_textmap() -> TextMapPropagator:

Returns

TextMapPropagator


set_global_textmap()

Replace the global text-map propagator.

def set_global_textmap(propagator) -> None:

Parameters

PropType
propagatorTextMapPropagator
TypeTextMapPropagator

Returns

None


inject()

Inject trace context and baggage into an outgoing carrier (e.g. HTTP headers).

Call this before making an outbound HTTP request to propagate the current trace across service boundaries.

headers = {}
propagation.inject(headers)
response = requests.get("https://api.example.com", headers=headers)
def inject(carrier, context=None, setter=default_setter) -> None:

Parameters

PropType
carrierobject

A mutable mapping (typically a dict) to write propagation headers into.

Typeobject
context?Optional[Context]

The OTel context to inject. Defaults to the current Judgment context.

TypeOptional[Context]
DefaultNone
setter?Setter

Strategy for writing values into the carrier.

TypeSetter
Defaultdefault_setter

Returns

None


extract()

Extract trace context and baggage from an incoming carrier.

Call this when handling an inbound request to continue an existing trace started by an upstream service.

ctx = propagation.extract(request.headers)
with Tracer.start_as_current_span("handle-request", context=ctx):
    ...
def extract(carrier, context=None, getter=default_getter) -> opentelemetry.context.Context:

Parameters

PropType
carrierobject

A mapping containing propagation headers (e.g. request.headers).

Typeobject
context?Optional[Context]

Base context to merge into. Defaults to the current Judgment context.

TypeOptional[Context]
DefaultNone
getter?Getter

Strategy for reading values from the carrier.

TypeGetter
Defaultdefault_getter

Returns

opentelemetry.context.Context - A new Context with the extracted trace and baggage data.

Was this page helpful?