Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ test('Sends a server function span with wrapFetchWithSentry', async ({ page }) =
'sentry.op': { type: 'string', value: 'function' },
'sentry.origin': { type: 'string', value: 'auto.function.tanstackstart.server' },
'sentry.description': { type: 'string', value: 'GET /_serverFn/testLog' },
'tanstackstart.function.id': { type: 'string', value: expect.any(String) },
'tanstackstart.function.filename': { type: 'string', value: 'src/routes/test-serverFn.tsx' },
'code.file.path': { type: 'string', value: 'src/routes/test-serverFn.tsx' },
}),
}),
]),
Expand Down Expand Up @@ -85,8 +84,7 @@ test('Sends a server function span for a nested server function with manual span
'sentry.op': { type: 'string', value: 'function' },
'sentry.origin': { type: 'string', value: 'auto.function.tanstackstart.server' },
'sentry.description': { type: 'string', value: 'GET /_serverFn/testNestedLog' },
'tanstackstart.function.id': { type: 'string', value: expect.any(String) },
'tanstackstart.function.filename': { type: 'string', value: 'src/routes/test-serverFn.tsx' },
'code.file.path': { type: 'string', value: 'src/routes/test-serverFn.tsx' },
}),
}),
expect.objectContaining({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ test('Sends a server function transaction with auto-instrumentation', async ({ p
'sentry.origin': 'auto.function.tanstackstart.server',
'code.function.name': 'testLog',
'http.request.method': 'GET',
'tanstackstart.function.id': expect.any(String),
'tanstackstart.function.filename': 'app/routes/test-serverFn.tsx',
'code.file.path': 'app/routes/test-serverFn.tsx',
},
status: 'ok',
}),
Expand Down Expand Up @@ -69,8 +68,7 @@ test('Sends a server function transaction for a nested server function', async (
'sentry.origin': 'auto.function.tanstackstart.server',
'code.function.name': 'testNestedLog',
'http.request.method': 'GET',
'tanstackstart.function.id': expect.any(String),
'tanstackstart.function.filename': 'app/routes/test-serverFn.tsx',
'code.file.path': 'app/routes/test-serverFn.tsx',
},
status: 'ok',
}),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect, test } from '@playwright/test';
import { collectStreamedSpans, getSpanOp } from '@sentry-internal/test-utils';
import { SENTRY_DESCRIPTION, SENTRY_OP, SENTRY_ORIGIN } from '@sentry/conventions/attributes';
import { CODE_FILE_PATH, SENTRY_DESCRIPTION, SENTRY_OP, SENTRY_ORIGIN } from '@sentry/conventions/attributes';
import { FUNCTION } from '@sentry/conventions/op';

function isServerFnSegment(span: Parameters<typeof getSpanOp>[0]): boolean {
Expand Down Expand Up @@ -39,7 +39,7 @@ test('Sends a server function span with auto-instrumentation', async ({ page })
'sentry.op': { type: 'string', value: 'function' },
'sentry.origin': { type: 'string', value: 'auto.function.tanstackstart.server' },
'sentry.description': { type: 'string', value: 'GET /_serverFn/testLog' },
'tanstackstart.function.filename': { type: 'string', value: 'src/routes/test-serverFn.tsx' },
[CODE_FILE_PATH]: { type: 'string', value: 'src/routes/test-serverFn.tsx' },
}),
}),
]),
Expand Down Expand Up @@ -79,7 +79,7 @@ test('Sends a server function span for a nested server function', async ({ page
attributes: expect.objectContaining({
[SENTRY_OP]: { type: 'string', value: FUNCTION },
[SENTRY_DESCRIPTION]: { type: 'string', value: 'GET /_serverFn/testNestedLog' },
'tanstackstart.function.filename': { type: 'string', value: 'src/routes/test-serverFn.tsx' },
[CODE_FILE_PATH]: { type: 'string', value: 'src/routes/test-serverFn.tsx' },
}),
});
expect(manualSpan).toMatchObject({ status: 'ok', parent_span_id: outerSpan?.span_id });
Expand Down
5 changes: 2 additions & 3 deletions packages/tanstackstart-react/src/server/globalMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
import type { SentryGlobalFunctionMiddleware, SentryGlobalRequestMiddleware } from '../common/types';
import { SENTRY_INTERNAL } from './middleware';
import {
CODE_FILE_PATH,
CODE_FUNCTION_NAME,
HTTP_REQUEST_METHOD,
SENTRY_DESCRIPTION,
Expand All @@ -17,7 +18,6 @@ import {
import { FUNCTION } from '@sentry/conventions/op';

type ServerFnMeta = {
id?: string;
name?: string;
filename?: string;
};
Expand Down Expand Up @@ -61,8 +61,7 @@ function createSentryFunctionMiddlewareHandler(mechanismType: string) {
[HTTP_REQUEST_METHOD]: method,
// Relay infers a `function` span's description from `code.function.name` alone, which drops the path.
...(hasSpanStreaming && { [SENTRY_DESCRIPTION]: description }),
...(serverFnMeta?.id && { 'tanstackstart.function.id': serverFnMeta.id }),
...(serverFnMeta?.filename && { 'tanstackstart.function.filename': serverFnMeta.filename }),
...(serverFnMeta?.filename && { [CODE_FILE_PATH]: serverFnMeta.filename }),
},
},
async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { afterEach, describe, expect, it, vi } from 'vitest';
import {
CODE_FILE_PATH,
CODE_FUNCTION_NAME,
HTTP_REQUEST_METHOD,
SENTRY_DESCRIPTION,
Expand Down Expand Up @@ -109,8 +110,7 @@ describe('sentryGlobalFunctionMiddleware', () => {
[CODE_FUNCTION_NAME]: 'testLog',
[HTTP_REQUEST_METHOD]: 'POST',
[SENTRY_DESCRIPTION]: 'POST /_serverFn/testLog',
'tanstackstart.function.id': 'abc123',
'tanstackstart.function.filename': 'src/routes/test.tsx',
[CODE_FILE_PATH]: 'src/routes/test.tsx',
},
},
expect.any(Function),
Expand Down
Loading