diff --git a/dev-packages/deno-integration-tests/suites/orchestrion-express/test.ts b/dev-packages/deno-integration-tests/suites/orchestrion-express/test.ts index 8e4072305e2f..7fb2aafd0bf6 100644 --- a/dev-packages/deno-integration-tests/suites/orchestrion-express/test.ts +++ b/dev-packages/deno-integration-tests/suites/orchestrion-express/test.ts @@ -46,8 +46,8 @@ Deno.test('express instrumentation: orchestrion:express:handle channel produces "'parent' transaction", ); - const expressSpan = parent.spans?.find(s => s.op === 'middleware.express'); - assertExists(expressSpan, `expected a middleware.express span, got ops: ${parent.spans?.map(s => s.op).join(', ')}`); + const expressSpan = parent.spans?.find(s => s.op === 'middleware'); + assertExists(expressSpan, `expected an express middleware span, got ops: ${parent.spans?.map(s => s.op).join(', ')}`); assertEquals(expressSpan!.description, 'myMiddleware'); assertEquals(expressSpan!.data?.['express.name'], 'myMiddleware'); assertEquals(expressSpan!.data?.['express.type'], 'middleware'); diff --git a/dev-packages/deno-integration-tests/suites/orchestrion-koa/test.ts b/dev-packages/deno-integration-tests/suites/orchestrion-koa/test.ts index ae52b8997897..e084e4cd136a 100644 --- a/dev-packages/deno-integration-tests/suites/orchestrion-koa/test.ts +++ b/dev-packages/deno-integration-tests/suites/orchestrion-koa/test.ts @@ -44,8 +44,8 @@ Deno.test('koa instrumentation: orchestrion:koa:use channel wraps middleware int "'parent' transaction", ); - const koaSpan = parent.spans?.find(s => s.op === 'middleware.koa'); - assertExists(koaSpan, `expected a middleware.koa child span, got ops: ${parent.spans?.map(s => s.op).join(', ')}`); + const koaSpan = parent.spans?.find(s => s.op === 'middleware'); + assertExists(koaSpan, `expected a koa middleware child span, got ops: ${parent.spans?.map(s => s.op).join(', ')}`); assertEquals(koaSpan!.description, 'myMiddleware'); assertEquals(koaSpan!.data?.['sentry.origin'], 'auto.http.koa'); }); diff --git a/dev-packages/e2e-tests/test-applications/elysia-bun/tests/transactions.test.ts b/dev-packages/e2e-tests/test-applications/elysia-bun/tests/transactions.test.ts index b0b21fb9227f..0c09def64b7f 100644 --- a/dev-packages/e2e-tests/test-applications/elysia-bun/tests/transactions.test.ts +++ b/dev-packages/e2e-tests/test-applications/elysia-bun/tests/transactions.test.ts @@ -132,7 +132,7 @@ test('Creates lifecycle spans for Elysia hooks', async ({ baseURL, request }) => expect(spans).toContainEqual( expect.objectContaining({ description: 'Handle', - op: 'request_handler.elysia', + op: 'function', origin: 'auto.http.elysia', }), ); @@ -181,7 +181,7 @@ test('Creates lifecycle spans for route-specific middleware', async ({ baseURL, expect(spans).toContainEqual( expect.objectContaining({ description: 'BeforeHandle', - op: 'middleware.elysia', + op: 'middleware', origin: 'auto.http.elysia', }), ); diff --git a/dev-packages/e2e-tests/test-applications/elysia-node/tests/transactions.test.ts b/dev-packages/e2e-tests/test-applications/elysia-node/tests/transactions.test.ts index 941341c3422a..75ba4d08994a 100644 --- a/dev-packages/e2e-tests/test-applications/elysia-node/tests/transactions.test.ts +++ b/dev-packages/e2e-tests/test-applications/elysia-node/tests/transactions.test.ts @@ -132,7 +132,7 @@ test('Creates lifecycle spans for Elysia hooks', async ({ baseURL, request }) => expect(spans).toContainEqual( expect.objectContaining({ description: 'Handle', - op: 'request_handler.elysia', + op: 'function', origin: 'auto.http.elysia', }), ); @@ -181,7 +181,7 @@ test('Creates lifecycle spans for route-specific middleware', async ({ baseURL, expect(spans).toContainEqual( expect.objectContaining({ description: 'BeforeHandle', - op: 'middleware.elysia', + op: 'middleware', origin: 'auto.http.elysia', }), ); diff --git a/dev-packages/e2e-tests/test-applications/hono-4/tests/basepath-and-late-routes.test.ts b/dev-packages/e2e-tests/test-applications/hono-4/tests/basepath-and-late-routes.test.ts index 03a97816c9c5..c22897c4a349 100644 --- a/dev-packages/e2e-tests/test-applications/hono-4/tests/basepath-and-late-routes.test.ts +++ b/dev-packages/e2e-tests/test-applications/hono-4/tests/basepath-and-late-routes.test.ts @@ -55,7 +55,7 @@ test.skip('.basePath() middleware instrumentation', () => { const spans = transaction.spans || []; const middlewareSpan = spans.find( (span: { description?: string; op?: string }) => - span.op === 'middleware.hono' && span.description === 'basepathMiddleware', + span.op === 'middleware' && span.description === 'basepathMiddleware', ); expect(middlewareSpan).toBeDefined(); diff --git a/dev-packages/e2e-tests/test-applications/hono-4/tests/errors.test.ts b/dev-packages/e2e-tests/test-applications/hono-4/tests/errors.test.ts index fbe758c708a9..a157de5bd896 100644 --- a/dev-packages/e2e-tests/test-applications/hono-4/tests/errors.test.ts +++ b/dev-packages/e2e-tests/test-applications/hono-4/tests/errors.test.ts @@ -151,7 +151,7 @@ test.describe('middleware errors', () => { expect(errorEvent.transaction).toBe('GET /test-errors/middleware-http-exception'); const transaction = await transactionPromise; - const middlewareSpan = (transaction.spans || []).find(s => s.op === 'middleware.hono'); + const middlewareSpan = (transaction.spans || []).find(s => s.op === 'middleware'); expect(middlewareSpan?.status).toBe('internal_error'); }); @@ -187,7 +187,7 @@ test.describe('middleware errors', () => { if (RUNTIME === 'cloudflare') { expect(transaction.transaction).toBe('GET /test-errors/middleware-http-exception-4xx'); - const middlewareSpan = (transaction.spans || []).find(s => s.op === 'middleware.hono'); + const middlewareSpan = (transaction.spans || []).find(s => s.op === 'middleware'); expect(middlewareSpan?.status).not.toBe('internal_error'); } diff --git a/dev-packages/e2e-tests/test-applications/hono-4/tests/middleware.test.ts b/dev-packages/e2e-tests/test-applications/hono-4/tests/middleware.test.ts index 0ef039000c9a..a68d347a597a 100644 --- a/dev-packages/e2e-tests/test-applications/hono-4/tests/middleware.test.ts +++ b/dev-packages/e2e-tests/test-applications/hono-4/tests/middleware.test.ts @@ -30,14 +30,13 @@ for (const { name, prefix } of SCENARIOS) { const spans = transaction.spans || []; const middlewareSpan = spans.find( - (span: { description?: string; op?: string }) => - span.op === 'middleware.hono' && span.description === 'middlewareA', + (span: { description?: string; op?: string }) => span.op === 'middleware' && span.description === 'middlewareA', ); expect(middlewareSpan).toEqual( expect.objectContaining({ description: 'middlewareA', - op: 'middleware.hono', + op: 'middleware', origin: 'auto.middleware.hono', }), ); @@ -62,8 +61,7 @@ for (const { name, prefix } of SCENARIOS) { const spans = transaction.spans || []; const anonymousSpan = spans.find( - (span: { description?: string; op?: string }) => - span.op === 'middleware.hono' && span.description === '', + (span: { description?: string; op?: string }) => span.op === 'middleware' && span.description === '', ); expect(anonymousSpan).toBeDefined(); expect(anonymousSpan?.origin).toBe('auto.middleware.hono'); @@ -133,9 +131,7 @@ for (const { name, prefix } of SCENARIOS) { const spans = transaction.spans || []; - const failingSpan = spans.find( - (span: SpanJSON) => span.op === 'middleware.hono' && span.status === 'internal_error', - ); + const failingSpan = spans.find((span: SpanJSON) => span.op === 'middleware' && span.status === 'internal_error'); expect(failingSpan).toBeDefined(); expect(failingSpan?.status).toBe('internal_error'); @@ -154,8 +150,7 @@ for (const { name, prefix } of SCENARIOS) { const spans = transaction.spans || []; const middlewareSpan = spans.find( - (span: { description?: string; op?: string }) => - span.op === 'middleware.hono' && span.description === 'middlewareA', + (span: { description?: string; op?: string }) => span.op === 'middleware' && span.description === 'middlewareA', ); expect(middlewareSpan).toBeDefined(); }); @@ -241,7 +236,7 @@ test.describe('inline middleware spans (sub-app)', () => { const inlineSpan = (transaction.spans || []).find(s => s.description === expectedDescription); expect(inlineSpan).toBeDefined(); - expect(inlineSpan?.op).toBe('middleware.hono'); + expect(inlineSpan?.op).toBe('middleware'); expect(inlineSpan?.origin).toBe('auto.middleware.hono'); expect(inlineSpan?.status).not.toBe('internal_error'); }); @@ -276,11 +271,11 @@ test.describe('inline middleware spans (main app)', () => { const inlineSpan = spans.find(s => s.description === expectedMiddlewareName); expect(inlineSpan).toBeDefined(); - expect(inlineSpan?.op).toBe('middleware.hono'); + expect(inlineSpan?.op).toBe('middleware'); expect(inlineSpan?.origin).toBe('auto.middleware.hono'); expect(inlineSpan?.status).not.toBe('internal_error'); - const middlewareSpans = spans.filter(s => s.op === 'middleware.hono'); + const middlewareSpans = spans.filter(s => s.op === 'middleware'); expect(middlewareSpans).toHaveLength(1); }); }); @@ -299,18 +294,18 @@ test.describe('inline middleware spans (main app)', () => { expect(transaction.transaction).toBe(`GET ${fullPath}`); const spans = transaction.spans || []; - const middlewareSpans = spans.filter(s => s.op === 'middleware.hono'); + const middlewareSpans = spans.filter(s => s.op === 'middleware'); expect(middlewareSpans).toHaveLength(2); const [spanA, spanB] = middlewareSpans.sort((a, b) => (a.description ?? '').localeCompare(b.description ?? '')); expect(spanA?.description).toBe('combinedInlineMw'); - expect(spanA?.op).toBe('middleware.hono'); + expect(spanA?.op).toBe('middleware'); expect(spanA?.origin).toBe('auto.middleware.hono'); expect(spanA?.status).not.toBe('internal_error'); expect(spanB?.description).toBe('middlewareA'); - expect(spanB?.op).toBe('middleware.hono'); + expect(spanB?.op).toBe('middleware'); expect(spanB?.origin).toBe('auto.middleware.hono'); expect(spanB?.status).not.toBe('internal_error'); }); diff --git a/dev-packages/e2e-tests/test-applications/hono-4/tests/multi-fetch.test.ts b/dev-packages/e2e-tests/test-applications/hono-4/tests/multi-fetch.test.ts index 3fde49185424..3904a02ebc30 100644 --- a/dev-packages/e2e-tests/test-applications/hono-4/tests/multi-fetch.test.ts +++ b/dev-packages/e2e-tests/test-applications/hono-4/tests/multi-fetch.test.ts @@ -48,13 +48,13 @@ test.describe('multi-fetch: internal .request() calls between sub-apps', () => { const middlewareSpan = spans.find( (span: { description?: string; op?: string }) => - span.op === 'middleware.hono' && span.description === 'storefrontAuth', + span.op === 'middleware' && span.description === 'storefrontAuth', ); expect(middlewareSpan).toEqual( expect.objectContaining({ description: 'storefrontAuth', - op: 'middleware.hono', + op: 'middleware', origin: 'auto.middleware.hono', }), ); @@ -185,7 +185,7 @@ test.describe('multi-fetch: internal .request() calls between sub-apps', () => { }); test.describe('trace propagation through internal .request() calls', () => { - test('single internal fetch produces a hono.request child span', async ({ baseURL }) => { + test('single internal fetch produces an internal-request child span', async ({ baseURL }) => { const transactionPromise = waitForTransaction(APP_NAME, event => { return ( event.contexts?.trace?.op === 'http.server' && event.transaction === `GET ${STOREFRONT}/product/:productId` @@ -198,12 +198,14 @@ test.describe('multi-fetch: internal .request() calls between sub-apps', () => { const traceId = transaction.contexts?.trace?.trace_id; const spans = transaction.spans || []; - const internalRequestSpans = spans.filter((s: { op?: string }) => s.op === 'hono.request'); + const internalRequestSpans = spans.filter( + (s: { origin?: string }) => s.origin === 'auto.http.hono.internal_request', + ); expect(internalRequestSpans).toHaveLength(1); expect(internalRequestSpans[0]).toEqual( expect.objectContaining({ - op: 'hono.request', + op: 'http.server', origin: 'auto.http.hono.internal_request', trace_id: traceId, }), @@ -211,7 +213,7 @@ test.describe('multi-fetch: internal .request() calls between sub-apps', () => { expect(internalRequestSpans[0]?.description).toContain('GET /item/self-watering-plant'); }); - test('parallel internal fetches produce two sibling hono.request spans', async ({ baseURL }) => { + test('parallel internal fetches produce two sibling internal-request spans', async ({ baseURL }) => { const transactionPromise = waitForTransaction(APP_NAME, event => { return ( event.contexts?.trace?.op === 'http.server' && @@ -225,7 +227,9 @@ test.describe('multi-fetch: internal .request() calls between sub-apps', () => { const traceId = transaction.contexts?.trace?.trace_id; const spans = transaction.spans || []; - const internalRequestSpans = spans.filter((s: { op?: string }) => s.op === 'hono.request'); + const internalRequestSpans = spans.filter( + (s: { origin?: string }) => s.origin === 'auto.http.hono.internal_request', + ); expect(internalRequestSpans).toHaveLength(2); @@ -238,7 +242,7 @@ test.describe('multi-fetch: internal .request() calls between sub-apps', () => { expect(internalRequestSpans[1]?.origin).toBe('auto.http.hono.internal_request'); }); - test('sequential chained fetches produce two ordered hono.request spans', async ({ baseURL }) => { + test('sequential chained fetches produce two ordered internal-request spans', async ({ baseURL }) => { const transactionPromise = waitForTransaction(APP_NAME, event => { return ( event.contexts?.trace?.op === 'http.server' && @@ -253,7 +257,7 @@ test.describe('multi-fetch: internal .request() calls between sub-apps', () => { const spans = transaction.spans || []; const internalRequestSpans = spans - .filter((s: { op?: string }) => s.op === 'hono.request') + .filter((s: { origin?: string }) => s.origin === 'auto.http.hono.internal_request') .sort( (a: { start_timestamp?: number }, b: { start_timestamp?: number }) => (a.start_timestamp ?? 0) - (b.start_timestamp ?? 0), @@ -270,7 +274,7 @@ test.describe('multi-fetch: internal .request() calls between sub-apps', () => { expect(internalRequestSpans[1]?.trace_id).toBe(traceId); }); - test('hono.request span has no error status for internal 4xx HTTPException', async ({ baseURL }) => { + test('internal-request span has no error status for internal 4xx HTTPException', async ({ baseURL }) => { const transactionPromise = waitForTransaction(APP_NAME, event => { return ( event.contexts?.trace?.op === 'http.server' && @@ -283,7 +287,9 @@ test.describe('multi-fetch: internal .request() calls between sub-apps', () => { const transaction = await transactionPromise; const spans = transaction.spans || []; - const internalRequestSpans = spans.filter((s: { op?: string }) => s.op === 'hono.request'); + const internalRequestSpans = spans.filter( + (s: { origin?: string }) => s.origin === 'auto.http.hono.internal_request', + ); expect(internalRequestSpans).toHaveLength(1); expect(internalRequestSpans[0]?.status).not.toBe('internal_error'); diff --git a/dev-packages/e2e-tests/test-applications/hono-4/tests/route-patterns.test.ts b/dev-packages/e2e-tests/test-applications/hono-4/tests/route-patterns.test.ts index 6cd48dfac68c..6bb9b81b4d74 100644 --- a/dev-packages/e2e-tests/test-applications/hono-4/tests/route-patterns.test.ts +++ b/dev-packages/e2e-tests/test-applications/hono-4/tests/route-patterns.test.ts @@ -26,7 +26,7 @@ test.describe('HTTP methods', () => { expect(transaction.contexts?.trace?.data?.['sentry.source']).toBe('route'); const spans = transaction.spans || []; - const middlewareSpans = spans.filter(s => s.op === 'middleware.hono'); + const middlewareSpans = spans.filter(s => s.op === 'middleware'); expect(middlewareSpans).toEqual([]); }); }); @@ -48,7 +48,7 @@ test.describe('route registration styles', () => { expect(transaction.contexts?.trace?.data?.['sentry.source']).toBe('route'); const spans = transaction.spans || []; - const middlewareSpans = spans.filter(s => s.op === 'middleware.hono'); + const middlewareSpans = spans.filter(s => s.op === 'middleware'); expect(middlewareSpans).toEqual([]); }); }); @@ -70,7 +70,7 @@ test.describe('route registration styles', () => { expect(transaction.contexts?.trace?.data?.['sentry.source']).toBe('route'); const spans = transaction.spans || []; - const middlewareSpans = spans.filter(s => s.op === 'middleware.hono'); + const middlewareSpans = spans.filter(s => s.op === 'middleware'); expect(middlewareSpans).toEqual([]); }); }); @@ -142,6 +142,6 @@ test('async handler sends transaction', async ({ baseURL }) => { expect(transaction.contexts?.trace?.data?.['sentry.source']).toBe('route'); const spans = transaction.spans || []; - const middlewareSpans = spans.filter(s => s.op === 'middleware.hono'); + const middlewareSpans = spans.filter(s => s.op === 'middleware'); expect(middlewareSpans).toEqual([]); }); diff --git a/dev-packages/e2e-tests/test-applications/nestjs-11/tests/transactions.test.ts b/dev-packages/e2e-tests/test-applications/nestjs-11/tests/transactions.test.ts index f6fcce730296..6ac9548ed03f 100644 --- a/dev-packages/e2e-tests/test-applications/nestjs-11/tests/transactions.test.ts +++ b/dev-packages/e2e-tests/test-applications/nestjs-11/tests/transactions.test.ts @@ -62,9 +62,9 @@ test('Sends an API route transaction', async ({ baseURL }) => { 'express.type': 'request_handler', 'http.route': '/test-transaction', 'sentry.origin': 'auto.http.express', - 'sentry.op': 'request_handler.express', + 'sentry.op': 'function', }, - op: 'request_handler.express', + op: 'function', description: '/test-transaction', parent_span_id: expect.stringMatching(/[a-f0-9]{16}/), span_id: expect.stringMatching(/[a-f0-9]{16}/), @@ -105,7 +105,7 @@ test('Sends an API route transaction', async ({ baseURL }) => { trace_id: expect.stringMatching(/[a-f0-9]{32}/), data: { 'sentry.origin': 'auto.http.nestjs', - 'sentry.op': 'handler.nestjs', + 'sentry.op': 'function', component: '@nestjs/core', 'nestjs.version': expect.any(String), 'nestjs.type': 'handler', @@ -117,7 +117,7 @@ test('Sends an API route transaction', async ({ baseURL }) => { timestamp: expect.any(Number), status: 'ok', origin: 'auto.http.nestjs', - op: 'handler.nestjs', + op: 'function', }, ]), transaction: 'GET /test-transaction', @@ -151,7 +151,7 @@ test('API route transaction includes nest middleware span. Spans created in and span_id: expect.stringMatching(/[a-f0-9]{16}/), trace_id: expect.stringMatching(/[a-f0-9]{32}/), data: { - 'sentry.op': 'middleware.nestjs', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.middleware.nestjs', }, description: 'ExampleMiddleware', @@ -159,7 +159,7 @@ test('API route transaction includes nest middleware span. Spans created in and start_timestamp: expect.any(Number), timestamp: expect.any(Number), status: 'ok', - op: 'middleware.nestjs', + op: 'middleware', origin: 'auto.middleware.nestjs', }, ]), @@ -231,7 +231,7 @@ test('API route transaction includes nest guard span and span started in guard i span_id: expect.stringMatching(/[a-f0-9]{16}/), trace_id: expect.stringMatching(/[a-f0-9]{32}/), data: { - 'sentry.op': 'middleware.nestjs', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.middleware.nestjs.guard', }, description: 'ExampleGuard', @@ -239,7 +239,7 @@ test('API route transaction includes nest guard span and span started in guard i start_timestamp: expect.any(Number), timestamp: expect.any(Number), status: 'ok', - op: 'middleware.nestjs', + op: 'middleware', origin: 'auto.middleware.nestjs.guard', }, ]), @@ -295,7 +295,7 @@ test('API route transaction includes nest pipe span for valid request', async ({ span_id: expect.stringMatching(/[a-f0-9]{16}/), trace_id: expect.stringMatching(/[a-f0-9]{32}/), data: { - 'sentry.op': 'middleware.nestjs', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.middleware.nestjs.pipe', }, description: 'ParseIntPipe', @@ -303,7 +303,7 @@ test('API route transaction includes nest pipe span for valid request', async ({ start_timestamp: expect.any(Number), timestamp: expect.any(Number), status: 'ok', - op: 'middleware.nestjs', + op: 'middleware', origin: 'auto.middleware.nestjs.pipe', }, ]), @@ -332,7 +332,7 @@ test('API route transaction includes nest pipe span for invalid request', async span_id: expect.stringMatching(/[a-f0-9]{16}/), trace_id: expect.stringMatching(/[a-f0-9]{32}/), data: { - 'sentry.op': 'middleware.nestjs', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.middleware.nestjs.pipe', }, description: 'ParseIntPipe', @@ -340,7 +340,7 @@ test('API route transaction includes nest pipe span for invalid request', async start_timestamp: expect.any(Number), timestamp: expect.any(Number), status: 'internal_error', - op: 'middleware.nestjs', + op: 'middleware', origin: 'auto.middleware.nestjs.pipe', }, ]), @@ -371,7 +371,7 @@ test('API route transaction includes nest interceptor spans before route executi span_id: expect.stringMatching(/[a-f0-9]{16}/), trace_id: expect.stringMatching(/[a-f0-9]{32}/), data: { - 'sentry.op': 'middleware.nestjs', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.middleware.nestjs.interceptor', }, description: 'ExampleInterceptor1', @@ -379,14 +379,14 @@ test('API route transaction includes nest interceptor spans before route executi start_timestamp: expect.any(Number), timestamp: expect.any(Number), status: 'ok', - op: 'middleware.nestjs', + op: 'middleware', origin: 'auto.middleware.nestjs.interceptor', }, { span_id: expect.stringMatching(/[a-f0-9]{16}/), trace_id: expect.stringMatching(/[a-f0-9]{32}/), data: { - 'sentry.op': 'middleware.nestjs', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.middleware.nestjs.interceptor', }, description: 'ExampleInterceptor2', @@ -394,7 +394,7 @@ test('API route transaction includes nest interceptor spans before route executi start_timestamp: expect.any(Number), timestamp: expect.any(Number), status: 'ok', - op: 'middleware.nestjs', + op: 'middleware', origin: 'auto.middleware.nestjs.interceptor', }, ]), @@ -489,7 +489,7 @@ test('API route transaction includes exactly one nest interceptor span after rou span_id: expect.stringMatching(/[a-f0-9]{16}/), trace_id: expect.stringMatching(/[a-f0-9]{32}/), data: { - 'sentry.op': 'middleware.nestjs', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.middleware.nestjs.interceptor', }, description: 'Interceptors - After Route', @@ -497,7 +497,7 @@ test('API route transaction includes exactly one nest interceptor span after rou start_timestamp: expect.any(Number), timestamp: expect.any(Number), status: 'ok', - op: 'middleware.nestjs', + op: 'middleware', origin: 'auto.middleware.nestjs.interceptor', }, ]), @@ -571,7 +571,7 @@ test('API route transaction includes nest async interceptor spans before route e span_id: expect.stringMatching(/[a-f0-9]{16}/), trace_id: expect.stringMatching(/[a-f0-9]{32}/), data: { - 'sentry.op': 'middleware.nestjs', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.middleware.nestjs.interceptor', }, description: 'AsyncInterceptor', @@ -579,7 +579,7 @@ test('API route transaction includes nest async interceptor spans before route e start_timestamp: expect.any(Number), timestamp: expect.any(Number), status: 'ok', - op: 'middleware.nestjs', + op: 'middleware', origin: 'auto.middleware.nestjs.interceptor', }, ]), @@ -656,7 +656,7 @@ test('API route transaction includes exactly one nest async interceptor span aft span_id: expect.stringMatching(/[a-f0-9]{16}/), trace_id: expect.stringMatching(/[a-f0-9]{32}/), data: { - 'sentry.op': 'middleware.nestjs', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.middleware.nestjs.interceptor', }, description: 'Interceptors - After Route', @@ -664,7 +664,7 @@ test('API route transaction includes exactly one nest async interceptor span aft start_timestamp: expect.any(Number), timestamp: expect.any(Number), status: 'ok', - op: 'middleware.nestjs', + op: 'middleware', origin: 'auto.middleware.nestjs.interceptor', }, ]), diff --git a/dev-packages/e2e-tests/test-applications/nestjs-8/tests/transactions.test.ts b/dev-packages/e2e-tests/test-applications/nestjs-8/tests/transactions.test.ts index d3004503544c..512f6d60d3b0 100644 --- a/dev-packages/e2e-tests/test-applications/nestjs-8/tests/transactions.test.ts +++ b/dev-packages/e2e-tests/test-applications/nestjs-8/tests/transactions.test.ts @@ -66,9 +66,9 @@ test('Sends an API route transaction', async ({ baseURL }) => { 'express.type': 'request_handler', 'http.route': '/test-transaction', 'sentry.origin': 'auto.http.express', - 'sentry.op': 'request_handler.express', + 'sentry.op': 'function', }, - op: 'request_handler.express', + op: 'function', description: '/test-transaction', parent_span_id: expect.stringMatching(/[a-f0-9]{16}/), span_id: expect.stringMatching(/[a-f0-9]{16}/), @@ -109,7 +109,7 @@ test('Sends an API route transaction', async ({ baseURL }) => { trace_id: expect.stringMatching(/[a-f0-9]{32}/), data: { 'sentry.origin': 'auto.http.nestjs', - 'sentry.op': 'handler.nestjs', + 'sentry.op': 'function', component: '@nestjs/core', 'nestjs.version': expect.any(String), 'nestjs.type': 'handler', @@ -121,7 +121,7 @@ test('Sends an API route transaction', async ({ baseURL }) => { timestamp: expect.any(Number), status: 'ok', origin: 'auto.http.nestjs', - op: 'handler.nestjs', + op: 'function', }, ]), transaction: 'GET /test-transaction', @@ -155,7 +155,7 @@ test('API route transaction includes nest middleware span. Spans created in and span_id: expect.stringMatching(/[a-f0-9]{16}/), trace_id: expect.stringMatching(/[a-f0-9]{32}/), data: { - 'sentry.op': 'middleware.nestjs', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.middleware.nestjs', }, description: 'ExampleMiddleware', @@ -163,7 +163,7 @@ test('API route transaction includes nest middleware span. Spans created in and start_timestamp: expect.any(Number), timestamp: expect.any(Number), status: 'ok', - op: 'middleware.nestjs', + op: 'middleware', origin: 'auto.middleware.nestjs', }, ]), @@ -235,7 +235,7 @@ test('API route transaction includes nest guard span and span started in guard i span_id: expect.stringMatching(/[a-f0-9]{16}/), trace_id: expect.stringMatching(/[a-f0-9]{32}/), data: { - 'sentry.op': 'middleware.nestjs', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.middleware.nestjs.guard', }, description: 'ExampleGuard', @@ -243,7 +243,7 @@ test('API route transaction includes nest guard span and span started in guard i start_timestamp: expect.any(Number), timestamp: expect.any(Number), status: 'ok', - op: 'middleware.nestjs', + op: 'middleware', origin: 'auto.middleware.nestjs.guard', }, ]), @@ -299,7 +299,7 @@ test('API route transaction includes nest pipe span for valid request', async ({ span_id: expect.stringMatching(/[a-f0-9]{16}/), trace_id: expect.stringMatching(/[a-f0-9]{32}/), data: { - 'sentry.op': 'middleware.nestjs', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.middleware.nestjs.pipe', }, description: 'ParseIntPipe', @@ -307,7 +307,7 @@ test('API route transaction includes nest pipe span for valid request', async ({ start_timestamp: expect.any(Number), timestamp: expect.any(Number), status: 'ok', - op: 'middleware.nestjs', + op: 'middleware', origin: 'auto.middleware.nestjs.pipe', }, ]), @@ -336,7 +336,7 @@ test('API route transaction includes nest pipe span for invalid request', async span_id: expect.stringMatching(/[a-f0-9]{16}/), trace_id: expect.stringMatching(/[a-f0-9]{32}/), data: { - 'sentry.op': 'middleware.nestjs', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.middleware.nestjs.pipe', }, description: 'ParseIntPipe', @@ -344,7 +344,7 @@ test('API route transaction includes nest pipe span for invalid request', async start_timestamp: expect.any(Number), timestamp: expect.any(Number), status: 'internal_error', - op: 'middleware.nestjs', + op: 'middleware', origin: 'auto.middleware.nestjs.pipe', }, ]), @@ -375,7 +375,7 @@ test('API route transaction includes nest interceptor spans before route executi span_id: expect.stringMatching(/[a-f0-9]{16}/), trace_id: expect.stringMatching(/[a-f0-9]{32}/), data: { - 'sentry.op': 'middleware.nestjs', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.middleware.nestjs.interceptor', }, description: 'ExampleInterceptor1', @@ -383,14 +383,14 @@ test('API route transaction includes nest interceptor spans before route executi start_timestamp: expect.any(Number), timestamp: expect.any(Number), status: 'ok', - op: 'middleware.nestjs', + op: 'middleware', origin: 'auto.middleware.nestjs.interceptor', }, { span_id: expect.stringMatching(/[a-f0-9]{16}/), trace_id: expect.stringMatching(/[a-f0-9]{32}/), data: { - 'sentry.op': 'middleware.nestjs', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.middleware.nestjs.interceptor', }, description: 'ExampleInterceptor2', @@ -398,7 +398,7 @@ test('API route transaction includes nest interceptor spans before route executi start_timestamp: expect.any(Number), timestamp: expect.any(Number), status: 'ok', - op: 'middleware.nestjs', + op: 'middleware', origin: 'auto.middleware.nestjs.interceptor', }, ]), @@ -493,7 +493,7 @@ test('API route transaction includes exactly one nest interceptor span after rou span_id: expect.stringMatching(/[a-f0-9]{16}/), trace_id: expect.stringMatching(/[a-f0-9]{32}/), data: { - 'sentry.op': 'middleware.nestjs', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.middleware.nestjs.interceptor', }, description: 'Interceptors - After Route', @@ -501,7 +501,7 @@ test('API route transaction includes exactly one nest interceptor span after rou start_timestamp: expect.any(Number), timestamp: expect.any(Number), status: 'ok', - op: 'middleware.nestjs', + op: 'middleware', origin: 'auto.middleware.nestjs.interceptor', }, ]), @@ -575,7 +575,7 @@ test('API route transaction includes nest async interceptor spans before route e span_id: expect.stringMatching(/[a-f0-9]{16}/), trace_id: expect.stringMatching(/[a-f0-9]{32}/), data: { - 'sentry.op': 'middleware.nestjs', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.middleware.nestjs.interceptor', }, description: 'AsyncInterceptor', @@ -583,7 +583,7 @@ test('API route transaction includes nest async interceptor spans before route e start_timestamp: expect.any(Number), timestamp: expect.any(Number), status: 'ok', - op: 'middleware.nestjs', + op: 'middleware', origin: 'auto.middleware.nestjs.interceptor', }, ]), @@ -660,7 +660,7 @@ test('API route transaction includes exactly one nest async interceptor span aft span_id: expect.stringMatching(/[a-f0-9]{16}/), trace_id: expect.stringMatching(/[a-f0-9]{32}/), data: { - 'sentry.op': 'middleware.nestjs', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.middleware.nestjs.interceptor', }, description: 'Interceptors - After Route', @@ -668,7 +668,7 @@ test('API route transaction includes exactly one nest async interceptor span aft start_timestamp: expect.any(Number), timestamp: expect.any(Number), status: 'ok', - op: 'middleware.nestjs', + op: 'middleware', origin: 'auto.middleware.nestjs.interceptor', }, ]), diff --git a/dev-packages/e2e-tests/test-applications/nestjs-basic/tests/transactions.test.ts b/dev-packages/e2e-tests/test-applications/nestjs-basic/tests/transactions.test.ts index 31472452f460..2d3100b95d1d 100644 --- a/dev-packages/e2e-tests/test-applications/nestjs-basic/tests/transactions.test.ts +++ b/dev-packages/e2e-tests/test-applications/nestjs-basic/tests/transactions.test.ts @@ -88,9 +88,9 @@ test('Sends an API route transaction', async ({ baseURL }) => { 'express.type': 'request_handler', 'http.route': '/test-transaction', 'sentry.origin': 'auto.http.express', - 'sentry.op': 'request_handler.express', + 'sentry.op': 'function', }, - op: 'request_handler.express', + op: 'function', description: '/test-transaction', parent_span_id: expect.stringMatching(/[a-f0-9]{16}/), span_id: expect.stringMatching(/[a-f0-9]{16}/), @@ -131,7 +131,7 @@ test('Sends an API route transaction', async ({ baseURL }) => { trace_id: expect.stringMatching(/[a-f0-9]{32}/), data: { 'sentry.origin': 'auto.http.nestjs', - 'sentry.op': 'handler.nestjs', + 'sentry.op': 'function', component: '@nestjs/core', 'nestjs.version': expect.any(String), 'nestjs.type': 'handler', @@ -143,7 +143,7 @@ test('Sends an API route transaction', async ({ baseURL }) => { timestamp: expect.any(Number), status: 'ok', origin: 'auto.http.nestjs', - op: 'handler.nestjs', + op: 'function', }, ]), transaction: 'GET /test-transaction', @@ -177,7 +177,7 @@ test('API route transaction includes nest middleware span. Spans created in and span_id: expect.stringMatching(/[a-f0-9]{16}/), trace_id: expect.stringMatching(/[a-f0-9]{32}/), data: { - 'sentry.op': 'middleware.nestjs', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.middleware.nestjs', }, description: 'ExampleMiddleware', @@ -185,7 +185,7 @@ test('API route transaction includes nest middleware span. Spans created in and start_timestamp: expect.any(Number), timestamp: expect.any(Number), status: 'ok', - op: 'middleware.nestjs', + op: 'middleware', origin: 'auto.middleware.nestjs', }, ]), @@ -257,7 +257,7 @@ test('API route transaction includes nest guard span and span started in guard i span_id: expect.stringMatching(/[a-f0-9]{16}/), trace_id: expect.stringMatching(/[a-f0-9]{32}/), data: { - 'sentry.op': 'middleware.nestjs', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.middleware.nestjs.guard', }, description: 'ExampleGuard', @@ -265,7 +265,7 @@ test('API route transaction includes nest guard span and span started in guard i start_timestamp: expect.any(Number), timestamp: expect.any(Number), status: 'ok', - op: 'middleware.nestjs', + op: 'middleware', origin: 'auto.middleware.nestjs.guard', }, ]), @@ -321,7 +321,7 @@ test('API route transaction includes nest pipe span for valid request', async ({ span_id: expect.stringMatching(/[a-f0-9]{16}/), trace_id: expect.stringMatching(/[a-f0-9]{32}/), data: { - 'sentry.op': 'middleware.nestjs', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.middleware.nestjs.pipe', }, description: 'ParseIntPipe', @@ -329,7 +329,7 @@ test('API route transaction includes nest pipe span for valid request', async ({ start_timestamp: expect.any(Number), timestamp: expect.any(Number), status: 'ok', - op: 'middleware.nestjs', + op: 'middleware', origin: 'auto.middleware.nestjs.pipe', }, ]), @@ -358,7 +358,7 @@ test('API route transaction includes nest pipe span for invalid request', async span_id: expect.stringMatching(/[a-f0-9]{16}/), trace_id: expect.stringMatching(/[a-f0-9]{32}/), data: { - 'sentry.op': 'middleware.nestjs', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.middleware.nestjs.pipe', }, description: 'ParseIntPipe', @@ -366,7 +366,7 @@ test('API route transaction includes nest pipe span for invalid request', async start_timestamp: expect.any(Number), timestamp: expect.any(Number), status: 'internal_error', - op: 'middleware.nestjs', + op: 'middleware', origin: 'auto.middleware.nestjs.pipe', }, ]), @@ -397,7 +397,7 @@ test('API route transaction includes nest interceptor spans before route executi span_id: expect.stringMatching(/[a-f0-9]{16}/), trace_id: expect.stringMatching(/[a-f0-9]{32}/), data: { - 'sentry.op': 'middleware.nestjs', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.middleware.nestjs.interceptor', }, description: 'ExampleInterceptor1', @@ -405,14 +405,14 @@ test('API route transaction includes nest interceptor spans before route executi start_timestamp: expect.any(Number), timestamp: expect.any(Number), status: 'ok', - op: 'middleware.nestjs', + op: 'middleware', origin: 'auto.middleware.nestjs.interceptor', }, { span_id: expect.stringMatching(/[a-f0-9]{16}/), trace_id: expect.stringMatching(/[a-f0-9]{32}/), data: { - 'sentry.op': 'middleware.nestjs', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.middleware.nestjs.interceptor', }, description: 'ExampleInterceptor2', @@ -420,7 +420,7 @@ test('API route transaction includes nest interceptor spans before route executi start_timestamp: expect.any(Number), timestamp: expect.any(Number), status: 'ok', - op: 'middleware.nestjs', + op: 'middleware', origin: 'auto.middleware.nestjs.interceptor', }, ]), @@ -515,7 +515,7 @@ test('API route transaction includes exactly one nest interceptor span after rou span_id: expect.stringMatching(/[a-f0-9]{16}/), trace_id: expect.stringMatching(/[a-f0-9]{32}/), data: { - 'sentry.op': 'middleware.nestjs', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.middleware.nestjs.interceptor', }, description: 'Interceptors - After Route', @@ -523,7 +523,7 @@ test('API route transaction includes exactly one nest interceptor span after rou start_timestamp: expect.any(Number), timestamp: expect.any(Number), status: 'ok', - op: 'middleware.nestjs', + op: 'middleware', origin: 'auto.middleware.nestjs.interceptor', }, ]), @@ -597,7 +597,7 @@ test('API route transaction includes nest async interceptor spans before route e span_id: expect.stringMatching(/[a-f0-9]{16}/), trace_id: expect.stringMatching(/[a-f0-9]{32}/), data: { - 'sentry.op': 'middleware.nestjs', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.middleware.nestjs.interceptor', }, description: 'AsyncInterceptor', @@ -605,7 +605,7 @@ test('API route transaction includes nest async interceptor spans before route e start_timestamp: expect.any(Number), timestamp: expect.any(Number), status: 'ok', - op: 'middleware.nestjs', + op: 'middleware', origin: 'auto.middleware.nestjs.interceptor', }, ]), @@ -682,7 +682,7 @@ test('API route transaction includes exactly one nest async interceptor span aft span_id: expect.stringMatching(/[a-f0-9]{16}/), trace_id: expect.stringMatching(/[a-f0-9]{32}/), data: { - 'sentry.op': 'middleware.nestjs', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.middleware.nestjs.interceptor', }, description: 'Interceptors - After Route', @@ -690,7 +690,7 @@ test('API route transaction includes exactly one nest async interceptor span aft start_timestamp: expect.any(Number), timestamp: expect.any(Number), status: 'ok', - op: 'middleware.nestjs', + op: 'middleware', origin: 'auto.middleware.nestjs.interceptor', }, ]), diff --git a/dev-packages/e2e-tests/test-applications/nestjs-fastify/tests/transactions.test.ts b/dev-packages/e2e-tests/test-applications/nestjs-fastify/tests/transactions.test.ts index 2c263ea7c8ff..5198eeaa9439 100644 --- a/dev-packages/e2e-tests/test-applications/nestjs-fastify/tests/transactions.test.ts +++ b/dev-packages/e2e-tests/test-applications/nestjs-fastify/tests/transactions.test.ts @@ -65,13 +65,13 @@ test.skip('Sends an API route transaction', async ({ baseURL }) => { trace_id: expect.stringMatching(/[a-f0-9]{32}/), data: { 'sentry.origin': 'auto.http.otel.fastify', - 'sentry.op': 'hook.fastify', + 'sentry.op': 'middleware', 'hook.name': 'fastify -> @sentry/instrumentation-fastify -> @fastify/middie - onRequest', 'fastify.type': 'hook', 'hook.callback.name': 'runMiddie', }, description: '@fastify/middie - onRequest', - op: 'hook.fastify', + op: 'middleware', parent_span_id: expect.stringMatching(/[a-f0-9]{16}/), start_timestamp: expect.any(Number), timestamp: expect.any(Number), @@ -83,14 +83,14 @@ test.skip('Sends an API route transaction', async ({ baseURL }) => { trace_id: expect.stringMatching(/[a-f0-9]{32}/), data: { 'sentry.origin': 'auto.http.otel.fastify', - 'sentry.op': 'request_handler.fastify', + 'sentry.op': 'function', 'hook.name': 'fastify -> @sentry/instrumentation-fastify -> @fastify/middie - route-handler', 'fastify.type': 'request-handler', 'http.route': '/test-transaction', 'hook.callback.name': 'anonymous', }, description: '@fastify/middie - route-handler', - op: 'request_handler.fastify', + op: 'function', parent_span_id: expect.stringMatching(/[a-f0-9]{16}/), start_timestamp: expect.any(Number), timestamp: expect.any(Number), @@ -125,7 +125,7 @@ test.skip('Sends an API route transaction', async ({ baseURL }) => { trace_id: expect.stringMatching(/[a-f0-9]{32}/), data: { 'sentry.origin': 'auto.http.nestjs', - 'sentry.op': 'handler.nestjs', + 'sentry.op': 'function', component: '@nestjs/core', 'nestjs.version': expect.any(String), 'nestjs.type': 'handler', @@ -136,7 +136,7 @@ test.skip('Sends an API route transaction', async ({ baseURL }) => { start_timestamp: expect.any(Number), timestamp: expect.any(Number), status: 'ok', - op: 'handler.nestjs', + op: 'function', origin: 'auto.http.nestjs', }, { @@ -198,7 +198,7 @@ test('API route transaction includes nest middleware span. Spans created in and span_id: expect.stringMatching(/[a-f0-9]{16}/), trace_id: expect.stringMatching(/[a-f0-9]{32}/), data: { - 'sentry.op': 'middleware.nestjs', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.middleware.nestjs', }, description: 'ExampleMiddleware', @@ -206,7 +206,7 @@ test('API route transaction includes nest middleware span. Spans created in and start_timestamp: expect.any(Number), timestamp: expect.any(Number), status: 'ok', - op: 'middleware.nestjs', + op: 'middleware', origin: 'auto.middleware.nestjs', }, ]), @@ -278,7 +278,7 @@ test('API route transaction includes nest guard span and span started in guard i span_id: expect.stringMatching(/[a-f0-9]{16}/), trace_id: expect.stringMatching(/[a-f0-9]{32}/), data: { - 'sentry.op': 'middleware.nestjs', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.middleware.nestjs.guard', }, description: 'ExampleGuard', @@ -286,7 +286,7 @@ test('API route transaction includes nest guard span and span started in guard i start_timestamp: expect.any(Number), timestamp: expect.any(Number), status: 'ok', - op: 'middleware.nestjs', + op: 'middleware', origin: 'auto.middleware.nestjs.guard', }, ]), @@ -342,7 +342,7 @@ test('API route transaction includes nest pipe span for valid request', async ({ span_id: expect.stringMatching(/[a-f0-9]{16}/), trace_id: expect.stringMatching(/[a-f0-9]{32}/), data: { - 'sentry.op': 'middleware.nestjs', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.middleware.nestjs.pipe', }, description: 'ParseIntPipe', @@ -350,7 +350,7 @@ test('API route transaction includes nest pipe span for valid request', async ({ start_timestamp: expect.any(Number), timestamp: expect.any(Number), status: 'ok', - op: 'middleware.nestjs', + op: 'middleware', origin: 'auto.middleware.nestjs.pipe', }, ]), @@ -379,7 +379,7 @@ test('API route transaction includes nest pipe span for invalid request', async span_id: expect.stringMatching(/[a-f0-9]{16}/), trace_id: expect.stringMatching(/[a-f0-9]{32}/), data: { - 'sentry.op': 'middleware.nestjs', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.middleware.nestjs.pipe', }, description: 'ParseIntPipe', @@ -387,7 +387,7 @@ test('API route transaction includes nest pipe span for invalid request', async start_timestamp: expect.any(Number), timestamp: expect.any(Number), status: 'internal_error', - op: 'middleware.nestjs', + op: 'middleware', origin: 'auto.middleware.nestjs.pipe', }, ]), @@ -418,7 +418,7 @@ test('API route transaction includes nest interceptor spans before route executi span_id: expect.stringMatching(/[a-f0-9]{16}/), trace_id: expect.stringMatching(/[a-f0-9]{32}/), data: { - 'sentry.op': 'middleware.nestjs', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.middleware.nestjs.interceptor', }, description: 'ExampleInterceptor1', @@ -426,14 +426,14 @@ test('API route transaction includes nest interceptor spans before route executi start_timestamp: expect.any(Number), timestamp: expect.any(Number), status: 'ok', - op: 'middleware.nestjs', + op: 'middleware', origin: 'auto.middleware.nestjs.interceptor', }, { span_id: expect.stringMatching(/[a-f0-9]{16}/), trace_id: expect.stringMatching(/[a-f0-9]{32}/), data: { - 'sentry.op': 'middleware.nestjs', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.middleware.nestjs.interceptor', }, description: 'ExampleInterceptor2', @@ -441,7 +441,7 @@ test('API route transaction includes nest interceptor spans before route executi start_timestamp: expect.any(Number), timestamp: expect.any(Number), status: 'ok', - op: 'middleware.nestjs', + op: 'middleware', origin: 'auto.middleware.nestjs.interceptor', }, ]), @@ -536,7 +536,7 @@ test('API route transaction includes exactly one nest interceptor span after rou span_id: expect.stringMatching(/[a-f0-9]{16}/), trace_id: expect.stringMatching(/[a-f0-9]{32}/), data: { - 'sentry.op': 'middleware.nestjs', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.middleware.nestjs.interceptor', }, description: 'Interceptors - After Route', @@ -544,7 +544,7 @@ test('API route transaction includes exactly one nest interceptor span after rou start_timestamp: expect.any(Number), timestamp: expect.any(Number), status: 'ok', - op: 'middleware.nestjs', + op: 'middleware', origin: 'auto.middleware.nestjs.interceptor', }, ]), @@ -618,7 +618,7 @@ test('API route transaction includes nest async interceptor spans before route e span_id: expect.stringMatching(/[a-f0-9]{16}/), trace_id: expect.stringMatching(/[a-f0-9]{32}/), data: { - 'sentry.op': 'middleware.nestjs', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.middleware.nestjs.interceptor', }, description: 'AsyncInterceptor', @@ -626,7 +626,7 @@ test('API route transaction includes nest async interceptor spans before route e start_timestamp: expect.any(Number), timestamp: expect.any(Number), status: 'ok', - op: 'middleware.nestjs', + op: 'middleware', origin: 'auto.middleware.nestjs.interceptor', }, ]), @@ -703,7 +703,7 @@ test('API route transaction includes exactly one nest async interceptor span aft span_id: expect.stringMatching(/[a-f0-9]{16}/), trace_id: expect.stringMatching(/[a-f0-9]{32}/), data: { - 'sentry.op': 'middleware.nestjs', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.middleware.nestjs.interceptor', }, description: 'Interceptors - After Route', @@ -711,7 +711,7 @@ test('API route transaction includes exactly one nest async interceptor span aft start_timestamp: expect.any(Number), timestamp: expect.any(Number), status: 'ok', - op: 'middleware.nestjs', + op: 'middleware', origin: 'auto.middleware.nestjs.interceptor', }, ]), @@ -799,7 +799,7 @@ test('Sets error status on nest spans when a handler throws', async ({ baseURL } expect(transactionEvent.spans).toEqual( expect.arrayContaining([ expect.objectContaining({ op: 'request_context.nestjs', status: 'internal_error' }), - expect.objectContaining({ op: 'handler.nestjs', status: 'internal_error' }), + expect.objectContaining({ op: 'function', status: 'internal_error' }), ]), ); }); diff --git a/dev-packages/e2e-tests/test-applications/nestjs-orchestrion/README.md b/dev-packages/e2e-tests/test-applications/nestjs-orchestrion/README.md index c637516cc6fc..e0a137d517d4 100644 --- a/dev-packages/e2e-tests/test-applications/nestjs-orchestrion/README.md +++ b/dev-packages/e2e-tests/test-applications/nestjs-orchestrion/README.md @@ -12,9 +12,8 @@ The tests assert the **same** span tree the OTel path produced instrumentation against that baseline: - `transactions.test.ts`: `app_creation`, `request_context`, - `handler`, and the - `middleware.nestjs[.guard|.pipe|.interceptor|.exception_filter]` - spans. + `handler`, and the `middleware` spans + (origin `auto.middleware.nestjs[.guard|.pipe|.interceptor|.exception_filter]`). - `schedule.test.ts`: `@Cron`/`@Interval`/`@Timeout` error mechanisms. - `events.test.ts`: the `@OnEvent` `event.nestjs` transaction. diff --git a/dev-packages/e2e-tests/test-applications/nestjs-orchestrion/src/example.guard.ts b/dev-packages/e2e-tests/test-applications/nestjs-orchestrion/src/example.guard.ts index a9069f4e6f9d..dbcd982d1f7b 100644 --- a/dev-packages/e2e-tests/test-applications/nestjs-orchestrion/src/example.guard.ts +++ b/dev-packages/e2e-tests/test-applications/nestjs-orchestrion/src/example.guard.ts @@ -5,7 +5,7 @@ import * as Sentry from '@sentry/nestjs'; export class ExampleGuard implements CanActivate { public canActivate(_context: ExecutionContext): boolean { // Child span - // should nest under the guard span (middleware.nestjs / .guard). + // should nest under the guard span (middleware op, auto.middleware.nestjs.guard origin). Sentry.startSpan({ name: 'test-guard-span' }, () => undefined); return true; } diff --git a/dev-packages/e2e-tests/test-applications/nestjs-orchestrion/tests/transactions.test.ts b/dev-packages/e2e-tests/test-applications/nestjs-orchestrion/tests/transactions.test.ts index 897467c903d8..ef13bcfcfe7f 100644 --- a/dev-packages/e2e-tests/test-applications/nestjs-orchestrion/tests/transactions.test.ts +++ b/dev-packages/e2e-tests/test-applications/nestjs-orchestrion/tests/transactions.test.ts @@ -60,7 +60,7 @@ test('request_context + handler: a route transaction nests the nestjs spans', as // request_handler span: wraps the controller method itself. const handler = (transactionEvent.spans ?? []).find( - span => span.op === 'handler.nestjs' && span.description === 'testTransaction', + span => span.op === 'function' && span.description === 'testTransaction', ); expect(handler).toBeDefined(); }); @@ -90,13 +90,13 @@ for (const { route, origin, description } of MIDDLEWARE_CASES) { await fetch(`${baseURL}/${route}`); const transactionEvent = await transactionPromise; - const span = findSpan(transactionEvent, 'middleware.nestjs', origin); + const span = findSpan(transactionEvent, 'middleware', origin); expect(span, `expected a ${origin} span`).toBeDefined(); expect(span?.description).toBe(description); }); } -test('exception_filter span: a @Catch filter opens a middleware.nestjs span', async ({ baseURL }) => { +test('exception_filter span: a @Catch filter opens a middleware span', async ({ baseURL }) => { const transactionPromise = waitForTransaction(PROXY, transactionEvent => { return ( transactionEvent?.contexts?.trace?.op === 'http.server' && transactionEvent?.transaction === 'GET /test-exception' @@ -106,7 +106,7 @@ test('exception_filter span: a @Catch filter opens a middleware.nestjs span', as await fetch(`${baseURL}/test-exception`); const transactionEvent = await transactionPromise; - const span = findSpan(transactionEvent, 'middleware.nestjs', 'auto.middleware.nestjs.exception_filter'); + const span = findSpan(transactionEvent, 'middleware', 'auto.middleware.nestjs.exception_filter'); expect(span).toBeDefined(); expect(span?.description).toBe('ExampleExceptionFilter'); }); diff --git a/dev-packages/e2e-tests/test-applications/nestjs-with-submodules-decorator/tests/transactions.test.ts b/dev-packages/e2e-tests/test-applications/nestjs-with-submodules-decorator/tests/transactions.test.ts index bfbfbf98081a..8c2c3bc8cbe9 100644 --- a/dev-packages/e2e-tests/test-applications/nestjs-with-submodules-decorator/tests/transactions.test.ts +++ b/dev-packages/e2e-tests/test-applications/nestjs-with-submodules-decorator/tests/transactions.test.ts @@ -62,9 +62,9 @@ test('Sends an API route transaction from module', async ({ baseURL }) => { 'express.type': 'request_handler', 'http.route': '/example-module/transaction', 'sentry.origin': 'auto.http.express', - 'sentry.op': 'request_handler.express', + 'sentry.op': 'function', }, - op: 'request_handler.express', + op: 'function', description: '/example-module/transaction', parent_span_id: expect.stringMatching(/[a-f0-9]{16}/), span_id: expect.stringMatching(/[a-f0-9]{16}/), @@ -105,7 +105,7 @@ test('Sends an API route transaction from module', async ({ baseURL }) => { trace_id: expect.stringMatching(/[a-f0-9]{32}/), data: { 'sentry.origin': 'auto.http.nestjs', - 'sentry.op': 'handler.nestjs', + 'sentry.op': 'function', component: '@nestjs/core', 'nestjs.version': expect.any(String), 'nestjs.type': 'handler', @@ -117,7 +117,7 @@ test('Sends an API route transaction from module', async ({ baseURL }) => { timestamp: expect.any(Number), status: 'ok', origin: 'auto.http.nestjs', - op: 'handler.nestjs', + op: 'function', }, ]), transaction: 'GET /example-module/transaction', @@ -152,7 +152,7 @@ test('API route transaction includes exception filter span for global filter in span_id: expect.stringMatching(/[a-f0-9]{16}/), trace_id: expect.stringMatching(/[a-f0-9]{32}/), data: { - 'sentry.op': 'middleware.nestjs', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.middleware.nestjs.exception_filter', }, description: 'ExampleExceptionFilter', @@ -160,7 +160,7 @@ test('API route transaction includes exception filter span for global filter in start_timestamp: expect.any(Number), timestamp: expect.any(Number), status: 'ok', - op: 'middleware.nestjs', + op: 'middleware', origin: 'auto.middleware.nestjs.exception_filter', }, ]), @@ -191,7 +191,7 @@ test('API route transaction includes exception filter span for local filter in m span_id: expect.stringMatching(/[a-f0-9]{16}/), trace_id: expect.stringMatching(/[a-f0-9]{32}/), data: { - 'sentry.op': 'middleware.nestjs', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.middleware.nestjs.exception_filter', }, description: 'LocalExampleExceptionFilter', @@ -199,7 +199,7 @@ test('API route transaction includes exception filter span for local filter in m start_timestamp: expect.any(Number), timestamp: expect.any(Number), status: 'ok', - op: 'middleware.nestjs', + op: 'middleware', origin: 'auto.middleware.nestjs.exception_filter', }, ]), @@ -230,7 +230,7 @@ test('API route transaction includes exception filter span for global filter in span_id: expect.stringMatching(/[a-f0-9]{16}/), trace_id: expect.stringMatching(/[a-f0-9]{32}/), data: { - 'sentry.op': 'middleware.nestjs', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.middleware.nestjs.exception_filter', }, description: 'ExampleExceptionFilterRegisteredFirst', @@ -238,7 +238,7 @@ test('API route transaction includes exception filter span for global filter in start_timestamp: expect.any(Number), timestamp: expect.any(Number), status: 'ok', - op: 'middleware.nestjs', + op: 'middleware', origin: 'auto.middleware.nestjs.exception_filter', }, ]), diff --git a/dev-packages/e2e-tests/test-applications/nestjs-with-submodules/tests/transactions.test.ts b/dev-packages/e2e-tests/test-applications/nestjs-with-submodules/tests/transactions.test.ts index 3b1aad002241..3abf1ea5b5fa 100644 --- a/dev-packages/e2e-tests/test-applications/nestjs-with-submodules/tests/transactions.test.ts +++ b/dev-packages/e2e-tests/test-applications/nestjs-with-submodules/tests/transactions.test.ts @@ -62,9 +62,9 @@ test('Sends an API route transaction from module', async ({ baseURL }) => { 'express.type': 'request_handler', 'http.route': '/example-module/transaction', 'sentry.origin': 'auto.http.express', - 'sentry.op': 'request_handler.express', + 'sentry.op': 'function', }, - op: 'request_handler.express', + op: 'function', description: '/example-module/transaction', parent_span_id: expect.stringMatching(/[a-f0-9]{16}/), span_id: expect.stringMatching(/[a-f0-9]{16}/), @@ -105,7 +105,7 @@ test('Sends an API route transaction from module', async ({ baseURL }) => { trace_id: expect.stringMatching(/[a-f0-9]{32}/), data: { 'sentry.origin': 'auto.http.nestjs', - 'sentry.op': 'handler.nestjs', + 'sentry.op': 'function', component: '@nestjs/core', 'nestjs.version': expect.any(String), 'nestjs.type': 'handler', @@ -117,7 +117,7 @@ test('Sends an API route transaction from module', async ({ baseURL }) => { timestamp: expect.any(Number), status: 'ok', origin: 'auto.http.nestjs', - op: 'handler.nestjs', + op: 'function', }, ]), transaction: 'GET /example-module/transaction', @@ -152,7 +152,7 @@ test('API route transaction includes exception filter span for global filter in span_id: expect.stringMatching(/[a-f0-9]{16}/), trace_id: expect.stringMatching(/[a-f0-9]{32}/), data: { - 'sentry.op': 'middleware.nestjs', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.middleware.nestjs.exception_filter', }, description: 'ExampleExceptionFilter', @@ -160,7 +160,7 @@ test('API route transaction includes exception filter span for global filter in start_timestamp: expect.any(Number), timestamp: expect.any(Number), status: 'ok', - op: 'middleware.nestjs', + op: 'middleware', origin: 'auto.middleware.nestjs.exception_filter', }, ]), @@ -191,7 +191,7 @@ test('API route transaction includes exception filter span for local filter in m span_id: expect.stringMatching(/[a-f0-9]{16}/), trace_id: expect.stringMatching(/[a-f0-9]{32}/), data: { - 'sentry.op': 'middleware.nestjs', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.middleware.nestjs.exception_filter', }, description: 'LocalExampleExceptionFilter', @@ -199,7 +199,7 @@ test('API route transaction includes exception filter span for local filter in m start_timestamp: expect.any(Number), timestamp: expect.any(Number), status: 'ok', - op: 'middleware.nestjs', + op: 'middleware', origin: 'auto.middleware.nestjs.exception_filter', }, ]), @@ -230,7 +230,7 @@ test('API route transaction includes exception filter span for global filter in span_id: expect.stringMatching(/[a-f0-9]{16}/), trace_id: expect.stringMatching(/[a-f0-9]{32}/), data: { - 'sentry.op': 'middleware.nestjs', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.middleware.nestjs.exception_filter', }, description: 'ExampleExceptionFilterRegisteredFirst', @@ -238,7 +238,7 @@ test('API route transaction includes exception filter span for global filter in start_timestamp: expect.any(Number), timestamp: expect.any(Number), status: 'ok', - op: 'middleware.nestjs', + op: 'middleware', origin: 'auto.middleware.nestjs.exception_filter', }, ]), diff --git a/dev-packages/e2e-tests/test-applications/nitro-3/tests/middleware.test.ts b/dev-packages/e2e-tests/test-applications/nitro-3/tests/middleware.test.ts index eec281d28f98..50aed0ddabe2 100644 --- a/dev-packages/e2e-tests/test-applications/nitro-3/tests/middleware.test.ts +++ b/dev-packages/e2e-tests/test-applications/nitro-3/tests/middleware.test.ts @@ -12,9 +12,9 @@ test('Creates middleware spans for requests', async ({ request }) => { const transactionEvent = await transactionEventPromise; - // h3 middleware spans have origin auto.http.nitro.h3 and op middleware.nitro + // h3 middleware spans have origin auto.http.nitro.h3 and op middleware const h3MiddlewareSpans = transactionEvent.spans?.filter( - span => span.origin === 'auto.http.nitro.h3' && span.op === 'middleware.nitro', + span => span.origin === 'auto.http.nitro.h3' && span.op === 'middleware', ); expect(h3MiddlewareSpans?.length).toBeGreaterThanOrEqual(1); }); diff --git a/dev-packages/e2e-tests/test-applications/nitro-3/tests/span-nesting.test.ts b/dev-packages/e2e-tests/test-applications/nitro-3/tests/span-nesting.test.ts index 8a824c4fe429..841566b32d74 100644 --- a/dev-packages/e2e-tests/test-applications/nitro-3/tests/span-nesting.test.ts +++ b/dev-packages/e2e-tests/test-applications/nitro-3/tests/span-nesting.test.ts @@ -34,7 +34,7 @@ test('Span nesting: h3 middleware spans are children of the srvx request span', // All h3 middleware spans should be children of the srvx span const h3MiddlewareSpans = event.spans?.filter( - span => span.origin === 'auto.http.nitro.h3' && span.op === 'middleware.nitro', + span => span.origin === 'auto.http.nitro.h3' && span.op === 'middleware', ); expect(h3MiddlewareSpans?.length).toBeGreaterThanOrEqual(1); @@ -104,7 +104,7 @@ test('Span nesting: middleware spans start before manual spans in the span tree' const event = await transactionEventPromise; // Middleware spans should start before the manual db spans - const middlewareSpans = event.spans?.filter(span => span.op === 'middleware.nitro') ?? []; + const middlewareSpans = event.spans?.filter(span => span.op === 'middleware') ?? []; const dbSpans = event.spans?.filter(span => span.op === 'db') ?? []; expect(middlewareSpans.length).toBeGreaterThanOrEqual(1); diff --git a/dev-packages/e2e-tests/test-applications/node-express-cjs-preload/tests/server.test.ts b/dev-packages/e2e-tests/test-applications/node-express-cjs-preload/tests/server.test.ts index bc6cbde21393..79b50c9a9179 100644 --- a/dev-packages/e2e-tests/test-applications/node-express-cjs-preload/tests/server.test.ts +++ b/dev-packages/e2e-tests/test-applications/node-express-cjs-preload/tests/server.test.ts @@ -65,9 +65,9 @@ test('Should record a transaction for route with parameters', async ({ request } 'express.name': 'query', 'express.type': 'middleware', 'sentry.origin': 'auto.http.express', - 'sentry.op': 'middleware.express', + 'sentry.op': 'middleware', }, - op: 'middleware.express', + op: 'middleware', description: 'query', origin: 'auto.http.express', parent_span_id: expect.stringMatching(/[a-f0-9]{16}/), @@ -83,9 +83,9 @@ test('Should record a transaction for route with parameters', async ({ request } 'express.name': 'expressInit', 'express.type': 'middleware', 'sentry.origin': 'auto.http.express', - 'sentry.op': 'middleware.express', + 'sentry.op': 'middleware', }, - op: 'middleware.express', + op: 'middleware', description: 'expressInit', origin: 'auto.http.express', parent_span_id: expect.stringMatching(/[a-f0-9]{16}/), @@ -102,9 +102,9 @@ test('Should record a transaction for route with parameters', async ({ request } 'express.type': 'request_handler', 'http.route': '/test-transaction/:param', 'sentry.origin': 'auto.http.express', - 'sentry.op': 'request_handler.express', + 'sentry.op': 'function', }, - op: 'request_handler.express', + op: 'function', description: '/test-transaction/:param', origin: 'auto.http.express', parent_span_id: expect.stringMatching(/[a-f0-9]{16}/), diff --git a/dev-packages/e2e-tests/test-applications/node-express-esm-loader/tests/server.test.ts b/dev-packages/e2e-tests/test-applications/node-express-esm-loader/tests/server.test.ts index d51e9639696a..9a51236368db 100644 --- a/dev-packages/e2e-tests/test-applications/node-express-esm-loader/tests/server.test.ts +++ b/dev-packages/e2e-tests/test-applications/node-express-esm-loader/tests/server.test.ts @@ -65,9 +65,9 @@ test('Should record a transaction for route with parameters', async ({ request } 'express.name': 'query', 'express.type': 'middleware', 'sentry.origin': 'auto.http.express', - 'sentry.op': 'middleware.express', + 'sentry.op': 'middleware', }, - op: 'middleware.express', + op: 'middleware', description: 'query', origin: 'auto.http.express', parent_span_id: expect.stringMatching(/[a-f0-9]{16}/), @@ -83,9 +83,9 @@ test('Should record a transaction for route with parameters', async ({ request } 'express.name': 'expressInit', 'express.type': 'middleware', 'sentry.origin': 'auto.http.express', - 'sentry.op': 'middleware.express', + 'sentry.op': 'middleware', }, - op: 'middleware.express', + op: 'middleware', description: 'expressInit', origin: 'auto.http.express', parent_span_id: expect.stringMatching(/[a-f0-9]{16}/), @@ -102,9 +102,9 @@ test('Should record a transaction for route with parameters', async ({ request } 'express.type': 'request_handler', 'http.route': '/test-transaction/:param', 'sentry.origin': 'auto.http.express', - 'sentry.op': 'request_handler.express', + 'sentry.op': 'function', }, - op: 'request_handler.express', + op: 'function', description: '/test-transaction/:param', origin: 'auto.http.express', parent_span_id: expect.stringMatching(/[a-f0-9]{16}/), diff --git a/dev-packages/e2e-tests/test-applications/node-express-esm-preload/tests/server.test.ts b/dev-packages/e2e-tests/test-applications/node-express-esm-preload/tests/server.test.ts index fb089b27b5f0..266b545329d5 100644 --- a/dev-packages/e2e-tests/test-applications/node-express-esm-preload/tests/server.test.ts +++ b/dev-packages/e2e-tests/test-applications/node-express-esm-preload/tests/server.test.ts @@ -65,9 +65,9 @@ test('Should record a transaction for route with parameters', async ({ request } 'express.name': 'query', 'express.type': 'middleware', 'sentry.origin': 'auto.http.express', - 'sentry.op': 'middleware.express', + 'sentry.op': 'middleware', }, - op: 'middleware.express', + op: 'middleware', description: 'query', origin: 'auto.http.express', parent_span_id: expect.stringMatching(/[a-f0-9]{16}/), @@ -83,9 +83,9 @@ test('Should record a transaction for route with parameters', async ({ request } 'express.name': 'expressInit', 'express.type': 'middleware', 'sentry.origin': 'auto.http.express', - 'sentry.op': 'middleware.express', + 'sentry.op': 'middleware', }, - op: 'middleware.express', + op: 'middleware', description: 'expressInit', origin: 'auto.http.express', parent_span_id: expect.stringMatching(/[a-f0-9]{16}/), @@ -102,9 +102,9 @@ test('Should record a transaction for route with parameters', async ({ request } 'express.type': 'request_handler', 'http.route': '/test-transaction/:param', 'sentry.origin': 'auto.http.express', - 'sentry.op': 'request_handler.express', + 'sentry.op': 'function', }, - op: 'request_handler.express', + op: 'function', description: '/test-transaction/:param', origin: 'auto.http.express', parent_span_id: expect.stringMatching(/[a-f0-9]{16}/), diff --git a/dev-packages/e2e-tests/test-applications/node-express-orchestrion-cjs/tests/transactions.test.ts b/dev-packages/e2e-tests/test-applications/node-express-orchestrion-cjs/tests/transactions.test.ts index 9ed354830fc8..44070eaf84a9 100644 --- a/dev-packages/e2e-tests/test-applications/node-express-orchestrion-cjs/tests/transactions.test.ts +++ b/dev-packages/e2e-tests/test-applications/node-express-orchestrion-cjs/tests/transactions.test.ts @@ -86,13 +86,13 @@ test('Sends an API route transaction', async ({ baseURL }) => { expect(spans).toContainEqual({ data: { 'sentry.origin': 'auto.http.express', - 'sentry.op': 'request_handler.express', + 'sentry.op': 'function', 'http.route': '/test-transaction', 'express.name': '/test-transaction', 'express.type': 'request_handler', }, description: '/test-transaction', - op: 'request_handler.express', + op: 'function', origin: 'auto.http.express', parent_span_id: expect.stringMatching(/[a-f0-9]{16}/), span_id: expect.stringMatching(/[a-f0-9]{16}/), diff --git a/dev-packages/e2e-tests/test-applications/node-express-orchestrion/tests/transactions.test.ts b/dev-packages/e2e-tests/test-applications/node-express-orchestrion/tests/transactions.test.ts index 75b9ffe2f716..fee291536d64 100644 --- a/dev-packages/e2e-tests/test-applications/node-express-orchestrion/tests/transactions.test.ts +++ b/dev-packages/e2e-tests/test-applications/node-express-orchestrion/tests/transactions.test.ts @@ -86,13 +86,13 @@ test('Sends an API route transaction', async ({ baseURL }) => { expect(spans).toContainEqual({ data: { 'sentry.origin': 'auto.http.express', - 'sentry.op': 'request_handler.express', + 'sentry.op': 'function', 'http.route': '/test-transaction', 'express.name': '/test-transaction', 'express.type': 'request_handler', }, description: '/test-transaction', - op: 'request_handler.express', + op: 'function', origin: 'auto.http.express', parent_span_id: expect.stringMatching(/[a-f0-9]{16}/), span_id: expect.stringMatching(/[a-f0-9]{16}/), diff --git a/dev-packages/e2e-tests/test-applications/node-express-v5/tests/transactions.test.ts b/dev-packages/e2e-tests/test-applications/node-express-v5/tests/transactions.test.ts index dbe870bd4c16..089832650ac6 100644 --- a/dev-packages/e2e-tests/test-applications/node-express-v5/tests/transactions.test.ts +++ b/dev-packages/e2e-tests/test-applications/node-express-v5/tests/transactions.test.ts @@ -86,13 +86,13 @@ test('Sends an API route transaction', async ({ baseURL }) => { expect(spans).toContainEqual({ data: { 'sentry.origin': 'auto.http.express', - 'sentry.op': 'request_handler.express', + 'sentry.op': 'function', 'http.route': '/test-transaction', 'express.name': '/test-transaction', 'express.type': 'request_handler', }, description: '/test-transaction', - op: 'request_handler.express', + op: 'function', origin: 'auto.http.express', parent_span_id: expect.stringMatching(/[a-f0-9]{16}/), span_id: expect.stringMatching(/[a-f0-9]{16}/), diff --git a/dev-packages/e2e-tests/test-applications/node-express/tests/transactions.test.ts b/dev-packages/e2e-tests/test-applications/node-express/tests/transactions.test.ts index 48b7cc58aed7..0d0081e22f71 100644 --- a/dev-packages/e2e-tests/test-applications/node-express/tests/transactions.test.ts +++ b/dev-packages/e2e-tests/test-applications/node-express/tests/transactions.test.ts @@ -86,12 +86,12 @@ test('Sends an API route transaction', async ({ baseURL }) => { expect(spans).toContainEqual({ data: { 'sentry.origin': 'auto.http.express', - 'sentry.op': 'middleware.express', + 'sentry.op': 'middleware', 'express.name': 'query', 'express.type': 'middleware', }, description: 'query', - op: 'middleware.express', + op: 'middleware', origin: 'auto.http.express', parent_span_id: expect.stringMatching(/[a-f0-9]{16}/), span_id: expect.stringMatching(/[a-f0-9]{16}/), @@ -104,12 +104,12 @@ test('Sends an API route transaction', async ({ baseURL }) => { expect(spans).toContainEqual({ data: { 'sentry.origin': 'auto.http.express', - 'sentry.op': 'middleware.express', + 'sentry.op': 'middleware', 'express.name': 'expressInit', 'express.type': 'middleware', }, description: 'expressInit', - op: 'middleware.express', + op: 'middleware', origin: 'auto.http.express', parent_span_id: expect.stringMatching(/[a-f0-9]{16}/), span_id: expect.stringMatching(/[a-f0-9]{16}/), @@ -122,13 +122,13 @@ test('Sends an API route transaction', async ({ baseURL }) => { expect(spans).toContainEqual({ data: { 'sentry.origin': 'auto.http.express', - 'sentry.op': 'request_handler.express', + 'sentry.op': 'function', 'http.route': '/test-transaction', 'express.name': '/test-transaction', 'express.type': 'request_handler', }, description: '/test-transaction', - op: 'request_handler.express', + op: 'function', origin: 'auto.http.express', parent_span_id: expect.stringMatching(/[a-f0-9]{16}/), span_id: expect.stringMatching(/[a-f0-9]{16}/), @@ -162,12 +162,12 @@ test('Sends an API route transaction for an errored route', async ({ baseURL }) expect(spans).toContainEqual({ data: { 'sentry.origin': 'auto.http.express', - 'sentry.op': 'middleware.express', + 'sentry.op': 'middleware', 'express.name': 'query', 'express.type': 'middleware', }, description: 'query', - op: 'middleware.express', + op: 'middleware', origin: 'auto.http.express', parent_span_id: expect.stringMatching(/[a-f0-9]{16}/), span_id: expect.stringMatching(/[a-f0-9]{16}/), @@ -180,12 +180,12 @@ test('Sends an API route transaction for an errored route', async ({ baseURL }) expect(spans).toContainEqual({ data: { 'sentry.origin': 'auto.http.express', - 'sentry.op': 'middleware.express', + 'sentry.op': 'middleware', 'express.name': 'expressInit', 'express.type': 'middleware', }, description: 'expressInit', - op: 'middleware.express', + op: 'middleware', origin: 'auto.http.express', parent_span_id: expect.stringMatching(/[a-f0-9]{16}/), span_id: expect.stringMatching(/[a-f0-9]{16}/), @@ -198,14 +198,14 @@ test('Sends an API route transaction for an errored route', async ({ baseURL }) expect(spans).toContainEqual({ data: { 'sentry.origin': 'auto.http.express', - 'sentry.op': 'request_handler.express', + 'sentry.op': 'function', 'http.route': '/test-exception/:id', 'express.name': '/test-exception/:id', 'express.type': 'request_handler', 'error.type': 'Error', }, description: '/test-exception/:id', - op: 'request_handler.express', + op: 'function', origin: 'auto.http.express', parent_span_id: expect.stringMatching(/[a-f0-9]{16}/), span_id: expect.stringMatching(/[a-f0-9]{16}/), diff --git a/dev-packages/e2e-tests/test-applications/node-fastify-3/tests/transactions.test.ts b/dev-packages/e2e-tests/test-applications/node-fastify-3/tests/transactions.test.ts index 2912f27eec34..06756c5e7f66 100644 --- a/dev-packages/e2e-tests/test-applications/node-fastify-3/tests/transactions.test.ts +++ b/dev-packages/e2e-tests/test-applications/node-fastify-3/tests/transactions.test.ts @@ -75,7 +75,7 @@ test.skip('Sends an API route transaction', async ({ baseURL }) => { expect(spans).toContainEqual({ data: { 'sentry.origin': 'auto.http.otel.fastify', - 'sentry.op': 'request_handler.fastify', + 'sentry.op': 'function', 'fastify.root': '@sentry/instrumentation-fastify', 'http.request.method': 'GET', 'url.path': '/test-transaction', @@ -83,7 +83,7 @@ test.skip('Sends an API route transaction', async ({ baseURL }) => { 'http.response.status_code': 200, }, description: 'GET /test-transaction', - op: 'request_handler.fastify', + op: 'function', parent_span_id: expect.stringMatching(/[a-f0-9]{16}/), span_id: expect.stringMatching(/[a-f0-9]{16}/), start_timestamp: expect.any(Number), @@ -97,12 +97,12 @@ test.skip('Sends an API route transaction', async ({ baseURL }) => { expect(spans).toContainEqual({ data: expect.objectContaining({ 'sentry.origin': 'auto.http.otel.fastify', - 'sentry.op': 'request_handler.fastify', + 'sentry.op': 'function', 'fastify.type': expect.stringMatching(/request[-_]handler/), 'http.route': '/test-transaction', }), description: expect.stringContaining('sentry-fastify-error-handler'), - op: 'request_handler.fastify', + op: 'function', parent_span_id: expect.stringMatching(/[a-f0-9]{16}/), span_id: expect.stringMatching(/[a-f0-9]{16}/), start_timestamp: expect.any(Number), diff --git a/dev-packages/e2e-tests/test-applications/node-fastify-4/tests/transactions.test.ts b/dev-packages/e2e-tests/test-applications/node-fastify-4/tests/transactions.test.ts index 8c0017620628..054193da1a84 100644 --- a/dev-packages/e2e-tests/test-applications/node-fastify-4/tests/transactions.test.ts +++ b/dev-packages/e2e-tests/test-applications/node-fastify-4/tests/transactions.test.ts @@ -70,11 +70,11 @@ test('Sends an API route transaction', async ({ baseURL }) => { 'fastify.type': 'hook', 'hook.callback.name': 'anonymous', 'hook.name': 'fastify -> @sentry/instrumentation-fastify - onRequest', - 'sentry.op': 'hook.fastify', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.http.otel.fastify', }, description: '@sentry/instrumentation-fastify - onRequest', - op: 'hook.fastify', + op: 'middleware', parent_span_id: expect.stringMatching(/[a-f0-9]{16}/), span_id: expect.stringMatching(/[a-f0-9]{16}/), start_timestamp: expect.any(Number), diff --git a/dev-packages/e2e-tests/test-applications/node-fastify-5/tests/transactions.test.ts b/dev-packages/e2e-tests/test-applications/node-fastify-5/tests/transactions.test.ts index d820e157c36e..6fafa28a162b 100644 --- a/dev-packages/e2e-tests/test-applications/node-fastify-5/tests/transactions.test.ts +++ b/dev-packages/e2e-tests/test-applications/node-fastify-5/tests/transactions.test.ts @@ -70,11 +70,11 @@ test('Sends an API route transaction', async ({ baseURL }) => { 'fastify.type': 'hook', 'hook.callback.name': 'anonymous', 'hook.name': 'fastify -> @sentry/instrumentation-fastify - onRequest', - 'sentry.op': 'hook.fastify', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.http.otel.fastify', }, description: '@sentry/instrumentation-fastify - onRequest', - op: 'hook.fastify', + op: 'middleware', parent_span_id: expect.stringMatching(/[a-f0-9]{16}/), span_id: expect.stringMatching(/[a-f0-9]{16}/), start_timestamp: expect.any(Number), diff --git a/dev-packages/e2e-tests/test-applications/node-koa/tests/transactions.test.ts b/dev-packages/e2e-tests/test-applications/node-koa/tests/transactions.test.ts index 7509c87bf4e8..e42d821e63d3 100644 --- a/dev-packages/e2e-tests/test-applications/node-koa/tests/transactions.test.ts +++ b/dev-packages/e2e-tests/test-applications/node-koa/tests/transactions.test.ts @@ -67,11 +67,11 @@ test('Sends an API route transaction', async ({ baseURL }) => { 'koa.name': 'bodyParser', 'code.function.name': 'bodyParser', 'koa.type': 'middleware', - 'sentry.op': 'middleware.koa', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.http.koa', }, description: 'bodyParser', - op: 'middleware.koa', + op: 'middleware', origin: 'auto.http.koa', parent_span_id: expect.stringMatching(/[a-f0-9]{16}/), span_id: expect.stringMatching(/[a-f0-9]{16}/), @@ -86,9 +86,9 @@ test('Sends an API route transaction', async ({ baseURL }) => { 'code.function.name': 'middleware', 'koa.type': 'middleware', 'sentry.origin': 'auto.http.koa', - 'sentry.op': 'middleware.koa', + 'sentry.op': 'middleware', }, - op: 'middleware.koa', + op: 'middleware', origin: 'auto.http.koa', description: 'middleware', parent_span_id: expect.stringMatching(/[a-f0-9]{16}/), diff --git a/dev-packages/e2e-tests/test-applications/nuxt-3/tests/middleware.test.ts b/dev-packages/e2e-tests/test-applications/nuxt-3/tests/middleware.test.ts index 7cb3c84e9050..0ebd88e2ed18 100644 --- a/dev-packages/e2e-tests/test-applications/nuxt-3/tests/middleware.test.ts +++ b/dev-packages/e2e-tests/test-applications/nuxt-3/tests/middleware.test.ts @@ -17,7 +17,7 @@ test.describe('Server Middleware Instrumentation', () => { const serverTxnEvent = await serverTxnEventPromise; // Verify that we have spans for each middleware - const middlewareSpans = serverTxnEvent.spans?.filter(span => span.op === 'middleware.nuxt') || []; + const middlewareSpans = serverTxnEvent.spans?.filter(span => span.op === 'middleware') || []; // 3 simple + 3 hooks (onRequest+handler+onBeforeResponse) + 5 array hooks (2 onRequest + 1 handler + 2 onBeforeResponse) expect(middlewareSpans).toHaveLength(11); @@ -41,9 +41,9 @@ test.describe('Server Middleware Instrumentation', () => { [firstMiddlewareSpan, secondMiddlewareSpan, authMiddlewareSpan].forEach(span => { expect(span).toEqual( expect.objectContaining({ - op: 'middleware.nuxt', + op: 'middleware', data: expect.objectContaining({ - 'sentry.op': 'middleware.nuxt', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.middleware.nuxt', 'sentry.source': 'custom', 'http.request.method': 'GET', @@ -76,7 +76,7 @@ test.describe('Server Middleware Instrumentation', () => { await request.get('/api/middleware-test'); const serverTxnEvent = await serverTxnEventPromise; - const middlewareSpans = serverTxnEvent.spans?.filter(span => span.op === 'middleware.nuxt') || []; + const middlewareSpans = serverTxnEvent.spans?.filter(span => span.op === 'middleware') || []; // All middleware spans should be children of the main transaction middlewareSpans.forEach(span => { @@ -103,7 +103,7 @@ test.describe('Server Middleware Instrumentation', () => { // Find the auth middleware span const authMiddlewareSpan = serverTxnEvent.spans?.find( - span => span.op === 'middleware.nuxt' && span.data?.['nuxt.middleware.name'] === '03.auth', + span => span.op === 'middleware' && span.data?.['nuxt.middleware.name'] === '03.auth', ); expect(authMiddlewareSpan).toBeDefined(); @@ -141,7 +141,7 @@ test.describe('Server Middleware Instrumentation', () => { expect(response.status()).toBe(200); const serverTxnEvent = await serverTxnEventPromise; - const middlewareSpans = serverTxnEvent.spans?.filter(span => span.op === 'middleware.nuxt') || []; + const middlewareSpans = serverTxnEvent.spans?.filter(span => span.op === 'middleware') || []; // Find spans for the hooks middleware const hooksSpans = middlewareSpans.filter(span => span.data?.['nuxt.middleware.name'] === '04.hooks'); @@ -191,7 +191,7 @@ test.describe('Server Middleware Instrumentation', () => { expect(response.status()).toBe(200); const serverTxnEvent = await serverTxnEventPromise; - const middlewareSpans = serverTxnEvent.spans?.filter(span => span.op === 'middleware.nuxt') || []; + const middlewareSpans = serverTxnEvent.spans?.filter(span => span.op === 'middleware') || []; // Find spans for the array hooks middleware const arrayHooksSpans = middlewareSpans.filter(span => span.data?.['nuxt.middleware.name'] === '05.array-hooks'); @@ -255,7 +255,7 @@ test.describe('Server Middleware Instrumentation', () => { // Find the onRequest span that should have error status const onRequestSpan = serverTxnEvent.spans?.find( span => - span.op === 'middleware.nuxt' && + span.op === 'middleware' && span.data?.['nuxt.middleware.name'] === '04.hooks' && span.data?.['nuxt.middleware.hook.name'] === 'onRequest', ); @@ -283,7 +283,7 @@ test.describe('Server Middleware Instrumentation', () => { // Find the onBeforeResponse span that should have error status const onBeforeResponseSpan = serverTxnEvent.spans?.find( span => - span.op === 'middleware.nuxt' && + span.op === 'middleware' && span.data?.['nuxt.middleware.name'] === '04.hooks' && span.data?.['nuxt.middleware.hook.name'] === 'onBeforeResponse', ); @@ -311,7 +311,7 @@ test.describe('Server Middleware Instrumentation', () => { // Find the second onRequest span that should have error status const onRequest1Span = serverTxnEvent.spans?.find( span => - span.op === 'middleware.nuxt' && + span.op === 'middleware' && span.data?.['nuxt.middleware.name'] === '05.array-hooks' && span.data?.['nuxt.middleware.hook.name'] === 'onRequest' && span.data?.['nuxt.middleware.hook.index'] === 1, @@ -324,7 +324,7 @@ test.describe('Server Middleware Instrumentation', () => { // Verify the first onRequest handler still executed successfully const onRequest0Span = serverTxnEvent.spans?.find( span => - span.op === 'middleware.nuxt' && + span.op === 'middleware' && span.data?.['nuxt.middleware.name'] === '05.array-hooks' && span.data?.['nuxt.middleware.hook.name'] === 'onRequest' && span.data?.['nuxt.middleware.hook.index'] === 0, diff --git a/dev-packages/e2e-tests/test-applications/nuxt-4/tests/middleware.test.ts b/dev-packages/e2e-tests/test-applications/nuxt-4/tests/middleware.test.ts index 005330c01fee..b24775e8db63 100644 --- a/dev-packages/e2e-tests/test-applications/nuxt-4/tests/middleware.test.ts +++ b/dev-packages/e2e-tests/test-applications/nuxt-4/tests/middleware.test.ts @@ -17,7 +17,7 @@ test.describe('Server Middleware Instrumentation', () => { const serverTxnEvent = await serverTxnEventPromise; // Verify that we have spans for each middleware - const middlewareSpans = serverTxnEvent.spans?.filter(span => span.op === 'middleware.nuxt') || []; + const middlewareSpans = serverTxnEvent.spans?.filter(span => span.op === 'middleware') || []; // 3 simple + 3 hooks (onRequest+handler+onBeforeResponse) + 5 array hooks (2 onRequest + 1 handler + 2 onBeforeResponse expect(middlewareSpans).toHaveLength(11); @@ -41,9 +41,9 @@ test.describe('Server Middleware Instrumentation', () => { [firstMiddlewareSpan, secondMiddlewareSpan, authMiddlewareSpan].forEach(span => { expect(span).toEqual( expect.objectContaining({ - op: 'middleware.nuxt', + op: 'middleware', data: expect.objectContaining({ - 'sentry.op': 'middleware.nuxt', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.middleware.nuxt', 'sentry.source': 'custom', 'http.request.method': 'GET', @@ -76,7 +76,7 @@ test.describe('Server Middleware Instrumentation', () => { await request.get('/api/middleware-test'); const serverTxnEvent = await serverTxnEventPromise; - const middlewareSpans = serverTxnEvent.spans?.filter(span => span.op === 'middleware.nuxt') || []; + const middlewareSpans = serverTxnEvent.spans?.filter(span => span.op === 'middleware') || []; // All middleware spans should be children of the main transaction middlewareSpans.forEach(span => { @@ -103,7 +103,7 @@ test.describe('Server Middleware Instrumentation', () => { // Find the auth middleware span const authMiddlewareSpan = serverTxnEvent.spans?.find( - span => span.op === 'middleware.nuxt' && span.data?.['nuxt.middleware.name'] === '03.auth', + span => span.op === 'middleware' && span.data?.['nuxt.middleware.name'] === '03.auth', ); expect(authMiddlewareSpan).toBeDefined(); @@ -137,7 +137,7 @@ test.describe('Server Middleware Instrumentation', () => { expect(response.status()).toBe(200); const serverTxnEvent = await serverTxnEventPromise; - const middlewareSpans = serverTxnEvent.spans?.filter(span => span.op === 'middleware.nuxt') || []; + const middlewareSpans = serverTxnEvent.spans?.filter(span => span.op === 'middleware') || []; // Find spans for the hooks middleware const hooksSpans = middlewareSpans.filter(span => span.data?.['nuxt.middleware.name'] === '04.hooks'); @@ -187,7 +187,7 @@ test.describe('Server Middleware Instrumentation', () => { expect(response.status()).toBe(200); const serverTxnEvent = await serverTxnEventPromise; - const middlewareSpans = serverTxnEvent.spans?.filter(span => span.op === 'middleware.nuxt') || []; + const middlewareSpans = serverTxnEvent.spans?.filter(span => span.op === 'middleware') || []; // Find spans for the array hooks middleware const arrayHooksSpans = middlewareSpans.filter(span => span.data?.['nuxt.middleware.name'] === '05.array-hooks'); @@ -251,7 +251,7 @@ test.describe('Server Middleware Instrumentation', () => { // Find the onRequest span that should have error status const onRequestSpan = serverTxnEvent.spans?.find( span => - span.op === 'middleware.nuxt' && + span.op === 'middleware' && span.data?.['nuxt.middleware.name'] === '04.hooks' && span.data?.['nuxt.middleware.hook.name'] === 'onRequest', ); @@ -279,7 +279,7 @@ test.describe('Server Middleware Instrumentation', () => { // Find the onBeforeResponse span that should have error status const onBeforeResponseSpan = serverTxnEvent.spans?.find( span => - span.op === 'middleware.nuxt' && + span.op === 'middleware' && span.data?.['nuxt.middleware.name'] === '04.hooks' && span.data?.['nuxt.middleware.hook.name'] === 'onBeforeResponse', ); @@ -307,7 +307,7 @@ test.describe('Server Middleware Instrumentation', () => { // Find the second onRequest span that should have error status const onRequest1Span = serverTxnEvent.spans?.find( span => - span.op === 'middleware.nuxt' && + span.op === 'middleware' && span.data?.['nuxt.middleware.name'] === '05.array-hooks' && span.data?.['nuxt.middleware.hook.name'] === 'onRequest' && span.data?.['nuxt.middleware.hook.index'] === 1, @@ -320,7 +320,7 @@ test.describe('Server Middleware Instrumentation', () => { // Verify the first onRequest handler still executed successfully const onRequest0Span = serverTxnEvent.spans?.find( span => - span.op === 'middleware.nuxt' && + span.op === 'middleware' && span.data?.['nuxt.middleware.name'] === '05.array-hooks' && span.data?.['nuxt.middleware.hook.name'] === 'onRequest' && span.data?.['nuxt.middleware.hook.index'] === 0, diff --git a/dev-packages/e2e-tests/test-applications/nuxt-5/tests/middleware.test.ts b/dev-packages/e2e-tests/test-applications/nuxt-5/tests/middleware.test.ts index 71ef433b6c07..ff4cdf76157b 100644 --- a/dev-packages/e2e-tests/test-applications/nuxt-5/tests/middleware.test.ts +++ b/dev-packages/e2e-tests/test-applications/nuxt-5/tests/middleware.test.ts @@ -18,7 +18,7 @@ test.describe('Server Middleware Instrumentation', () => { const serverTxnEvent = await serverTxnEventPromise; // Verify that we have spans for each middleware - const middlewareSpans = serverTxnEvent.spans?.filter(span => span.op === 'middleware.nuxt') || []; + const middlewareSpans = serverTxnEvent.spans?.filter(span => span.op === 'middleware') || []; // 3 simple + 2 hooks (middleware+handler) + 3 array hooks (2 middleware + 1 handler) expect(middlewareSpans).toHaveLength(8); @@ -42,9 +42,9 @@ test.describe('Server Middleware Instrumentation', () => { [firstMiddlewareSpan, secondMiddlewareSpan, authMiddlewareSpan].forEach(span => { expect(span).toEqual( expect.objectContaining({ - op: 'middleware.nuxt', + op: 'middleware', data: expect.objectContaining({ - 'sentry.op': 'middleware.nuxt', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.middleware.nuxt', 'sentry.source': 'custom', 'http.request.method': 'GET', @@ -77,7 +77,7 @@ test.describe('Server Middleware Instrumentation', () => { await request.get('/api/middleware-test'); const serverTxnEvent = await serverTxnEventPromise; - const middlewareSpans = serverTxnEvent.spans?.filter(span => span.op === 'middleware.nuxt') || []; + const middlewareSpans = serverTxnEvent.spans?.filter(span => span.op === 'middleware') || []; // All middleware spans should be children of the main transaction middlewareSpans.forEach(span => { @@ -104,7 +104,7 @@ test.describe('Server Middleware Instrumentation', () => { // Find the auth middleware span const authMiddlewareSpan = serverTxnEvent.spans?.find( - span => span.op === 'middleware.nuxt' && span.data?.['nuxt.middleware.name'] === '03.auth', + span => span.op === 'middleware' && span.data?.['nuxt.middleware.name'] === '03.auth', ); expect(authMiddlewareSpan).toBeDefined(); @@ -138,7 +138,7 @@ test.describe('Server Middleware Instrumentation', () => { expect(response.status()).toBe(200); const serverTxnEvent = await serverTxnEventPromise; - const middlewareSpans = serverTxnEvent.spans?.filter(span => span.op === 'middleware.nuxt') || []; + const middlewareSpans = serverTxnEvent.spans?.filter(span => span.op === 'middleware') || []; // Find spans for the hooks middleware const hooksSpans = middlewareSpans.filter(span => span.data?.['nuxt.middleware.name'] === '04.hooks'); @@ -181,7 +181,7 @@ test.describe('Server Middleware Instrumentation', () => { expect(response.status()).toBe(200); const serverTxnEvent = await serverTxnEventPromise; - const middlewareSpans = serverTxnEvent.spans?.filter(span => span.op === 'middleware.nuxt') || []; + const middlewareSpans = serverTxnEvent.spans?.filter(span => span.op === 'middleware') || []; // Find spans for the array hooks middleware const arrayHooksSpans = middlewareSpans.filter(span => span.data?.['nuxt.middleware.name'] === '05.array-hooks'); @@ -232,7 +232,7 @@ test.describe('Server Middleware Instrumentation', () => { // Find the middleware span that should have error status const middlewareSpan = serverTxnEvent.spans?.find( span => - span.op === 'middleware.nuxt' && + span.op === 'middleware' && span.data?.['nuxt.middleware.name'] === '04.hooks' && span.data?.['nuxt.middleware.hook.name'] === 'middleware', ); @@ -260,7 +260,7 @@ test.describe('Server Middleware Instrumentation', () => { // Find the second middleware span that should have error status const middleware1Span = serverTxnEvent.spans?.find( span => - span.op === 'middleware.nuxt' && + span.op === 'middleware' && span.data?.['nuxt.middleware.name'] === '05.array-hooks' && span.data?.['nuxt.middleware.hook.name'] === 'middleware' && span.data?.['nuxt.middleware.hook.index'] === 1, @@ -273,7 +273,7 @@ test.describe('Server Middleware Instrumentation', () => { // Verify the first middleware handler still executed successfully const middleware0Span = serverTxnEvent.spans?.find( span => - span.op === 'middleware.nuxt' && + span.op === 'middleware' && span.data?.['nuxt.middleware.name'] === '05.array-hooks' && span.data?.['nuxt.middleware.hook.name'] === 'middleware' && span.data?.['nuxt.middleware.hook.index'] === 0, diff --git a/dev-packages/e2e-tests/test-applications/react-router-7-framework/tests/performance/trace-propagation.test.ts b/dev-packages/e2e-tests/test-applications/react-router-7-framework/tests/performance/trace-propagation.test.ts index e9b2c9409154..0a4bc17f622b 100644 --- a/dev-packages/e2e-tests/test-applications/react-router-7-framework/tests/performance/trace-propagation.test.ts +++ b/dev-packages/e2e-tests/test-applications/react-router-7-framework/tests/performance/trace-propagation.test.ts @@ -32,7 +32,7 @@ test.describe('Trace propagation', () => { expect(clientTx.contexts?.trace?.trace_id).toEqual(serverTx.contexts?.trace?.trace_id); - const requestHandlerSpan = serverTx.spans?.find(span => span.op === 'request_handler.express'); + const requestHandlerSpan = serverTx.spans?.find(span => span.op === 'function'); expect(requestHandlerSpan).toBeDefined(); expect(clientTx.contexts?.trace?.parent_span_id).toBe(requestHandlerSpan?.span_id); diff --git a/dev-packages/e2e-tests/test-applications/react-router-8-framework/tests/performance/trace-propagation.test.ts b/dev-packages/e2e-tests/test-applications/react-router-8-framework/tests/performance/trace-propagation.test.ts index 4ce133514ce3..9f356007cb6e 100644 --- a/dev-packages/e2e-tests/test-applications/react-router-8-framework/tests/performance/trace-propagation.test.ts +++ b/dev-packages/e2e-tests/test-applications/react-router-8-framework/tests/performance/trace-propagation.test.ts @@ -32,7 +32,7 @@ test.describe('Trace propagation', () => { expect(clientTx.contexts?.trace?.trace_id).toEqual(serverTx.contexts?.trace?.trace_id); - const requestHandlerSpan = serverTx.spans?.find(span => span.op === 'request_handler.express'); + const requestHandlerSpan = serverTx.spans?.find(span => span.op === 'function'); expect(requestHandlerSpan).toBeDefined(); expect(clientTx.contexts?.trace?.parent_span_id).toBe(requestHandlerSpan?.span_id); diff --git a/dev-packages/e2e-tests/test-applications/tanstackstart-react/tests/middleware.test.ts b/dev-packages/e2e-tests/test-applications/tanstackstart-react/tests/middleware.test.ts index ab31ce5e022a..c5c1961c0413 100644 --- a/dev-packages/e2e-tests/test-applications/tanstackstart-react/tests/middleware.test.ts +++ b/dev-packages/e2e-tests/test-applications/tanstackstart-react/tests/middleware.test.ts @@ -38,7 +38,7 @@ test('Sends spans for multiple middlewares and verifies they are siblings under expect(serverFnMiddlewareSpan).toEqual( expect.objectContaining({ description: 'serverFnMiddleware', - op: 'middleware.tanstackstart', + op: 'middleware', origin: 'auto.middleware.tanstackstart', status: 'ok', }), @@ -46,7 +46,7 @@ test('Sends spans for multiple middlewares and verifies they are siblings under expect(globalFunctionMiddlewareSpan).toEqual( expect.objectContaining({ description: 'globalFunctionMiddleware', - op: 'middleware.tanstackstart', + op: 'middleware', origin: 'auto.middleware.tanstackstart', status: 'ok', }), @@ -77,7 +77,7 @@ test('Sends spans for global function middleware', async ({ page }) => { expect.arrayContaining([ expect.objectContaining({ description: 'globalFunctionMiddleware', - op: 'middleware.tanstackstart', + op: 'middleware', origin: 'auto.middleware.tanstackstart', status: 'ok', }), @@ -104,7 +104,7 @@ test('Sends spans for global request middleware', async ({ page }) => { expect.arrayContaining([ expect.objectContaining({ description: 'globalRequestMiddleware', - op: 'middleware.tanstackstart', + op: 'middleware', origin: 'auto.middleware.tanstackstart', status: 'ok', }), @@ -131,7 +131,7 @@ test('Sends spans for server route request middleware', async ({ page }) => { expect.arrayContaining([ expect.objectContaining({ description: 'serverRouteRequestMiddleware', - op: 'middleware.tanstackstart', + op: 'middleware', origin: 'auto.middleware.tanstackstart', status: 'ok', }), @@ -160,7 +160,7 @@ test('Sends span for middleware that returns early without calling next()', asyn expect.arrayContaining([ expect.objectContaining({ description: 'earlyReturnMiddleware', - op: 'middleware.tanstackstart', + op: 'middleware', origin: 'auto.middleware.tanstackstart', status: 'ok', }), @@ -189,7 +189,7 @@ test('Sends span for middleware that throws an error', async ({ page }) => { expect.arrayContaining([ expect.objectContaining({ description: 'errorMiddleware', - op: 'middleware.tanstackstart', + op: 'middleware', origin: 'auto.middleware.tanstackstart', }), ]), diff --git a/dev-packages/e2e-tests/test-applications/tsx-express/tests/transactions.test.ts b/dev-packages/e2e-tests/test-applications/tsx-express/tests/transactions.test.ts index 916cc4bb3d7b..0fbe6275925e 100644 --- a/dev-packages/e2e-tests/test-applications/tsx-express/tests/transactions.test.ts +++ b/dev-packages/e2e-tests/test-applications/tsx-express/tests/transactions.test.ts @@ -72,12 +72,12 @@ test('Sends an API route transaction', async ({ baseURL }) => { expect(spans).toContainEqual({ data: { 'sentry.origin': 'auto.http.express', - 'sentry.op': 'middleware.express', + 'sentry.op': 'middleware', 'express.name': 'query', 'express.type': 'middleware', }, description: 'query', - op: 'middleware.express', + op: 'middleware', origin: 'auto.http.express', parent_span_id: expect.stringMatching(/[a-f0-9]{16}/), span_id: expect.stringMatching(/[a-f0-9]{16}/), @@ -90,12 +90,12 @@ test('Sends an API route transaction', async ({ baseURL }) => { expect(spans).toContainEqual({ data: { 'sentry.origin': 'auto.http.express', - 'sentry.op': 'middleware.express', + 'sentry.op': 'middleware', 'express.name': 'expressInit', 'express.type': 'middleware', }, description: 'expressInit', - op: 'middleware.express', + op: 'middleware', origin: 'auto.http.express', parent_span_id: expect.stringMatching(/[a-f0-9]{16}/), span_id: expect.stringMatching(/[a-f0-9]{16}/), @@ -108,13 +108,13 @@ test('Sends an API route transaction', async ({ baseURL }) => { expect(spans).toContainEqual({ data: { 'sentry.origin': 'auto.http.express', - 'sentry.op': 'request_handler.express', + 'sentry.op': 'function', 'http.route': '/test-transaction', 'express.name': '/test-transaction', 'express.type': 'request_handler', }, description: '/test-transaction', - op: 'request_handler.express', + op: 'function', origin: 'auto.http.express', parent_span_id: expect.stringMatching(/[a-f0-9]{16}/), span_id: expect.stringMatching(/[a-f0-9]{16}/), @@ -148,12 +148,12 @@ test('Sends an API route transaction for an errored route', async ({ baseURL }) expect(spans).toContainEqual({ data: { 'sentry.origin': 'auto.http.express', - 'sentry.op': 'middleware.express', + 'sentry.op': 'middleware', 'express.name': 'query', 'express.type': 'middleware', }, description: 'query', - op: 'middleware.express', + op: 'middleware', origin: 'auto.http.express', parent_span_id: expect.stringMatching(/[a-f0-9]{16}/), span_id: expect.stringMatching(/[a-f0-9]{16}/), @@ -166,12 +166,12 @@ test('Sends an API route transaction for an errored route', async ({ baseURL }) expect(spans).toContainEqual({ data: { 'sentry.origin': 'auto.http.express', - 'sentry.op': 'middleware.express', + 'sentry.op': 'middleware', 'express.name': 'expressInit', 'express.type': 'middleware', }, description: 'expressInit', - op: 'middleware.express', + op: 'middleware', origin: 'auto.http.express', parent_span_id: expect.stringMatching(/[a-f0-9]{16}/), span_id: expect.stringMatching(/[a-f0-9]{16}/), @@ -184,14 +184,14 @@ test('Sends an API route transaction for an errored route', async ({ baseURL }) expect(spans).toContainEqual({ data: { 'sentry.origin': 'auto.http.express', - 'sentry.op': 'request_handler.express', + 'sentry.op': 'function', 'http.route': '/test-exception/:id', 'express.name': '/test-exception/:id', 'express.type': 'request_handler', 'error.type': 'Error', }, description: '/test-exception/:id', - op: 'request_handler.express', + op: 'function', origin: 'auto.http.express', parent_span_id: expect.stringMatching(/[a-f0-9]{16}/), span_id: expect.stringMatching(/[a-f0-9]{16}/), diff --git a/dev-packages/node-integration-tests/suites/express/tracing/test.ts b/dev-packages/node-integration-tests/suites/express/tracing/test.ts index d3df34d3bea1..231f3206e7c9 100644 --- a/dev-packages/node-integration-tests/suites/express/tracing/test.ts +++ b/dev-packages/node-integration-tests/suites/express/tracing/test.ts @@ -32,7 +32,7 @@ describe('express tracing', () => { 'express.type': 'middleware', }), description: 'corsMiddleware', - op: 'middleware.express', + op: 'middleware', origin: 'auto.http.express', }), expect.objectContaining({ @@ -41,7 +41,7 @@ describe('express tracing', () => { 'express.type': 'request_handler', }), description: '/test/express', - op: 'request_handler.express', + op: 'function', origin: 'auto.http.express', }), ]), diff --git a/dev-packages/node-integration-tests/suites/tracing/fastify/test.ts b/dev-packages/node-integration-tests/suites/tracing/fastify/test.ts index d2e1157e8294..359e1e483c28 100644 --- a/dev-packages/node-integration-tests/suites/tracing/fastify/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/fastify/test.ts @@ -17,19 +17,19 @@ describe('fastify auto-instrumentation', () => { transaction: 'GET /test-transaction', spans: expect.arrayContaining([ expect.objectContaining({ - op: 'hook.fastify', + op: 'middleware', origin: 'auto.http.otel.fastify', data: expect.objectContaining({ 'fastify.type': 'hook', - 'sentry.op': 'hook.fastify', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.http.otel.fastify', }), }), expect.objectContaining({ - op: 'request_handler.fastify', + op: 'function', origin: 'auto.http.otel.fastify', data: expect.objectContaining({ - 'sentry.op': 'request_handler.fastify', + 'sentry.op': 'function', 'sentry.origin': 'auto.http.otel.fastify', }), }), diff --git a/dev-packages/node-integration-tests/suites/tracing/hapi/scenario.mjs b/dev-packages/node-integration-tests/suites/tracing/hapi/scenario.mjs index 1aa7e8846b9f..2b7589f0f345 100644 --- a/dev-packages/node-integration-tests/suites/tracing/hapi/scenario.mjs +++ b/dev-packages/node-integration-tests/suites/tracing/hapi/scenario.mjs @@ -51,7 +51,7 @@ const run = async () => { }, }); - // Route registered via a plugin produces a `plugin.hapi` span. + // Route registered via a plugin produces a `function` op span. await server.register({ name: 'testPlugin', version: '1.0.0', diff --git a/dev-packages/node-integration-tests/suites/tracing/hapi/test.ts b/dev-packages/node-integration-tests/suites/tracing/hapi/test.ts index 7999ff26d914..bcb62aaf04be 100644 --- a/dev-packages/node-integration-tests/suites/tracing/hapi/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/hapi/test.ts @@ -58,13 +58,13 @@ describe('hapi auto-instrumentation', () => { spans: expect.arrayContaining([ expect.objectContaining({ description: 'GET /plugin-route', - op: 'plugin.hapi', + op: 'function', origin, data: expect.objectContaining({ 'http.route': '/plugin-route', 'hapi.type': 'plugin', 'hapi.plugin.name': 'testPlugin', - 'sentry.op': 'plugin.hapi', + 'sentry.op': 'function', 'sentry.origin': origin, }), }), diff --git a/dev-packages/node-integration-tests/suites/tracing/ignoreSpans-streamed/children/test.ts b/dev-packages/node-integration-tests/suites/tracing/ignoreSpans-streamed/children/test.ts index 60ef7a9f1d95..9e429c8946e0 100644 --- a/dev-packages/node-integration-tests/suites/tracing/ignoreSpans-streamed/children/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/ignoreSpans-streamed/children/test.ts @@ -31,9 +31,9 @@ describe('filtering child spans with ignoreSpans (streaming)', () => { container.items.find( item => item.name === name && item.attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP]?.value === op, ); - const queryMiddlewareSpan = getSpan('query', 'middleware.express'); - const corsMiddlewareSpan = getSpan('corsMiddleware', 'middleware.express'); - const requestHandlerSpan = getSpan('/test/express', 'request_handler.express'); + const queryMiddlewareSpan = getSpan('query', 'middleware'); + const corsMiddlewareSpan = getSpan('corsMiddleware', 'middleware'); + const requestHandlerSpan = getSpan('/test/express', 'function'); const httpServerSpan = getSpan('GET /test/express', 'http.server'); const customSpan = getSpan('custom', 'custom'); const customGrandchildSpan = getSpan('custom-grandchild', 'custom'); diff --git a/dev-packages/node-integration-tests/suites/tracing/koa/scenario.mjs b/dev-packages/node-integration-tests/suites/tracing/koa/scenario.mjs index c1c0abc772cb..945f90feb39a 100644 --- a/dev-packages/node-integration-tests/suites/tracing/koa/scenario.mjs +++ b/dev-packages/node-integration-tests/suites/tracing/koa/scenario.mjs @@ -10,7 +10,7 @@ const app = new Koa(); // Registered first so it wraps every downstream middleware/route in its try/catch. Sentry.setupKoaErrorHandler(app); -// Plain middleware -> produces a `middleware.koa` span named after the function. +// Plain middleware -> produces a `middleware` span named after the function. app.use(async function simpleMiddleware(ctx, next) { await next(); }); diff --git a/dev-packages/node-integration-tests/suites/tracing/koa/test.ts b/dev-packages/node-integration-tests/suites/tracing/koa/test.ts index f730e24ab449..5cec23c83c9e 100644 --- a/dev-packages/node-integration-tests/suites/tracing/koa/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/koa/test.ts @@ -47,13 +47,13 @@ describe('koa auto-instrumentation', () => { // Plain middleware span. expect.objectContaining({ description: 'simpleMiddleware', - op: 'middleware.koa', + op: 'middleware', origin, data: expect.objectContaining({ 'koa.type': 'middleware', 'koa.name': 'simpleMiddleware', 'code.function.name': 'simpleMiddleware', - 'sentry.op': 'middleware.koa', + 'sentry.op': 'middleware', 'sentry.origin': origin, }), }), diff --git a/packages/core/src/integrations/express/patch-layer.ts b/packages/core/src/integrations/express/patch-layer.ts index 6a026afa67f8..d8211c3c7f2f 100644 --- a/packages/core/src/integrations/express/patch-layer.ts +++ b/packages/core/src/integrations/express/patch-layer.ts @@ -27,8 +27,10 @@ * limitations under the License. */ +import { SENTRY_OP } from '@sentry/conventions/attributes'; +import { WEB_SERVER_FUNCTION_SPAN_OP, WEB_SERVER_MIDDLEWARE_SPAN_OP } from '@sentry/conventions/op'; import { DEBUG_BUILD } from '../../debug-build'; -import { SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../../semanticAttributes'; +import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../../semanticAttributes'; import { SPAN_STATUS_ERROR, startSpanManual, withActiveSpan } from '../../tracing'; import { debug } from '../../utils/debug-logger'; import type { SpanAttributes } from '../../types/span'; @@ -122,7 +124,12 @@ export function patchLayer( const type = metadata.attributes[ATTR_EXPRESS_TYPE]; const attributes: SpanAttributes = Object.assign(metadata.attributes, { [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.express', - [SEMANTIC_ATTRIBUTE_SENTRY_OP]: `${type}.express`, + [SENTRY_OP]: + type === 'middleware' + ? WEB_SERVER_MIDDLEWARE_SPAN_OP + : type === 'request_handler' + ? WEB_SERVER_FUNCTION_SPAN_OP + : `${type}.express`, }); if (actualMatchedRoute) { attributes[ATTR_HTTP_ROUTE] = actualMatchedRoute; diff --git a/packages/core/test/lib/integrations/express/patch-layer.test.ts b/packages/core/test/lib/integrations/express/patch-layer.test.ts index 3c44bd93836f..00ee33365241 100644 --- a/packages/core/test/lib/integrations/express/patch-layer.test.ts +++ b/packages/core/test/lib/integrations/express/patch-layer.test.ts @@ -263,7 +263,7 @@ describe('patchLayer', () => { 'express.name': 'mw', 'express.type': 'middleware', 'http.route': '/a/:boo/:car/layerPath', - 'sentry.op': 'middleware.express', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.http.express', }, description: 'mw', @@ -349,7 +349,7 @@ describe('patchLayer', () => { 'express.name': 'a/:boo/:car/layerPath', 'express.type': 'request_handler', 'http.route': '/a/:boo/:car/layerPath', - 'sentry.op': 'request_handler.express', + 'sentry.op': 'function', 'sentry.origin': 'auto.http.express', }, description: 'a/:boo/:car/layerPath', @@ -403,7 +403,7 @@ describe('patchLayer', () => { 'express.name': 'a/:boo/:car', 'express.type': 'request_handler', 'http.route': '/a/:boo/:car', - 'sentry.op': 'request_handler.express', + 'sentry.op': 'function', 'sentry.origin': 'auto.http.express', }, description: 'a/:boo/:car', @@ -414,7 +414,7 @@ describe('patchLayer', () => { 'express.name': 'a/:boo/:car', 'express.type': 'request_handler', 'http.route': '/a/:boo/:car', - 'sentry.op': 'request_handler.express', + 'sentry.op': 'function', 'sentry.origin': 'auto.http.express', }, description: 'a/:boo/:car', @@ -453,7 +453,7 @@ describe('patchLayer', () => { 'express.name': 'mw', 'express.type': 'middleware', 'http.route': '/a/b/c', - 'sentry.op': 'middleware.express', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.http.express', }, description: 'mw', @@ -543,7 +543,7 @@ describe('patchLayer', () => { data: { 'express.name': 'mw', 'express.type': 'middleware', - 'sentry.op': 'middleware.express', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.http.express', }, description: 'mw', @@ -593,7 +593,7 @@ describe('patchLayer', () => { data: { 'express.name': 'mw', 'express.type': 'middleware', - 'sentry.op': 'middleware.express', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.http.express', }, description: 'mw', @@ -636,7 +636,7 @@ describe('patchLayer', () => { 'express.name': 'mw', 'express.type': 'middleware', 'http.route': '/a/b/c', - 'sentry.op': 'middleware.express', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.http.express', }, description: 'mw', diff --git a/packages/core/test/lib/utils/should-ignore-span.test.ts b/packages/core/test/lib/utils/should-ignore-span.test.ts index e329f3d7f00b..22d9594ea42c 100644 --- a/packages/core/test/lib/utils/should-ignore-span.test.ts +++ b/packages/core/test/lib/utils/should-ignore-span.test.ts @@ -94,9 +94,7 @@ describe('shouldIgnoreSpan', () => { }); it('matches middleware span names with regex', () => { - expect( - shouldIgnoreSpan({ description: 'middleware - expressInit', op: 'middleware.express' }, [/middleware/]), - ).toBe(true); + expect(shouldIgnoreSpan({ description: 'middleware - expressInit', op: 'middleware' }, [/middleware/])).toBe(true); }); it('matches IgnoreSpanFilter with op only', () => { diff --git a/packages/elysia/src/withElysia.ts b/packages/elysia/src/withElysia.ts index d1a253a99267..d147928101ce 100644 --- a/packages/elysia/src/withElysia.ts +++ b/packages/elysia/src/withElysia.ts @@ -1,4 +1,5 @@ import { HTTP_ROUTE, URL_FULL, URL_PATH } from '@sentry/conventions/attributes'; +import { WEB_SERVER_FUNCTION_SPAN_OP, WEB_SERVER_MIDDLEWARE_SPAN_OP } from '@sentry/conventions/op'; import type { Span } from '@sentry/core'; import { captureException, @@ -29,15 +30,15 @@ const ELYSIA_ORIGIN = 'auto.http.elysia'; * Map Elysia lifecycle phase names to Sentry span ops. */ const ELYSIA_LIFECYCLE_OP_MAP: Record = { - Request: 'middleware.elysia', - Parse: 'middleware.elysia', - Transform: 'middleware.elysia', - BeforeHandle: 'middleware.elysia', - Handle: 'request_handler.elysia', - AfterHandle: 'middleware.elysia', - MapResponse: 'middleware.elysia', - AfterResponse: 'middleware.elysia', - Error: 'middleware.elysia', + Request: WEB_SERVER_MIDDLEWARE_SPAN_OP, + Parse: WEB_SERVER_MIDDLEWARE_SPAN_OP, + Transform: WEB_SERVER_MIDDLEWARE_SPAN_OP, + BeforeHandle: WEB_SERVER_MIDDLEWARE_SPAN_OP, + Handle: WEB_SERVER_FUNCTION_SPAN_OP, + AfterHandle: WEB_SERVER_MIDDLEWARE_SPAN_OP, + MapResponse: WEB_SERVER_MIDDLEWARE_SPAN_OP, + AfterResponse: WEB_SERVER_MIDDLEWARE_SPAN_OP, + Error: WEB_SERVER_MIDDLEWARE_SPAN_OP, }; function isBun(): boolean { diff --git a/packages/hono/src/shared/patchAppRequest.ts b/packages/hono/src/shared/patchAppRequest.ts index d70b379eba1e..7f40c86aab12 100644 --- a/packages/hono/src/shared/patchAppRequest.ts +++ b/packages/hono/src/shared/patchAppRequest.ts @@ -1,8 +1,9 @@ +import { SENTRY_OP } from '@sentry/conventions/attributes'; +import { WEB_SERVER_HTTP_SERVER_SPAN_OP } from '@sentry/conventions/op'; import { debug, getActiveSpan, getOriginalFunction, - SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, startSpan, type WrappedFunction, @@ -10,7 +11,7 @@ import { import type { Env, Hono } from 'hono'; import { DEBUG_BUILD } from '../debug-build'; -const INTERNAL_REQUEST_OP = 'hono.request'; +const INTERNAL_REQUEST_OP = WEB_SERVER_HTTP_SERVER_SPAN_OP; const INTERNAL_REQUEST_ORIGIN = 'auto.http.hono.internal_request'; function extractPathname(input: string | Request | URL): string { @@ -23,7 +24,7 @@ function extractPathname(input: string | Request | URL): string { /** * Patches `app.request()` on a Hono instance so that each internal dispatch - * is traced as a `hono.request` span — child of whatever span is active at + * is traced as an `http.server` span — child of whatever span is active at * the call site. * * `.request()` is a class field (arrow function), so this must run per-instance. @@ -53,10 +54,9 @@ export function patchAppRequest(app: Hono): void { return startSpan( { name: `${method} ${path}`, - op: INTERNAL_REQUEST_OP, onlyIfParent: true, attributes: { - [SEMANTIC_ATTRIBUTE_SENTRY_OP]: INTERNAL_REQUEST_OP, + [SENTRY_OP]: INTERNAL_REQUEST_OP, [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: INTERNAL_REQUEST_ORIGIN, }, }, diff --git a/packages/hono/src/shared/wrapMiddlewareSpan.ts b/packages/hono/src/shared/wrapMiddlewareSpan.ts index 8c2e4787314b..7776e261f99e 100644 --- a/packages/hono/src/shared/wrapMiddlewareSpan.ts +++ b/packages/hono/src/shared/wrapMiddlewareSpan.ts @@ -1,8 +1,9 @@ +import { SENTRY_OP } from '@sentry/conventions/attributes'; +import { WEB_SERVER_MIDDLEWARE_SPAN_OP } from '@sentry/conventions/op'; import { getActiveSpan, getOriginalFunction, getRootSpan, - SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SPAN_STATUS_ERROR, startInactiveSpan, @@ -31,11 +32,10 @@ export function wrapMiddlewareWithSpan(handler: MiddlewareHandler): MiddlewareHa const rootSpan = activeSpan ? getRootSpan(activeSpan) : undefined; const span = startInactiveSpan({ name: handler.name || '', - op: 'middleware.hono', onlyIfParent: true, parentSpan: rootSpan, attributes: { - [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'middleware.hono', + [SENTRY_OP]: WEB_SERVER_MIDDLEWARE_SPAN_OP, [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: MIDDLEWARE_ORIGIN, }, }); diff --git a/packages/hono/test/shared/applyPatches.test.ts b/packages/hono/test/shared/applyPatches.test.ts index 51a68859e614..129e83d341d2 100644 --- a/packages/hono/test/shared/applyPatches.test.ts +++ b/packages/hono/test/shared/applyPatches.test.ts @@ -583,9 +583,8 @@ describe('applyPatches', () => { expect(startSpanMock).toHaveBeenCalledWith( expect.objectContaining({ name: 'GET /hello', - op: 'hono.request', attributes: expect.objectContaining({ - 'sentry.op': 'hono.request', + 'sentry.op': 'http.server', 'sentry.origin': 'auto.http.hono.internal_request', }), }), diff --git a/packages/hono/test/shared/earlyPatchRoute.test.ts b/packages/hono/test/shared/earlyPatchRoute.test.ts index bd748fda978c..3e2eee6208a7 100644 --- a/packages/hono/test/shared/earlyPatchRoute.test.ts +++ b/packages/hono/test/shared/earlyPatchRoute.test.ts @@ -56,10 +56,7 @@ describe('earlyPatchHono (two-phase prototype hook)', () => { await subApp.request('/hello'); expect(startSpanMock).toHaveBeenCalledTimes(1); - expect(startSpanMock).toHaveBeenCalledWith( - expect.objectContaining({ name: 'GET /hello', op: 'hono.request' }), - expect.any(Function), - ); + expect(startSpanMock).toHaveBeenCalledWith(expect.objectContaining({ name: 'GET /hello' }), expect.any(Function)); }); it('emits a debug log and applies patchAppRequest when sub-app was mounted before applyPatches', async () => { @@ -82,10 +79,7 @@ describe('earlyPatchHono (two-phase prototype hook)', () => { // patchAppRequest is applied retroactively await subApp.request('/hello'); - expect(startSpanMock).toHaveBeenCalledWith( - expect.objectContaining({ name: 'GET /hello', op: 'hono.request' }), - expect.any(Function), - ); + expect(startSpanMock).toHaveBeenCalledWith(expect.objectContaining({ name: 'GET /hello' }), expect.any(Function)); }); it('preserves correct route behavior', async () => { diff --git a/packages/hono/test/shared/patchAppRequest.test.ts b/packages/hono/test/shared/patchAppRequest.test.ts index 81fef4c52ace..bcd5ccf3a863 100644 --- a/packages/hono/test/shared/patchAppRequest.test.ts +++ b/packages/hono/test/shared/patchAppRequest.test.ts @@ -32,10 +32,9 @@ describe('patchAppRequest', () => { expect(startSpanMock).toHaveBeenCalledWith( expect.objectContaining({ name: 'GET /hello', - op: 'hono.request', onlyIfParent: true, attributes: expect.objectContaining({ - 'sentry.op': 'hono.request', + 'sentry.op': 'http.server', 'sentry.origin': 'auto.http.hono.internal_request', }), }), diff --git a/packages/hono/test/shared/patchAppUse.test.ts b/packages/hono/test/shared/patchAppUse.test.ts index dca53be16040..a499a6a7b17c 100644 --- a/packages/hono/test/shared/patchAppUse.test.ts +++ b/packages/hono/test/shared/patchAppUse.test.ts @@ -39,10 +39,9 @@ describe('patchAppUse (middleware spans)', () => { expect(startInactiveSpanMock).toHaveBeenCalledTimes(1); expect(startInactiveSpanMock).toHaveBeenCalledWith( expect.objectContaining({ - op: 'middleware.hono', onlyIfParent: true, attributes: expect.objectContaining({ - 'sentry.op': 'middleware.hono', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.middleware.hono', }), }), @@ -124,8 +123,8 @@ describe('patchAppUse (middleware spans)', () => { expect(startInactiveSpanMock).toHaveBeenCalledTimes(3); const [firstCall, secondCall, thirdCall] = startInactiveSpanMock.mock.calls; - expect(firstCall![0]).toMatchObject({ op: 'middleware.hono' }); - expect(secondCall![0]).toMatchObject({ op: 'middleware.hono' }); + expect(firstCall![0]).toMatchObject({ attributes: { 'sentry.op': 'middleware' } }); + expect(secondCall![0]).toMatchObject({ attributes: { 'sentry.op': 'middleware' } }); expect(firstCall![0].name).toMatch(''); expect(secondCall![0].name).toBe('namedMiddleware'); expect(thirdCall![0].name).toBe(''); @@ -225,11 +224,10 @@ describe('patchHttpMethodHandlers (inline middleware spans on main app)', () => expect(startInactiveSpanMock).toHaveBeenCalledTimes(1); expect(startInactiveSpanMock).toHaveBeenCalledWith({ name: 'inlineMw', - op: 'middleware.hono', onlyIfParent: true, parentSpan: undefined, attributes: { - 'sentry.op': 'middleware.hono', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.middleware.hono', }, }); diff --git a/packages/nestjs/src/integrations/helpers.ts b/packages/nestjs/src/integrations/helpers.ts index d3b1c5f14800..dd3ea3fb2dbd 100644 --- a/packages/nestjs/src/integrations/helpers.ts +++ b/packages/nestjs/src/integrations/helpers.ts @@ -1,3 +1,5 @@ +import { SENTRY_OP } from '@sentry/conventions/attributes'; +import { WEB_SERVER_MIDDLEWARE_SPAN_OP } from '@sentry/conventions/op'; import type { Span } from '@sentry/core'; import { addNonEnumerableProperty, @@ -89,7 +91,7 @@ export function getMiddlewareSpanOptions( return { name: name ?? target.name ?? 'unknown', attributes: { - [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'middleware.nestjs', + [SENTRY_OP]: WEB_SERVER_MIDDLEWARE_SPAN_OP, [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: middlewareOrigin(componentType), }, }; diff --git a/packages/nestjs/src/integrations/wrap-route.ts b/packages/nestjs/src/integrations/wrap-route.ts index 47a8d1b4909a..271cdd349f21 100644 --- a/packages/nestjs/src/integrations/wrap-route.ts +++ b/packages/nestjs/src/integrations/wrap-route.ts @@ -1,4 +1,5 @@ -import { HTTP_METHOD, HTTP_ROUTE, URL_FULL } from '@sentry/conventions/attributes'; +import { HTTP_METHOD, HTTP_ROUTE, SENTRY_OP, URL_FULL } from '@sentry/conventions/attributes'; +import { WEB_SERVER_FUNCTION_SPAN_OP } from '@sentry/conventions/op'; import type { SpanAttributes } from '@sentry/core'; import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, startSpan } from '@sentry/core'; import type { AnyFn } from './helpers'; @@ -42,8 +43,8 @@ export function getAppCreationSpanOptions( } /** - * Wrap the route-handler callback so each invocation opens the `handler.nestjs` - * span (REQUEST_HANDLER). Preserve the original `.name` and reflect-metadata so + * Wrap the route-handler callback so each invocation opens the request-handler + * (`function` op) span. Preserve the original `.name` and reflect-metadata so * NestJS reflection is unaffected. */ export function wrapRouteHandler(callback: AnyFn, moduleVersion?: string): AnyFn { @@ -53,15 +54,14 @@ export function wrapRouteHandler(callback: AnyFn, moduleVersion?: string): AnyFn const spanName = callback.name || 'anonymous nest handler'; const attributes: SpanAttributes = { component: NESTJS_COMPONENT, + [SENTRY_OP]: WEB_SERVER_FUNCTION_SPAN_OP, [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: HTTP_ORIGIN, [AttributeNames.TYPE]: NestType.REQUEST_HANDLER, [AttributeNames.CALLBACK]: callback.name, [AttributeNames.VERSION]: moduleVersion || undefined, }; const wrapped = function (this: unknown, ...args: unknown[]): unknown { - return startSpan({ name: spanName, op: `${NestType.REQUEST_HANDLER}.nestjs`, attributes }, () => - callback.apply(this, args), - ); + return startSpan({ name: spanName, attributes }, () => callback.apply(this, args)); }; if (callback.name) { Object.defineProperty(wrapped, 'name', { value: callback.name }); diff --git a/packages/nestjs/test/integrations/orchestrion-subscriber.test.ts b/packages/nestjs/test/integrations/orchestrion-subscriber.test.ts index b506ab153f06..6a38e3b2c916 100644 --- a/packages/nestjs/test/integrations/orchestrion-subscriber.test.ts +++ b/packages/nestjs/test/integrations/orchestrion-subscriber.test.ts @@ -278,7 +278,7 @@ describe('NestJS orchestrion subscriber: request_context / request_handler', () expect(handlerSpanJson).toBeDefined(); expect(handlerSpanJson!.description).toBe('getCats'); - expect(handlerSpanJson!.op).toBe('handler.nestjs'); + expect(handlerSpanJson!.op).toBe('function'); expect(handlerSpanJson!.origin).toBe('auto.http.nestjs'); expect(handlerSpanJson!.data).toMatchObject({ component: '@nestjs/core', @@ -354,7 +354,7 @@ describe('NestJS orchestrion subscriber: @Injectable (middleware/guard/pipe/inte expect(next).toHaveBeenCalledTimes(1); const json = spanToJSON(spanInside!); expect(json.description).toBe('LoggerMiddleware'); - expect(json.op).toBe('middleware.nestjs'); + expect(json.op).toBe('middleware'); expect(json.origin).toBe('auto.middleware.nestjs'); // startSpanManual span ends when the proxied `next` is called. expect(json.timestamp).toBeDefined(); @@ -377,7 +377,7 @@ describe('NestJS orchestrion subscriber: @Injectable (middleware/guard/pipe/inte expect(new AuthGuard().canActivate({ ctx: true })).toBe(true); const json = spanToJSON(spanInside!); expect(json.description).toBe('AuthGuard'); - expect(json.op).toBe('middleware.nestjs'); + expect(json.op).toBe('middleware'); expect(json.origin).toBe('auto.middleware.nestjs.guard'); }); @@ -398,7 +398,7 @@ describe('NestJS orchestrion subscriber: @Injectable (middleware/guard/pipe/inte expect(new ParseIntPipe().transform('42', { type: 'param' })).toBe(42); const json = spanToJSON(spanInside!); expect(json.description).toBe('ParseIntPipe'); - expect(json.op).toBe('middleware.nestjs'); + expect(json.op).toBe('middleware'); expect(json.origin).toBe('auto.middleware.nestjs.pipe'); }); @@ -432,7 +432,7 @@ describe('NestJS orchestrion subscriber: @Injectable (middleware/guard/pipe/inte const beforeJson = spanToJSON(beforeSpan!); expect(beforeJson.description).toBe('LoggingInterceptor'); - expect(beforeJson.op).toBe('middleware.nestjs'); + expect(beforeJson.op).toBe('middleware'); expect(beforeJson.origin).toBe('auto.middleware.nestjs.interceptor'); // before-span ends when `next.handle()` is called. expect(beforeJson.timestamp).toBeDefined(); @@ -659,7 +659,7 @@ describe('NestJS orchestrion subscriber: @Catch (exception filter)', () => { const json = spanToJSON(spanInside!); expect(json.description).toBe('HttpExceptionFilter'); - expect(json.op).toBe('middleware.nestjs'); + expect(json.op).toBe('middleware'); expect(json.origin).toBe('auto.middleware.nestjs.exception_filter'); }); @@ -714,7 +714,7 @@ describe('NestJS orchestrion subscriber: @Catch (exception filter)', () => { const json = spanToJSON(spanInside!); expect(json.description).toBe('HttpExceptionFilter'); - expect(json.op).toBe('middleware.nestjs'); + expect(json.op).toBe('middleware'); expect(json.origin).toBe('auto.middleware.nestjs.exception_filter'); }); @@ -738,7 +738,7 @@ describe('NestJS orchestrion subscriber: @Catch (exception filter)', () => { const json = spanToJSON(spanInside!); expect(json.description).toBe('HttpExceptionFilter'); - expect(json.op).toBe('middleware.nestjs'); + expect(json.op).toBe('middleware'); expect(json.origin).toBe('auto.middleware.nestjs.exception_filter'); }); diff --git a/packages/nitro/package.json b/packages/nitro/package.json index cc17edbd6b86..48c495001f26 100644 --- a/packages/nitro/package.json +++ b/packages/nitro/package.json @@ -36,6 +36,7 @@ }, "dependencies": { "@sentry/bundler-plugins": "^10.67.0", + "@sentry/conventions": "^0.16.0", "@sentry/core": "10.67.0", "@sentry/node": "10.67.0", "@sentry/server-utils": "10.67.0" diff --git a/packages/nitro/src/runtime/hooks/captureTracingEvents.ts b/packages/nitro/src/runtime/hooks/captureTracingEvents.ts index 155d8f1d6553..faad0238a5d7 100644 --- a/packages/nitro/src/runtime/hooks/captureTracingEvents.ts +++ b/packages/nitro/src/runtime/hooks/captureTracingEvents.ts @@ -1,4 +1,6 @@ import * as dc from 'node:diagnostics_channel'; +import { SENTRY_OP } from '@sentry/conventions/attributes'; +import { WEB_SERVER_HTTP_SERVER_SPAN_OP, WEB_SERVER_MIDDLEWARE_SPAN_OP } from '@sentry/conventions/op'; import { isObjectLike, getActiveSpan, @@ -8,7 +10,6 @@ import { GLOBAL_OBJ, httpHeadersToSpanAttributes, parseStringToURLObject, - SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, setHttpStatus, type Span, @@ -107,7 +108,7 @@ function setupH3TracingChannels(): void { attributes: { ...urlAttributes, [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.nitro.h3', - [SEMANTIC_ATTRIBUTE_SENTRY_OP]: data?.type === 'middleware' ? 'middleware.nitro' : 'http.server', + [SENTRY_OP]: data?.type === 'middleware' ? WEB_SERVER_MIDDLEWARE_SPAN_OP : WEB_SERVER_HTTP_SERVER_SPAN_OP, }, }); @@ -172,7 +173,7 @@ function setupSrvxTracingChannels(): void { ...urlAttributes, ...headerAttributes, [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.nitro.srvx', - [SEMANTIC_ATTRIBUTE_SENTRY_OP]: data.middleware ? 'middleware.nitro' : 'http.server', + [SENTRY_OP]: data.middleware ? WEB_SERVER_MIDDLEWARE_SPAN_OP : WEB_SERVER_HTTP_SERVER_SPAN_OP, 'server.port': data.server.options.port, }, // Use the same parent span as middleware to make them siblings @@ -211,7 +212,7 @@ function setupSrvxTracingChannels(): void { attributes: { ...urlAttributes, [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.nitro.srvx', - [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'middleware.nitro', + [SENTRY_OP]: WEB_SERVER_MIDDLEWARE_SPAN_OP, }, parentSpan: requestParentSpans.get(data.request) || undefined, }); diff --git a/packages/nuxt/package.json b/packages/nuxt/package.json index 1ef9e69ef68b..7e59613e6546 100644 --- a/packages/nuxt/package.json +++ b/packages/nuxt/package.json @@ -56,6 +56,7 @@ "@nuxt/kit": "^3.13.2", "@sentry/browser": "10.67.0", "@sentry/cloudflare": "10.67.0", + "@sentry/conventions": "^0.16.0", "@sentry/core": "10.67.0", "@sentry/node": "10.67.0", "@sentry/bundler-plugins": "10.67.0", diff --git a/packages/nuxt/src/runtime/hooks/wrapMiddlewareHandler.ts b/packages/nuxt/src/runtime/hooks/wrapMiddlewareHandler.ts index f425651cfe00..7c024388b948 100644 --- a/packages/nuxt/src/runtime/hooks/wrapMiddlewareHandler.ts +++ b/packages/nuxt/src/runtime/hooks/wrapMiddlewareHandler.ts @@ -1,10 +1,11 @@ +import { SENTRY_OP } from '@sentry/conventions/attributes'; +import { WEB_SERVER_MIDDLEWARE_SPAN_OP } from '@sentry/conventions/op'; import { captureException, debug, flushIfServerless, getClient, httpHeadersToSpanAttributes, - SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SPAN_STATUS_ERROR, @@ -164,7 +165,7 @@ function getSpanAttributes( index?: number, ): SpanAttributes { const attributes: SpanAttributes = { - [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'middleware.nuxt', + [SENTRY_OP]: WEB_SERVER_MIDDLEWARE_SPAN_OP, [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'custom', [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.middleware.nuxt', 'nuxt.middleware.name': middlewareName, diff --git a/packages/nuxt/test/runtime/hooks/wrapMiddlewareHandler.test.ts b/packages/nuxt/test/runtime/hooks/wrapMiddlewareHandler.test.ts index 3a3c9bdca5c0..96621d1e442d 100644 --- a/packages/nuxt/test/runtime/hooks/wrapMiddlewareHandler.test.ts +++ b/packages/nuxt/test/runtime/hooks/wrapMiddlewareHandler.test.ts @@ -177,7 +177,7 @@ describe('wrapMiddlewareHandlerWithSentry', () => { expect.objectContaining({ name: 'object-middleware', attributes: expect.objectContaining({ - [SentryCore.SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'middleware.nuxt', + [SentryCore.SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'middleware', 'nuxt.middleware.name': 'object-middleware', }), }), @@ -208,7 +208,7 @@ describe('wrapMiddlewareHandlerWithSentry', () => { expect.objectContaining({ name: 'request-middleware.onRequest', attributes: expect.objectContaining({ - [SentryCore.SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'middleware.nuxt', + [SentryCore.SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'middleware', 'nuxt.middleware.name': 'request-middleware', 'nuxt.middleware.hook.name': 'onRequest', }), @@ -295,7 +295,7 @@ describe('wrapMiddlewareHandlerWithSentry', () => { expect.objectContaining({ name: 'response-middleware.onBeforeResponse', attributes: expect.objectContaining({ - [SentryCore.SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'middleware.nuxt', + [SentryCore.SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'middleware', 'nuxt.middleware.name': 'response-middleware', 'nuxt.middleware.hook.name': 'onBeforeResponse', }), @@ -507,7 +507,7 @@ describe('wrapMiddlewareHandlerWithSentry', () => { expect.objectContaining({ name: 'v2-middleware.middleware', attributes: expect.objectContaining({ - [SentryCore.SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'middleware.nuxt', + [SentryCore.SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'middleware', 'nuxt.middleware.name': 'v2-middleware', 'nuxt.middleware.hook.name': 'middleware', 'nuxt.middleware.hook.index': 0, @@ -586,7 +586,7 @@ describe('wrapMiddlewareHandlerWithSentry', () => { expect.objectContaining({ name: 'api-middleware', attributes: expect.objectContaining({ - [SentryCore.SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'middleware.nuxt', + [SentryCore.SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'middleware', 'nuxt.middleware.name': 'api-middleware', 'http.request.method': 'GET', 'http.route': '/test-path', diff --git a/packages/server-utils/src/integrations/tracing-channel/express/instrumentation.ts b/packages/server-utils/src/integrations/tracing-channel/express/instrumentation.ts index 60950d23aa45..3c0cfd833948 100644 --- a/packages/server-utils/src/integrations/tracing-channel/express/instrumentation.ts +++ b/packages/server-utils/src/integrations/tracing-channel/express/instrumentation.ts @@ -1,12 +1,12 @@ import type * as diagnosticsChannel from 'node:diagnostics_channel'; -import { HTTP_ROUTE } from '@sentry/conventions/attributes'; +import { HTTP_ROUTE, SENTRY_OP } from '@sentry/conventions/attributes'; +import { WEB_SERVER_FUNCTION_SPAN_OP, WEB_SERVER_MIDDLEWARE_SPAN_OP } from '@sentry/conventions/op'; import type { Span } from '@sentry/core'; import { debug, getActiveSpan, getDefaultIsolationScope, getIsolationScope, - SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, startInactiveSpan, stringMatchesSomePattern, @@ -223,7 +223,12 @@ function getSpanForLayer(data: HandleChannelContext, options: ExpressIntegration name, attributes: { [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN, - [SEMANTIC_ATTRIBUTE_SENTRY_OP]: `${type}.express`, + [SENTRY_OP]: + type === 'middleware' + ? WEB_SERVER_MIDDLEWARE_SPAN_OP + : type === 'request_handler' + ? WEB_SERVER_FUNCTION_SPAN_OP + : `${type}.express`, [ATTR_EXPRESS_NAME]: name, [ATTR_EXPRESS_TYPE]: type, ...(matchedRoute ? { [HTTP_ROUTE]: matchedRoute } : {}), diff --git a/packages/server-utils/src/integrations/tracing-channel/fastify/instrumentation.ts b/packages/server-utils/src/integrations/tracing-channel/fastify/instrumentation.ts index 1964307844c4..3b17e10e2dbe 100644 --- a/packages/server-utils/src/integrations/tracing-channel/fastify/instrumentation.ts +++ b/packages/server-utils/src/integrations/tracing-channel/fastify/instrumentation.ts @@ -15,7 +15,14 @@ /* eslint-disable max-lines */ import * as diagnosticsChannel from 'node:diagnostics_channel'; -import { HTTP_REQUEST_METHOD, HTTP_RESPONSE_STATUS_CODE, HTTP_ROUTE, URL_PATH } from '@sentry/conventions/attributes'; +import { + HTTP_REQUEST_METHOD, + HTTP_RESPONSE_STATUS_CODE, + HTTP_ROUTE, + SENTRY_OP, + URL_PATH, +} from '@sentry/conventions/attributes'; +import { WEB_SERVER_FUNCTION_SPAN_OP, WEB_SERVER_MIDDLEWARE_SPAN_OP } from '@sentry/conventions/op'; import type { Span } from '@sentry/core'; import { isObjectLike, @@ -35,8 +42,8 @@ const PACKAGE_NAME = '@sentry/instrumentation-fastify'; const SUPPORTED_VERSIONS = '>=3.21.0 <6'; const ORIGIN = 'auto.http.otel.fastify'; -const HOOK_OP = 'hook.fastify'; -const REQUEST_HANDLER_OP = 'request_handler.fastify'; +const HOOK_OP = WEB_SERVER_MIDDLEWARE_SPAN_OP; +const REQUEST_HANDLER_OP = WEB_SERVER_FUNCTION_SPAN_OP; const FASTIFY_HOOKS = [ 'onRequest', @@ -175,6 +182,7 @@ function startRequestSpanHook(this: any, request: any, _reply: any, hookDone: () const attributes: Record = { [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN, + [SENTRY_OP]: REQUEST_HANDLER_OP, [ATTRIBUTE_FASTIFY_ROOT]: PACKAGE_NAME, [HTTP_REQUEST_METHOD]: request.method, [URL_PATH]: request.url, @@ -189,7 +197,6 @@ function startRequestSpanHook(this: any, request: any, _reply: any, hookDone: () const requestSpan = startInactiveSpan({ name: route != null ? `${request.method} ${route}` : 'request', - op: REQUEST_HANDLER_OP, attributes, }); request[kRequestSpan] = requestSpan; @@ -344,9 +351,9 @@ function handlerWrapper(handler: AnyFn, hookName: string, spanAttributes: Record return startSpan( { name, - op, attributes: { ...spanAttributes, + [SENTRY_OP]: op, [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN, }, parentSpan, diff --git a/packages/server-utils/src/integrations/tracing-channel/hapi-utils.ts b/packages/server-utils/src/integrations/tracing-channel/hapi-utils.ts index 7bb9b7944232..b611a923b445 100644 --- a/packages/server-utils/src/integrations/tracing-channel/hapi-utils.ts +++ b/packages/server-utils/src/integrations/tracing-channel/hapi-utils.ts @@ -2,12 +2,15 @@ * OTel-free, `@hapi/*`-free port of the span-building helpers and handler/ext * wrap logic from the vendored `@opentelemetry/instrumentation-hapi` * (upstream @opentelemetry/instrumentation-hapi@0.64.0). Span output (names, - * ops, origins, attributes) is kept byte-identical to that instrumentation; + * origins, attributes) is kept close to that instrumentation — except the + * plugin-route op, which is normalized to the cross-framework `function` op; * span creation goes through the `@sentry/core` API and the OTel active-span * guard is replaced with `getActiveSpan()`. */ import { getActiveSpan, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, startSpan } from '@sentry/core'; +import { SENTRY_OP } from '@sentry/conventions/attributes'; +import { WEB_SERVER_FUNCTION_SPAN_OP } from '@sentry/conventions/op'; import type { LifecycleMethod, PatchableExtMethod, @@ -104,12 +107,14 @@ export const getExtMetadata = ( }; function startMetadataSpan(metadata: SpanMetadata, original: () => unknown): unknown { + const hapiType = metadata.attributes[AttributeNames.HAPI_TYPE]; + const op = hapiType === HapiLayerType.PLUGIN ? WEB_SERVER_FUNCTION_SPAN_OP : `${hapiType}.hapi`; return startSpan( { name: metadata.name, - op: `${metadata.attributes[AttributeNames.HAPI_TYPE]}.hapi`, attributes: { ...metadata.attributes, + [SENTRY_OP]: op, [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.hapi', }, }, diff --git a/packages/server-utils/src/integrations/tracing-channel/koa.ts b/packages/server-utils/src/integrations/tracing-channel/koa.ts index 0efcd75623ba..9acc9dafda95 100644 --- a/packages/server-utils/src/integrations/tracing-channel/koa.ts +++ b/packages/server-utils/src/integrations/tracing-channel/koa.ts @@ -10,7 +10,8 @@ import { startSpan, } from '@sentry/core'; // oxlint-disable-next-line typescript/no-deprecated -import { CODE_FUNCTION_NAME, HTTP_ROUTE, KOA_NAME, KOA_TYPE } from '@sentry/conventions/attributes'; +import { CODE_FUNCTION_NAME, HTTP_ROUTE, KOA_NAME, KOA_TYPE, SENTRY_OP } from '@sentry/conventions/attributes'; +import { WEB_SERVER_MIDDLEWARE_SPAN_OP } from '@sentry/conventions/op'; import { DEBUG_BUILD } from '../../debug-build'; import { CHANNELS } from '../../orchestrion/channels'; import { setHttpServerSpanRouteAttribute } from '../../utils/setHttpServerSpanRouteAttribute'; @@ -181,9 +182,9 @@ function patchLayer( return startSpan( { name, - op: `${layerType}.koa`, attributes: { ...metadata.attributes, + [SENTRY_OP]: layerType === LAYER_TYPE.MIDDLEWARE ? WEB_SERVER_MIDDLEWARE_SPAN_OP : `${layerType}.koa`, [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN, }, }, diff --git a/packages/tanstackstart-react/src/server/utils.ts b/packages/tanstackstart-react/src/server/utils.ts index 9ff87c8ebbf4..ed6c38c3718b 100644 --- a/packages/tanstackstart-react/src/server/utils.ts +++ b/packages/tanstackstart-react/src/server/utils.ts @@ -1,16 +1,17 @@ +import { SENTRY_OP } from '@sentry/conventions/attributes'; +import { WEB_SERVER_MIDDLEWARE_SPAN_OP } from '@sentry/conventions/op'; import type { StartSpanOptions } from '@sentry/core'; -import { SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/node'; +import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/node'; /** * Returns span options for TanStack Start middleware spans. */ export function getMiddlewareSpanOptions(name: string): StartSpanOptions { return { - op: 'middleware.tanstackstart', name, attributes: { [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.middleware.tanstackstart', - [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'middleware.tanstackstart', + [SENTRY_OP]: WEB_SERVER_MIDDLEWARE_SPAN_OP, }, }; } diff --git a/packages/tanstackstart-react/test/server/utils.test.ts b/packages/tanstackstart-react/test/server/utils.test.ts index 66540bf3dfb3..5ddfc7b49c23 100644 --- a/packages/tanstackstart-react/test/server/utils.test.ts +++ b/packages/tanstackstart-react/test/server/utils.test.ts @@ -5,10 +5,9 @@ describe('getMiddlewareSpanOptions', () => { it('returns correct span options', () => { const options = getMiddlewareSpanOptions('testMiddleware'); expect(options).toEqual({ - op: 'middleware.tanstackstart', name: 'testMiddleware', attributes: { - 'sentry.op': 'middleware.tanstackstart', + 'sentry.op': 'middleware', 'sentry.origin': 'auto.middleware.tanstackstart', }, });