Skip to content

Commit 2a3d81b

Browse files
authored
fix(node): Add logs when node-fetch cannot be instrumented (#11289)
Addressing #11215, this updates the logs for `NodeFetch` to make it clearer what is happening. Also, we actually do not support Node <18 there, so updating this accordingly too.
1 parent 7325abb commit 2a3d81b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/node-experimental/src/integrations/node-fetch.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { registerInstrumentations } from '@opentelemetry/instrumentation';
55
import { addBreadcrumb, defineIntegration } from '@sentry/core';
66
import { _INTERNAL, getSpanKind } from '@sentry/opentelemetry';
77
import type { IntegrationFn } from '@sentry/types';
8+
import { logger } from '@sentry/utils';
9+
import { DEBUG_BUILD } from '../debug-build';
810
import { NODE_MAJOR } from '../nodeVersion';
911

1012
import { addOriginToSpan } from '../utils/addOriginToSpan';
@@ -28,8 +30,9 @@ const _nativeNodeFetchIntegration = ((options: NodeFetchOptions = {}) => {
2830
const _ignoreOutgoingRequests = options.ignoreOutgoingRequests;
2931

3032
async function getInstrumentation(): Promise<[Instrumentation] | void> {
31-
// Only add NodeFetch if Node >= 16, as previous versions do not support it
32-
if (NODE_MAJOR < 16) {
33+
// Only add NodeFetch if Node >= 18, as previous versions do not support it
34+
if (NODE_MAJOR < 18) {
35+
DEBUG_BUILD && logger.log('NodeFetch is not supported on Node < 18, skipping instrumentation...');
3336
return;
3437
}
3538

@@ -53,6 +56,7 @@ const _nativeNodeFetchIntegration = ((options: NodeFetchOptions = {}) => {
5356
];
5457
} catch (error) {
5558
// Could not load instrumentation
59+
DEBUG_BUILD && logger.log('Could not load NodeFetch instrumentation.');
5660
}
5761
}
5862

0 commit comments

Comments
 (0)