Skip to content

feat(sveltekit): Detect SvelteKit 3 native tracing from the Vite plugin - #21580

Merged
chargome merged 2 commits into
developfrom
cg/kit-3-vite-detection
Jul 16, 2026
Merged

feat(sveltekit): Detect SvelteKit 3 native tracing from the Vite plugin#21580
chargome merged 2 commits into
developfrom
cg/kit-3-vite-detection

Conversation

@chargome

@chargomechargome commented Jun 16, 2026

Copy link
Copy Markdown
Member

As of SvelteKit 3, native server-side tracing is no longer configured in svelte.config.js — it's passed to the sveltekit() Vite plugin instead. Our auto-instrumentation plugin derived onlyInstrumentClient from svelte.config.js, so under Kit 3 it could no longer tell that native tracing was enabled and kept injecting its own server-side load instrumentation. The result was duplicate spans (the SDK's function.sveltekit.server.load stacked on top of Kit's native sveltekit.load).

This PR now reads the resolved SvelteKit config that the sveltekit() plugin exposes via its plugin api.options and treats it as the source of truth for Kit 3.
When native server tracing is enabled there, we skip our own server-load instrumentation. On older SvelteKit versions that don't expose the config this way, detection falls back to the existing svelte.config.js-derived value — so nothing changes for Kit 2.

ref #21502

@chargomechargome self-assigned this Jun 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you apply the label PR: no-auto-close I will leave it alone ... forever!

@chargome
chargomeforce-pushed the feat/sveltekit-3-e2e-app branch from d0c2dba to 6f71d37CompareJuly 15, 2026 10:38
@chargome
chargomeforce-pushed the cg/kit-3-vite-detection branch from 06ac632 to 30c37eeCompareJuly 15, 2026 10:38
@chargome

Copy link
Copy Markdown
MemberAuthor

bugbot run

@cursorcursorBot left a comment

Copy link
Copy Markdown

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.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 30c37ee. Configure here.

@chargome
chargome marked this pull request as ready for review July 15, 2026 12:36
@chargome
chargome requested a review from a team as a code ownerJuly 15, 2026 12:36
@chargome
chargome requested review from mydea, nicohrubec and s1gr1d and removed request for a teamJuly 15, 2026 12:36
Base automatically changed from feat/sveltekit-3-e2e-app to developJuly 15, 2026 14:39
chargomeand others added 2 commits July 15, 2026 16:42
…nfig
SvelteKit 3.0.0-next.8 promoted the native server-tracing config out of
`experimental` (`kit.experimental.tracing.server` -> `kit.tracing.server`).
Read both locations when detecting native tracing so the SDK works across the
supported peer range (SvelteKit 2.31+ and early Kit 3 prereleases keep it under
`experimental`). Applies to detection from both the Vite plugin `api.options`
and `svelte.config.js`, and covers both shapes in the unit tests.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@chargome
chargomeforce-pushed the cg/kit-3-vite-detection branch from 30c37ee to a2b8566CompareJuly 15, 2026 14:57
@chargome
chargome merged commit 595e940 into developJul 16, 2026
52 checks passed
@chargome
chargome deleted the cg/kit-3-vite-detection branch July 16, 2026 08:38
Sign up for freeto 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.

3 participants

@chargome@nicohrubec@s1gr1d