Skip to content

Commit 00dea2a

Browse files
committed
ref(node): Do not manually finish / update root Hapi spans.
1 parent f4dcfdb commit 00dea2a

File tree

2 files changed

+15
-13
lines changed
  • dev-packages/e2e-tests/test-applications/node-hapi/tests
  • packages/node/src/integrations/tracing/hapi

2 files changed

+15
-13
lines changed

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
11
import { expect, test } from '@playwright/test';
2-
import { waitForError } from '@sentry-internal/event-proxy-server';
2+
import { waitForError, waitForTransaction } from '@sentry-internal/event-proxy-server';
33

44
test('Sends thrown error to Sentry', async ({ baseURL }) => {
55
const errorEventPromise = waitForError('node-hapi', errorEvent => {
66
return errorEvent?.exception?.values?.[0]?.value === 'This is an error';
77
});
88

9+
const transactionEventPromise = waitForTransaction('node-hapi', transactionEvent => {
10+
return transactionEvent?.transaction === 'GET /test-failure';
11+
});
12+
913
await fetch(`${baseURL}/test-failure`);
1014

1115
const errorEvent = await errorEventPromise;
12-
const errorEventId = errorEvent.event_id;
16+
const transactionEvent = await transactionEventPromise;
17+
18+
expect(transactionEvent.transaction).toBe('GET /test-failure');
19+
expect(transactionEvent.contexts?.trace).toMatchObject({
20+
trace_id: expect.any(String),
21+
span_id: expect.any(String),
22+
});
1323

1424
expect(errorEvent.exception?.values).toHaveLength(1);
1525
expect(errorEvent.exception?.values?.[0]?.value).toBe('This is an error');
@@ -27,6 +37,9 @@ test('Sends thrown error to Sentry', async ({ baseURL }) => {
2737
trace_id: expect.any(String),
2838
span_id: expect.any(String),
2939
});
40+
41+
expect(errorEvent.contexts?.trace?.trace_id).toBe(transactionEvent.contexts?.trace?.trace_id);
42+
expect(errorEvent.contexts?.trace?.span_id).toBe(transactionEvent.contexts?.trace?.span_id);
3043
});
3144

3245
test('sends error with parameterized transaction name', async ({ baseURL }) => {

packages/node/src/integrations/tracing/hapi/index.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,11 @@ import {
33
SDK_VERSION,
44
SEMANTIC_ATTRIBUTE_SENTRY_OP,
55
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
6-
SPAN_STATUS_ERROR,
76
captureException,
87
defineIntegration,
9-
getActiveSpan,
108
getClient,
119
getDefaultIsolationScope,
1210
getIsolationScope,
13-
getRootSpan,
1411
spanToJSON,
1512
} from '@sentry/core';
1613
import type { IntegrationFn, Span } from '@sentry/types';
@@ -79,19 +76,11 @@ export const hapiErrorPlugin = {
7976
logger.warn('Isolation scope is still the default isolation scope - skipping setting transactionName');
8077
}
8178

82-
const activeSpan = getActiveSpan();
83-
const rootSpan = activeSpan ? getRootSpan(activeSpan) : undefined;
84-
8579
if (request.response && isBoomObject(request.response)) {
8680
sendErrorToSentry(request.response);
8781
} else if (isErrorEvent(event)) {
8882
sendErrorToSentry(event.error);
8983
}
90-
91-
if (rootSpan) {
92-
rootSpan.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });
93-
rootSpan.end();
94-
}
9584
});
9685
},
9786
};

0 commit comments

Comments
 (0)