Add initial work from Codex
This commit is contained in:
19
backend/microservices/common/http.py
Normal file
19
backend/microservices/common/http.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from opentelemetry import trace
|
||||
|
||||
|
||||
def current_trace_headers() -> dict[str, str]:
|
||||
span_context = trace.get_current_span().get_span_context()
|
||||
if not span_context.is_valid:
|
||||
return {}
|
||||
return {
|
||||
"x-trace-id": f"{span_context.trace_id:032x}",
|
||||
"x-span-id": f"{span_context.span_id:016x}",
|
||||
}
|
||||
|
||||
|
||||
def with_internal_service_token(headers: dict[str, str], token: str) -> dict[str, str]:
|
||||
merged = dict(headers)
|
||||
merged["x-internal-service-token"] = token
|
||||
return merged
|
||||
Reference in New Issue
Block a user