Skip to content

feat(tanstackstart-react): Add distributed tracing#21144

Merged
nicohrubec merged 8 commits into
developfrom
feat/tanstack-start-distributed-tracing
May 26, 2026
Merged

feat(tanstackstart-react): Add distributed tracing#21144
nicohrubec merged 8 commits into
developfrom
feat/tanstack-start-distributed-tracing

Conversation

@nicohrubec
Copy link
Copy Markdown
Member

@nicohrubec nicohrubec commented May 23, 2026

Adds distributed tracing to the TanStack Start SDK by injecting sentry-trace and baggage meta tags into HTML responses in wrapFetchWithSentry. This connects server and client traces automatically without requiring any additional user setup.

The added functions that do the meta tag injections are essentially copies from the astro package (addMetaTagToHead, injectMetaTagsInResponse).

Added a trace-propagation test to the main TSS e2e test application and adjusted the existing cloudflare TSS e2e test application to the new pattern (i.e. remove the manual injection of meta tags).

Example trace with my local sample app:
Screenshot 2026-05-23 at 16 40 05

Closes #18286

Comment thread packages/tanstackstart-react/src/server/wrapFetchWithSentry.ts Outdated
Comment thread packages/tanstackstart-react/src/server/wrapFetchWithSentry.ts
Comment thread packages/tanstackstart-react/src/server/wrapFetchWithSentry.ts
Comment thread packages/tanstackstart-react/src/server/wrapFetchWithSentry.ts
@nicohrubec nicohrubec changed the title feat(tanstackstart-react): Add distributed tracing via meta tag injection feat(tanstackstart-react): Add distributed tracing May 23, 2026
@nicohrubec nicohrubec marked this pull request as ready for review May 26, 2026 07:23
@nicohrubec nicohrubec requested a review from a team as a code owner May 26, 2026 07:23
@nicohrubec nicohrubec requested review from JPeer264, chargome, mydea and s1gr1d and removed request for a team and mydea May 26, 2026 07:23
}
} catch (e) {
captureException(e, {
mechanism: { type: 'auto.http.tanstackstart', handled: false },
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe you could also test that those exceptions are correctly captured.

Comment thread packages/tanstackstart-react/src/server/wrapFetchWithSentry.ts
nicohrubec and others added 8 commits May 26, 2026 16:21
…tion

Adds distributed tracing to the TanStack Start SDK by injecting `sentry-trace` and `baggage` meta tags into HTML responses in `wrapFetchWithSentry`, connecting server and client traces automatically.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Restore bodyIterator generator for stream error reporting, captureException
in outer catch, TS narrowing reassignment, and comments.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Closing an already-errored ReadableStream controller throws TypeError.
Track error state and skip close() in that case.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@nicohrubec nicohrubec force-pushed the feat/tanstack-start-distributed-tracing branch from 796ae00 to 53a6c2b Compare May 26, 2026 14:23
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 53a6c2b. Configure here.

Comment thread packages/tanstackstart-react/src/server/wrapFetchWithSentry.ts
Comment thread packages/tanstackstart-react/src/server/wrapFetchWithSentry.ts
@nicohrubec nicohrubec merged commit 0a8adc4 into develop May 26, 2026
46 checks passed
@nicohrubec nicohrubec deleted the feat/tanstack-start-distributed-tracing branch May 26, 2026 14:34
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.

Support distributed tracing

2 participants