Skip to content

feat(frontend): propagate trace context via OpenAPI interceptor#16

Open
ncolesummers wants to merge 6 commits into
masterfrom
codex/issue-6-trace-context-propagation
Open

feat(frontend): propagate trace context via OpenAPI interceptor#16
ncolesummers wants to merge 6 commits into
masterfrom
codex/issue-6-trace-context-propagation

Conversation

@ncolesummers
Copy link
Copy Markdown
Owner

Summary

  • add frontend/src/telemetry-interceptor.ts to inject W3C trace context (traceparent/tracestate) into every generated OpenAPI client request via OpenAPI.interceptors.request
  • register the interceptor at startup in frontend/src/main.tsx immediately after telemetry initialization
  • update observability docs to explain the explicit educational propagation pattern and troubleshooting step for interceptor registration

Why

Issue #6 requires frontend-to-backend distributed trace continuity without modifying generated client files under frontend/src/client/.

Validation

  • bun run --cwd frontend build passes
  • Full stack runtime verification after container restart:
    • captured browser request header: traceparent: 00-9d901eba971201dd7b4e5ed1a8f87529-22ed13efe1b40b13-01
    • Jaeger trace 9d901eba971201dd7b4e5ed1a8f87529 includes both services (react-frontend, fastapi-backend)
    • backend server span GET /api/v1/users/me has parent span ID 22ed13efe1b40b13 (matching the frontend client span ID from traceparent)

Closes #6

Copilot AI review requested due to automatic review settings February 23, 2026 06:02
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an explicit OpenTelemetry trace-context propagation hook to the frontend’s generated OpenAPI client so backend requests carry W3C traceparent/tracestate without modifying generated client sources.

Changes:

  • Introduce frontend/src/telemetry-interceptor.ts to inject W3C trace context into OpenAPI client requests via OpenAPI.interceptors.request.
  • Register the interceptor during app startup in frontend/src/main.tsx after telemetry initialization.
  • Update docs/observability.md to describe the propagation approach and add a troubleshooting check.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
frontend/src/telemetry-interceptor.ts New interceptor + one-time registration helper to inject traceparent/tracestate into request headers.
frontend/src/main.tsx Calls registerTraceContextInterceptor() after initTelemetry().
docs/observability.md Updates trace propagation explanation and adds a troubleshooting step for interceptor registration.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread docs/observability.md Outdated
Comment thread frontend/src/telemetry-interceptor.ts
Comment thread frontend/src/telemetry-interceptor.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Frontend-to-backend distributed trace context propagation

3 participants