MCPcopy Create free account
hub / github.com/anthropics/anthropic-sdk-python / application_trace_context

Function application_trace_context

tests/test_open_telemetry.py:4122–4141  ·  view source on GitHub ↗

Runs with a sampled span and a baggage entry current, as an instrumented application calls the SDK.

()

Source from the content-addressed store, hash-verified

4120
4121@contextmanager
4122def application_trace_context() -> Iterator[CountingPropagator]:
4123 """Runs with a sampled span and a baggage entry current, as an instrumented application calls the SDK."""
4124 parent = trace.NonRecordingSpan(
4125 trace.SpanContext(
4126 trace_id=0x1234,
4127 span_id=0x5678,
4128 is_remote=True,
4129 trace_flags=trace.TraceFlags(trace.TraceFlags.SAMPLED),
4130 trace_state=trace.TraceState([("vendor", "value")]),
4131 )
4132 )
4133 registered = propagate.get_global_textmap()
4134 counting = CountingPropagator(registered)
4135 propagate.set_global_textmap(counting)
4136 token = context.attach(baggage.set_baggage("tenant", "acme", trace.set_span_in_context(parent)))
4137 try:
4138 yield counting
4139 finally:
4140 context.detach(token)
4141 propagate.set_global_textmap(registered)
4142
4143
4144class TestPropagationOption:

Calls 1

CountingPropagatorClass · 0.70

Tested by

no test coverage detected