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

Function application_trace_context

tests/test_open_telemetry.py:4123–4142  ·  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

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

Calls 1

CountingPropagatorClass · 0.70

Tested by

no test coverage detected