PR #290 · pramaan-io/pramaan-functions · merged 2026-06-10
Two tracing stacks. One request. Zero trust between them.
Custom FastAPI instrumentation, monkey-patched services and Powertools Tracer all writing the same request — cold-starts balloon, span IDs don't correlate, logs lose their traces.
More wrappers = more cost, less clarity.
The fix — One tracking number follows every parcel — duplicate tracing ends at SQS, not at the dashboard.
sequenceDiagram autonumber participant client as Client participant lambda as Lambda (Powertools tracer) participant sqs as SQS participant adot as ADOT :22 participant logs as Logs Insights client->>lambda: traceparent header lambda->>lambda: tracer.capture_lambda_handler → root span lambda->>sqs: msg attrs: traceparent, tracestate, correlation_id sqs->>lambda: next handler resumes same trace lambda-->>adot: xray + tracecontext export adot-->>logs: Logs Insights joins trace_id + correlation_id
| Method | in → out | what it does |
|---|---|---|
_trace_message_attributes | () → dict[str, Any] |
src/app_api/router_ws.py+29 −6Adds `_trace_message_attributes` so traceparent, tracestate and correlation_id travel on every SQS message; the trace survives the queue hop (claim: SQS enqueue carries those attributes).
| new method | signature |
|---|---|
_trace_message_attributes | () → dict[str, Any] |
Adds an optional `correlation_id` on `AgentCommand` so older frontends that omit it still produce valid commands (claim: AgentCommand.correlation_id optional + backward compatible).
correlation_id : str | None