Skip to content
Merged
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 @@ -48,3 +48,5 @@ export const handleError: HandleErrorFunction = (error, { request }) => {
};

export default Sentry.wrapSentryHandleRequest(handleRequest);

export const instrumentations = [Sentry.createSentryServerInstrumentation()];
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ const handleRequest = Sentry.createSentryHandleRequest({
export default handleRequest;

export const handleError: HandleErrorFunction = Sentry.createSentryHandleError({ logErrors: true });

export const instrumentations = [Sentry.createSentryServerInstrumentation()];
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,12 @@ test.describe('server-side errors', () => {
value: errorMessage,
mechanism: {
handled: false,
type: 'react-router',
type: 'react_router.loader',
},
},
],
},
// Express names the transaction on Node and Deno. On Bun, where Express is not instrumented under
// `bun run`, it stays the request path. On Cloudflare the error has no transaction.
// todo: should be 'GET /errors/server-loader' everywhere
...(RUNTIME === 'cloudflare'
? {}
: { transaction: RUNTIME === 'bun' ? 'GET /errors/server-loader' : 'GET /{*splat}' }),
transaction: 'GET /errors/server-loader',
request: {
url: expect.stringContaining('errors/server-loader'),
headers: expect.any(Object),
Expand Down Expand Up @@ -74,17 +69,12 @@ test.describe('server-side errors', () => {
value: errorMessage,
mechanism: {
handled: false,
type: 'react-router',
type: 'react_router.action',
},
},
],
},
// Express names the transaction on Node and Deno. On Bun, where Express is not instrumented under
// `bun run`, it stays the request path. On Cloudflare the error has no transaction.
// todo: should be 'POST /errors/server-action' everywhere
...(RUNTIME === 'cloudflare'
? {}
: { transaction: RUNTIME === 'bun' ? 'POST /errors/server-action.data' : 'POST /{*splat}' }),
transaction: 'POST /errors/server-action',
request: {
url: expect.stringContaining('errors/server-action'),
headers: expect.any(Object),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ test('propagates the trace to an outgoing fetch', async ({ request }) => {
.toBeDefined();
const serverSpan = streamedSpans.find(span => span.is_segment && span.trace_id === traceId && !span.parent_span_id)!;
expect(getSpanOp(serverSpan)).toBe('http.server');
expect(serverSpan.name).toBe('GET /performance/outgoing-fetch');
});
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ test.describe('server - performance', () => {
expect(getSpanOp(span)).toBe('http.server');
expect(span.attributes).toMatchObject({
'sentry.op': { value: 'http.server', type: 'string' },
'sentry.origin': { value: 'auto.http.react_router.request_handler', type: 'string' },
'sentry.origin': { value: 'auto.http.react_router.instrumentation_api', type: 'string' },
'sentry.segment.name.source': { value: 'route', type: 'string' },
'sentry.environment': { value: 'qa', type: 'string' },
'sentry.sdk.name': {
Expand Down Expand Up @@ -56,7 +56,7 @@ test.describe('server - performance', () => {
expect(getSpanOp(span)).toBe('http.server');
expect(span.attributes).toMatchObject({
'sentry.op': { value: 'http.server', type: 'string' },
'sentry.origin': { value: 'auto.http.react_router.request_handler', type: 'string' },
'sentry.origin': { value: 'auto.http.react_router.instrumentation_api', type: 'string' },
'sentry.segment.name.source': { value: 'route', type: 'string' },
'sentry.environment': { value: 'qa', type: 'string' },
'sentry.sdk.name': {
Expand Down
4 changes: 4 additions & 0 deletions packages/react-router/src/cloudflare/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import { isPrerenderRequest } from '../server/serverBuild';
export * from '../client';

export { wrapSentryHandleRequest } from '../server/wrapSentryHandleRequest';
export {
createSentryServerInstrumentation,
type CreateSentryServerInstrumentationOptions,
} from '../server/createServerInstrumentation';

/**
* Injects Sentry trace meta tags into the HTML response by transforming the ReadableStream.
Expand Down
Loading