Skip to content

Commit 93b0b34

Browse files
committed
feat(core, node): portable Connect integration (#20882)
Platform-portable Connect tracing integration in `@sentry/core` (`patchConnectModule`, `setupConnectErrorHandler`), similar to portable Express integration, and rewire the Node SDK's Connect integration to call into it through the otel InstrumentationBase class. Remove OTel-specific span attribute fix-up. Spans created with correct origin (`auto.http.connect`) and op directly in the middleware.
1 parent 7f2aa3d commit 93b0b34

6 files changed

Lines changed: 843 additions & 88 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ test('Sends an API route transaction', async ({ baseURL }) => {
7272
},
7373
{
7474
data: {
75-
'sentry.origin': 'auto.http.otel.connect',
75+
'sentry.origin': 'auto.http.connect',
7676
'sentry.op': 'request_handler.connect',
7777
'http.route': '/test-transaction',
7878
'connect.type': 'request_handler',
@@ -86,7 +86,7 @@ test('Sends an API route transaction', async ({ baseURL }) => {
8686
status: 'ok',
8787
timestamp: expect.any(Number),
8888
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
89-
origin: 'auto.http.otel.connect',
89+
origin: 'auto.http.connect',
9090
},
9191
],
9292
transaction: 'GET /test-transaction',

dev-packages/node-integration-tests/suites/tracing/connect/test.ts

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ describe('connect auto-instrumentation', () => {
1414
'connect.name': '/',
1515
'connect.type': 'request_handler',
1616
'http.route': '/',
17-
'sentry.origin': 'auto.http.otel.connect',
17+
'sentry.origin': 'auto.http.connect',
1818
'sentry.op': 'request_handler.connect',
1919
}),
2020
description: '/',
21-
origin: 'auto.http.otel.connect',
21+
origin: 'auto.http.connect',
2222
op: 'request_handler.connect',
2323
status: 'ok',
2424
}),
@@ -36,32 +36,26 @@ describe('connect auto-instrumentation', () => {
3636
},
3737
};
3838

39-
createEsmAndCjsTests(
40-
__dirname,
41-
'scenario.mjs',
42-
'instrument.mjs',
43-
(createTestRunner, test) => {
44-
test('should auto-instrument `connect` package.', async () => {
45-
const runner = createTestRunner().expect({ transaction: EXPECTED_TRANSACTION }).start();
46-
runner.makeRequest('get', '/');
47-
await runner.completed();
48-
});
39+
createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument.mjs', (createTestRunner, test) => {
40+
test('should auto-instrument `connect` package.', async () => {
41+
const runner = createTestRunner().expect({ transaction: EXPECTED_TRANSACTION }).start();
42+
runner.makeRequest('get', '/');
43+
await runner.completed();
44+
});
4945

50-
test('should capture errors in `connect` middleware.', async () => {
51-
const runner = createTestRunner().ignore('transaction').expect({ event: EXPECTED_EVENT }).start();
52-
runner.makeRequest('get', '/error');
53-
await runner.completed();
54-
});
46+
test('should capture errors in `connect` middleware.', async () => {
47+
const runner = createTestRunner().ignore('transaction').expect({ event: EXPECTED_EVENT }).start();
48+
runner.makeRequest('get', '/error');
49+
await runner.completed();
50+
});
5551

56-
test('should report errored transactions.', async () => {
57-
const runner = createTestRunner()
58-
.ignore('event')
59-
.expect({ transaction: { transaction: 'GET /error' } })
60-
.start();
61-
runner.makeRequest('get', '/error');
62-
await runner.completed();
63-
});
64-
},
65-
{ failsOnEsm: true },
66-
);
52+
test('should report errored transactions.', async () => {
53+
const runner = createTestRunner()
54+
.ignore('event')
55+
.expect({ transaction: { transaction: 'GET /error' } })
56+
.start();
57+
runner.makeRequest('get', '/error');
58+
await runner.completed();
59+
});
60+
});
6761
});

0 commit comments

Comments
 (0)