Skip to content

Commit 47342f3

Browse files
authored
ref(node): Add mechanism to errors captured via connect and koa integrations (#17579)
Adds mechanism following the trace origin naming scheme closes #17261 ref: #17212
1 parent 1917899 commit 47342f3

File tree

4 files changed

+26
-4
lines changed

4 files changed

+26
-4
lines changed

dev-packages/e2e-tests/test-applications/node-connect/tests/errors.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@ test('Sends correct error event', async ({ baseURL }) => {
1111
const errorEvent = await errorEventPromise;
1212

1313
expect(errorEvent.exception?.values).toHaveLength(1);
14-
expect(errorEvent.exception?.values?.[0]?.value).toBe('This is an exception');
14+
const exception = errorEvent.exception?.values?.[0];
15+
expect(exception?.value).toBe('This is an exception');
16+
17+
expect(exception?.mechanism).toEqual({
18+
type: 'auto.middleware.connect',
19+
handled: false,
20+
});
1521

1622
expect(errorEvent.request).toEqual({
1723
method: 'GET',

dev-packages/e2e-tests/test-applications/node-koa/tests/errors.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@ test('Sends correct error event', async ({ baseURL }) => {
1111
const errorEvent = await errorEventPromise;
1212

1313
expect(errorEvent.exception?.values).toHaveLength(1);
14-
expect(errorEvent.exception?.values?.[0]?.value).toBe('This is an exception with id 123');
14+
const exception = errorEvent.exception?.values?.[0];
15+
16+
expect(exception?.value).toBe('This is an exception with id 123');
17+
expect(exception?.mechanism).toEqual({
18+
type: 'auto.middleware.koa',
19+
handled: false,
20+
});
1521

1622
expect(errorEvent.request).toEqual({
1723
method: 'GET',

packages/node/src/integrations/tracing/connect.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,12 @@ export const connectIntegration = defineIntegration(_connectIntegration);
4848

4949
// eslint-disable-next-line @typescript-eslint/no-explicit-any
5050
function connectErrorMiddleware(err: any, req: any, res: any, next: any): void {
51-
captureException(err);
51+
captureException(err, {
52+
mechanism: {
53+
handled: false,
54+
type: 'auto.middleware.connect',
55+
},
56+
});
5257
next(err);
5358
}
5459

packages/node/src/integrations/tracing/koa.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,12 @@ export const setupKoaErrorHandler = (app: { use: (arg0: (ctx: any, next: any) =>
134134
try {
135135
await next();
136136
} catch (error) {
137-
captureException(error);
137+
captureException(error, {
138+
mechanism: {
139+
handled: false,
140+
type: 'auto.middleware.koa',
141+
},
142+
});
138143
throw error;
139144
}
140145
});

0 commit comments

Comments
 (0)