MCPcopy Index your code
hub / github.com/github/copilot-sdk / get_trace_context

Function get_trace_context

python/copilot/_telemetry.py:9–23  ·  view source on GitHub ↗

Get the current W3C Trace Context (traceparent/tracestate) if OpenTelemetry is available.

()

Source from the content-addressed store, hash-verified

7
8
9def get_trace_context() -> dict[str, str]:
10 """Get the current W3C Trace Context (traceparent/tracestate) if OpenTelemetry is available."""
11 try:
12 from opentelemetry import context, propagate
13 except ImportError:
14 return {}
15
16 carrier: dict[str, str] = {}
17 propagate.inject(carrier, context=context.get_current())
18 result: dict[str, str] = {}
19 if "traceparent" in carrier:
20 result["traceparent"] = carrier["traceparent"]
21 if "tracestate" in carrier:
22 result["tracestate"] = carrier["tracestate"]
23 return result
24
25
26@contextmanager

Callers 6

create_sessionMethod · 0.85
resume_sessionMethod · 0.85
sendMethod · 0.85

Calls 1

get_currentMethod · 0.45

Used in the wild real call sites across dependent graphs

searching dependent graphs…