Skip to content

Commit a6558a0

Browse files
fix(v10/sveltekit): add op and origin to Kit's sveltekit.endpoint span (#25429)
Backport of: #25376 ## Differences to the original PR - `packages/sveltekit/src/server-common/integrations/svelteKitSpans.ts`: v10's span mapping returns `{ op, origin }` instead of only an origin, so the endpoint case returns `{ op: 'function.sveltekit.endpoint', origin: 'auto.function.sveltekit.endpoint' }`. Unit and e2e test expectations were adjusted to match. This branch was prepared by the v10 backport automation, which was blocked at PR creation; it's opened manually now. <!-- junior-request-attribution:start --> via **Jan Peer Stöcklmair**. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:local%3Aweb%3A83fc948beed4fb12a54d41cb --> -- [View Junior Session in Sentry](https://sentry.sentry.io/explore/conversations/local%3Aweb%3A83fc948beed4fb12a54d41cb/?project=4510944073809921) <!-- junior-session-footer:end --> --------- Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: Jan Peer Stöcklmair <jan.peer@sentry.io>
1 parent 61db948 commit a6558a0

3 files changed

Lines changed: 20 additions & 1 deletion

File tree

‎dev-packages/e2e-tests/test-applications/sveltekit-3/tests/tracing.server.test.ts‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ test('server pageload request span has nested request span for sub request', asy
3131
},
3232
});
3333

34-
expect(spans).toHaveLength(6);
34+
expect(spans).toHaveLength(7);
3535

3636
expect(spans).toEqual(
3737
expect.arrayContaining([
@@ -120,6 +120,21 @@ test('server pageload request span has nested request span for sub request', asy
120120
origin: 'auto.http.sveltekit',
121121
status: 'ok',
122122
}),
123+
124+
// sub request `+server` handler span (emitted by Kit since 3.1.0).
125+
// Its op is inferred as `http` from `http.method` before the integration runs, and v10 keeps existing ops.
126+
expect.objectContaining({
127+
data: expect.objectContaining({
128+
'http.route': '/api/users',
129+
'http.method': 'GET',
130+
'sentry.op': 'http',
131+
'sentry.origin': 'auto.function.sveltekit.endpoint',
132+
}),
133+
description: 'sveltekit.endpoint',
134+
op: 'http',
135+
origin: 'auto.function.sveltekit.endpoint',
136+
status: 'ok',
137+
}),
123138
]),
124139
);
125140

‎packages/sveltekit/src/server-common/integrations/svelteKitSpans.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ function _getKitSpanEnhancement(spanName: string | undefined): {
8282
return { op: 'function.sveltekit.load', origin: 'auto.function.sveltekit.load' };
8383
case 'sveltekit.form_action':
8484
return { op: 'function.sveltekit.form_action', origin: 'auto.function.sveltekit.action' };
85+
case 'sveltekit.endpoint':
86+
return { op: 'function.sveltekit.endpoint', origin: 'auto.function.sveltekit.endpoint' };
8587
case 'sveltekit.remote.call':
8688
return { op: 'function.sveltekit.remote', origin: 'auto.rpc.sveltekit.remote' };
8789
case 'sveltekit.handle.root':

‎packages/sveltekit/test/server-common/integrations/svelteKitSpans.test.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ describe('svelteKitSpansIntegration', () => {
5656
['sveltekit.resolve', 'function.sveltekit.resolve', 'auto.http.sveltekit'],
5757
['sveltekit.load', 'function.sveltekit.load', 'auto.function.sveltekit.load'],
5858
['sveltekit.form_action', 'function.sveltekit.form_action', 'auto.function.sveltekit.action'],
59+
['sveltekit.endpoint', 'function.sveltekit.endpoint', 'auto.function.sveltekit.endpoint'],
5960
['sveltekit.remote.call', 'function.sveltekit.remote', 'auto.rpc.sveltekit.remote'],
6061
['sveltekit.handle.sequenced.0', 'function.sveltekit.handle', 'auto.function.sveltekit.handle'],
6162
['sveltekit.handle.sequenced.myHandler', 'function.sveltekit.handle', 'auto.function.sveltekit.handle'],
@@ -194,6 +195,7 @@ describe('svelteKitSpansIntegration', () => {
194195
['sveltekit.resolve', 'function.sveltekit.resolve', 'auto.http.sveltekit'],
195196
['sveltekit.load', 'function.sveltekit.load', 'auto.function.sveltekit.load'],
196197
['sveltekit.form_action', 'function.sveltekit.form_action', 'auto.function.sveltekit.action'],
198+
['sveltekit.endpoint', 'function.sveltekit.endpoint', 'auto.function.sveltekit.endpoint'],
197199
['sveltekit.remote.call', 'function.sveltekit.remote', 'auto.rpc.sveltekit.remote'],
198200
['sveltekit.handle.sequenced.0', 'function.sveltekit.handle', 'auto.function.sveltekit.handle'],
199201
['sveltekit.handle.sequenced.myHandler', 'function.sveltekit.handle', 'auto.function.sveltekit.handle'],

0 commit comments

Comments
 (0)