feat(telemetry): W3C propagation, route-named spans, trace-linked logs #577

Merged
sharang merged 1 commits from feat/otel-propagation into main 2026-10-29 10:13:34 +00:00
Owner

P2 of the instrumentation plan (research/observability/2026-10-28-instrumentation-portal-registry-db.md). Portal and tenant-registry already trace on stage; Prüfwerk was the gap.

What

  • Propagation: init_telemetry sets the W3C TraceContextPropagator. RegistryClient::request() (entitlements, tenants, projects, audit, API-key verify, usage) adds traceparent, so the registry's spans become children of Prüfwerk's trace.
  • Server spans: api/trace.rs gives TraceLayer its own span: INFO (the default was DEBUG and the INFO filter dropped it, so the agent had no HTTP server spans at all), named METHOD <route template> from MatchedPath (GET unmatched otherwise), continues an incoming traceparent (portal, registry), records the status, 5xx = error. /api/v1/health gets no span. No path, query or client address (the default recorded the full URI).
  • Log ↔ trace: opentelemetry-appender-tracing with experimental_use_tracing_span_context, so OTLP log records carry trace_id/span_id and SigNoz links them (today 0 Prüfwerk log lines carry a trace id).
  • Helpers in compliance-core::telemetry (trace_context_headers, continue_trace), so the agent needs no direct OTel dependency.

Checks

cargo fmt --check; clippy -D warnings for core, agent, dashboard (server); cargo test -p compliance-core -p compliance-agent --lib (954 + 183, incl. new: traceparent continued and passed on with the child's own span id, root without one, no headers outside a trace; span named after the route, path/query never recorded, 5xx marks the span, health untraced, unmatched); cargo audit green.

Not in this PR

deployment.environment comes from OTEL_RESOURCE_ATTRIBUTES (the resource builder reads it) — one env line per service in orca-platform. P1 (drop the duplicate docker copy of Prüfwerk logs) is separate.

🤖 Generated with Claude Code

https://claude.ai/code/session_01KYcAAeTw22GE9QPzDM8yc4

P2 of the instrumentation plan (`research/observability/2026-10-28-instrumentation-portal-registry-db.md`). Portal and tenant-registry already trace on stage; Prüfwerk was the gap. ## What - **Propagation:** `init_telemetry` sets the W3C `TraceContextPropagator`. `RegistryClient::request()` (entitlements, tenants, projects, audit, API-key verify, usage) adds `traceparent`, so the registry's spans become children of Prüfwerk's trace. - **Server spans:** `api/trace.rs` gives `TraceLayer` its own span: INFO (the default was DEBUG and the INFO filter dropped it, so the agent had **no HTTP server spans** at all), named `METHOD <route template>` from `MatchedPath` (`GET unmatched` otherwise), continues an incoming `traceparent` (portal, registry), records the status, 5xx = error. `/api/v1/health` gets no span. No path, query or client address (the default recorded the full URI). - **Log ↔ trace:** `opentelemetry-appender-tracing` with `experimental_use_tracing_span_context`, so OTLP log records carry `trace_id`/`span_id` and SigNoz links them (today 0 Prüfwerk log lines carry a trace id). - Helpers in `compliance-core::telemetry` (`trace_context_headers`, `continue_trace`), so the agent needs no direct OTel dependency. ## Checks `cargo fmt --check`; clippy `-D warnings` for core, agent, dashboard (server); `cargo test -p compliance-core -p compliance-agent --lib` (954 + 183, incl. new: traceparent continued and passed on with the child's own span id, root without one, no headers outside a trace; span named after the route, path/query never recorded, 5xx marks the span, health untraced, unmatched); `cargo audit` green. ## Not in this PR `deployment.environment` comes from `OTEL_RESOURCE_ATTRIBUTES` (the resource builder reads it) — one env line per service in orca-platform. P1 (drop the duplicate docker copy of Prüfwerk logs) is separate. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01KYcAAeTw22GE9QPzDM8yc4
sharang added 1 commit 2026-10-29 09:58:10 +00:00
feat(telemetry): W3C propagation, route-named spans, trace-linked logs
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Check (pull_request) Successful in 14m33s
85c7998f01
- W3C propagator in init_telemetry; calls to the registry carry
  traceparent, so the registry's spans join Prüfwerk's trace.
- The agent's HTTP server opens one INFO span per request, named after
  the route template and continuing an incoming traceparent (portal,
  registry). The default TraceLayer span was DEBUG (dropped by the INFO
  filter) and recorded the full URI. No path, query or client address.
- opentelemetry-appender-tracing experimental_use_tracing_span_context:
  OTLP log records carry trace_id/span_id, so SigNoz links logs and traces.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KYcAAeTw22GE9QPzDM8yc4
sharang force-pushed feat/otel-propagation from 8249404a85 to 85c7998f01 2026-10-29 09:58:10 +00:00 Compare
sharang merged commit fad23c20a9 into main 2026-10-29 10:13:34 +00:00
Sign in to join this conversation.