Skip to content

Commit 7e9f360

Browse files
nicohrubecclaude
andcommitted
fix: Update fastify span prefix stripping and E2E test expectations
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 3162e6e commit 7e9f360

4 files changed

Lines changed: 10 additions & 7 deletions

File tree

dev-packages/e2e-tests/test-applications/nestjs-fastify/tests/transactions.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ test('Sends an API route transaction', async ({ baseURL }) => {
6262
data: {
6363
'sentry.origin': 'auto.http.otel.fastify',
6464
'sentry.op': 'hook.fastify',
65-
'hook.name': 'fastify -> @fastify/otel -> @fastify/middie - onRequest',
65+
'hook.name': 'fastify -> @sentry/instrumentation-fastify -> @fastify/middie - onRequest',
6666
'fastify.type': 'hook',
6767
'hook.callback.name': 'runMiddie',
6868
},
@@ -80,7 +80,7 @@ test('Sends an API route transaction', async ({ baseURL }) => {
8080
data: {
8181
'sentry.origin': 'auto.http.otel.fastify',
8282
'sentry.op': 'request_handler.fastify',
83-
'hook.name': 'fastify -> @fastify/otel -> @fastify/middie - route-handler',
83+
'hook.name': 'fastify -> @sentry/instrumentation-fastify -> @fastify/middie - route-handler',
8484
'fastify.type': 'request-handler',
8585
'http.route': '/test-transaction',
8686
'hook.callback.name': 'anonymous',

dev-packages/e2e-tests/test-applications/node-fastify-4/tests/transactions.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ test('Sends an API route transaction', async ({ baseURL }) => {
6969
data: {
7070
'fastify.type': 'hook',
7171
'hook.callback.name': 'anonymous',
72-
'hook.name': 'fastify -> @fastify/otel - onRequest',
72+
'hook.name': 'fastify -> @sentry/instrumentation-fastify - onRequest',
7373
'sentry.op': 'hook.fastify',
7474
'sentry.origin': 'auto.http.otel.fastify',
7575
},
76-
description: '@fastify/otel - onRequest',
76+
description: '@sentry/instrumentation-fastify - onRequest',
7777
op: 'hook.fastify',
7878
parent_span_id: expect.stringMatching(/[a-f0-9]{16}/),
7979
span_id: expect.stringMatching(/[a-f0-9]{16}/),

dev-packages/e2e-tests/test-applications/node-fastify-5/tests/transactions.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ test('Sends an API route transaction', async ({ baseURL }) => {
6969
data: {
7070
'fastify.type': 'hook',
7171
'hook.callback.name': 'anonymous',
72-
'hook.name': 'fastify -> @fastify/otel - onRequest',
72+
'hook.name': 'fastify -> @sentry/instrumentation-fastify - onRequest',
7373
'sentry.op': 'hook.fastify',
7474
'sentry.origin': 'auto.http.otel.fastify',
7575
},
76-
description: '@fastify/otel - onRequest',
76+
description: '@sentry/instrumentation-fastify - onRequest',
7777
op: 'hook.fastify',
7878
parent_span_id: expect.stringMatching(/[a-f0-9]{16}/),
7979
span_id: expect.stringMatching(/[a-f0-9]{16}/),

packages/node/src/integrations/tracing/fastify/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,10 @@ function addFastifySpanAttributes(span: Span): void {
294294
// Try removing `fastify -> ` and `@fastify/otel -> ` prefixes
295295
// This is a bit of a hack, and not always working for all spans
296296
// But it's the best we can do without a proper API
297-
const updatedName = attrName.replace(/^fastify -> /, '').replace(/^@fastify\/otel -> /, '');
297+
const updatedName = attrName
298+
.replace(/^fastify -> /, '')
299+
.replace(/^@fastify\/otel -> /, '')
300+
.replace(/^@sentry\/instrumentation-fastify -> /, '');
298301

299302
span.updateName(updatedName);
300303
}

0 commit comments

Comments
 (0)