Runs with a sampled span and a baggage entry current, as an instrumented application calls the SDK.
()
| 4120 | |
| 4121 | @contextmanager |
| 4122 | def 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 | |
| 4144 | class TestPropagationOption: |
no test coverage detected