feat(remix): Server Timing Headers Trace Propagation PoC#18653
feat(remix): Server Timing Headers Trace Propagation PoC#18653onurtemizkan wants to merge 1 commit intodevelopfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR implements a proof-of-concept for propagating Sentry trace context from server to client using the Server-Timing HTTP header and the browser Performance API. This provides an alternative to meta tag-based trace propagation, particularly useful for streaming SSR responses and edge runtimes.
Key changes:
- Added utilities for generating and injecting Server-Timing headers with Sentry trace data
- Implemented client-side parsing of Server-Timing headers via the Performance API
- Updated server instrumentation to capture and propagate trace context via Server-Timing headers
- Added comprehensive E2E test coverage for both Node.js and Cloudflare environments
Reviewed changes
Copilot reviewed 25 out of 27 changed files in this pull request and generated 16 comments.
Show a summary per file
| File | Description |
|---|---|
packages/remix/src/server/serverTimingTracePropagation.ts |
New utility module for generating Server-Timing headers with trace context |
packages/remix/src/client/serverTimingTracePropagation.ts |
New client-side utilities for parsing trace data from Server-Timing headers |
packages/remix/src/server/instrumentServer.ts |
Updated server instrumentation to inject Server-Timing headers and refactored trace propagation logic |
packages/remix/src/client/performance.tsx |
Updated pageload span initialization to use Server-Timing trace propagation |
packages/remix/src/server/index.ts |
Exported new Server-Timing utilities for public API |
packages/remix/src/client/index.ts |
Exported new client-side Server-Timing utilities |
packages/remix/src/cloudflare/index.ts |
Exported Server-Timing utilities for Cloudflare runtime |
dev-packages/e2e-tests/test-applications/remix-server-timing/* |
New E2E test application validating Server-Timing trace propagation |
dev-packages/e2e-tests/test-applications/remix-hydrogen/* |
Updated Hydrogen test app to demonstrate Cloudflare support |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...2e-tests/test-applications/remix-server-timing/tests/server-timing-trace-propagation.test.ts
Outdated
Show resolved
Hide resolved
1f07bc8 to
67ec468
Compare
3e06c9b to
48e03dd
Compare
d882ca3 to
982c420
Compare
node-overhead report 🧳Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.
|
1b1481d to
8a43e90
Compare
...2e-tests/test-applications/remix-server-timing/tests/server-timing-trace-propagation.test.ts
Outdated
Show resolved
Hide resolved
fa61b3c to
7518ec6
Compare
Lms24
left a comment
There was a problem hiding this comment.
@onurtemizkan sorry for the delay on this! I merged in #18673 to get support for server-timing trace continuation on the client side in the general browser SDK. Could you update the PR to use this instead of the remix-specific approach? The server side looks fine to me, though I'll give this a more proper look once the PR is updated.
7518ec6 to
1f7c85c
Compare
Codecov Results 📊Generated by Codecov Action |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
dev-packages/e2e-tests/test-applications/remix-hydrogen/app/entry.server.tsx
Outdated
Show resolved
Hide resolved
25fa718 to
1033440
Compare
size-limit report 📦
|
Adds automatic trace propagation from server to client via the
Server-TimingHTTP header for Remix applications.This provides an alternative to meta tag injection for linking server and client traces. The server automatically injects
sentry-traceandbaggageinto theServer-Timingresponse header, and the client SDK reads it via the Performance API during pageload.Server-side:
generateSentryServerTimingHeader()- generates the header valueaddSentryServerTimingHeader(response)- adds header to a Responseentry.server.tsxusingaddSentryServerTimingHeaderClient-side:
Server-Timingfrom navigation timing entriesWorks on both Node.js and Cloudflare Workers environments.
Closes #18696 (added automatically)