Trace
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
Prop
Type
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
Prop
Type
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
Prop
Type
Returns
opentelemetry.context.Context - A new Context with the extracted trace and baggage data.