feat(controlplane): add OTel trace/span IDs to Sentry request context#3305
Conversation
Surface the OpenTelemetry trace and span IDs on control-plane Sentry error events so an event can be cross-referenced with its distributed trace in the OTLP backend (Tempo/Jaeger). The IDs are read from the request context (populated by the otelgrpc server handler) and added to the Sentry Request context as otel-trace-id and otel-span-id when a valid span context is present. They are informational fields and do not alter Sentry's canonical trace_id. Assisted-by: Claude Code Signed-off-by: Javier Rodriguez <javier@chainloop.dev> Chainloop-Trace-Sessions: e2467003-af35-4aaa-b332-c9255f3d6171
AI Session Analysis
|
| Status | Attribution | File | Lines |
|---|---|---|---|
| modified | ai | app/controlplane/internal/sentrycontext/sentry_context_test.go |
+22 / -1 |
| modified | ai | app/controlplane/internal/sentrycontext/sentry_context.go |
+14 / -2 |
Policies (4)
| Status | Policy | Material | Messages |
|---|---|---|---|
| ✅ Passed | ai-config-ai-agents-allowed |
ai-coding-session-e24670 |
- |
| ✅ Passed | ai-config-no-dangerous-commands |
ai-coding-session-e24670 |
- |
| ✅ Passed | ai-config-no-secrets |
ai-coding-session-e24670 |
- |
| ✅ Passed | ai-config-mcp-servers-allowed |
ai-coding-session-e24670 |
- |
Powered by Chainloop and Chainloop Trace
Summary
Adds the OpenTelemetry trace and span IDs to control-plane Sentry error events so an event can be cross-referenced with its distributed trace in the OTLP backend (Tempo/Jaeger).
The
NewSentryContextmiddleware now reads the OTelSpanContextfrom the request context (populated by theotelgrpcserver handler) and, when a valid span context is present, addsotel-trace-idandotel-span-idto the Sentry Request context. When tracing is disabled or the span context is invalid, the fields are omitted. These are informational fields and do not alter Sentry's canonicaltrace_id.Closes PFM-6777.
AI disclosure
Assisted by Claude Code.