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 @@ -11,7 +11,13 @@ test('Sends correct error event', async ({ baseURL }) => {
const errorEvent = await errorEventPromise;

expect(errorEvent.exception?.values).toHaveLength(1);
expect(errorEvent.exception?.values?.[0]?.value).toBe('This is an exception');
const exception = errorEvent.exception?.values?.[0];
expect(exception?.value).toBe('This is an exception');

expect(exception?.mechanism).toEqual({
type: 'auto.middleware.connect',
handled: false,
});

expect(errorEvent.request).toEqual({
method: 'GET',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ test('Sends correct error event', async ({ baseURL }) => {
const errorEvent = await errorEventPromise;

expect(errorEvent.exception?.values).toHaveLength(1);
expect(errorEvent.exception?.values?.[0]?.value).toBe('This is an exception with id 123');
const exception = errorEvent.exception?.values?.[0];

expect(exception?.value).toBe('This is an exception with id 123');
expect(exception?.mechanism).toEqual({
type: 'auto.middleware.koa',
handled: false,
});

expect(errorEvent.request).toEqual({
method: 'GET',
Expand Down
7 changes: 6 additions & 1 deletion packages/node/src/integrations/tracing/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,12 @@ export const connectIntegration = defineIntegration(_connectIntegration);

// eslint-disable-next-line @typescript-eslint/no-explicit-any
function connectErrorMiddleware(err: any, req: any, res: any, next: any): void {
captureException(err);
captureException(err, {
mechanism: {
handled: false,
type: 'auto.middleware.connect',
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Span Origin Mismatch for Exception Capture

The mechanism type should align with SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN when a span wraps the captureException call. Connect spans use 'auto.http.otel.connect' as their origin, so the mechanism type should be 'auto.http.otel.connect' instead of 'auto.middleware.connect'.

Fix in Cursor Fix in Web

},
});
next(err);
}

Expand Down
7 changes: 6 additions & 1 deletion packages/node/src/integrations/tracing/koa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,12 @@ export const setupKoaErrorHandler = (app: { use: (arg0: (ctx: any, next: any) =>
try {
await next();
} catch (error) {
captureException(error);
captureException(error, {
mechanism: {
handled: false,
type: 'auto.middleware.koa',
},
});
throw error;
}
});
Expand Down
Loading