Skip to content
Merged
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
8 changes: 6 additions & 2 deletions packages/node-experimental/src/integrations/node-fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { registerInstrumentations } from '@opentelemetry/instrumentation';
import { addBreadcrumb, defineIntegration } from '@sentry/core';
import { _INTERNAL, getSpanKind } from '@sentry/opentelemetry';
import type { IntegrationFn } from '@sentry/types';
import { logger } from '@sentry/utils';
import { DEBUG_BUILD } from '../debug-build';
import { NODE_MAJOR } from '../nodeVersion';

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

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

Expand All @@ -53,6 +56,7 @@ const _nativeNodeFetchIntegration = ((options: NodeFetchOptions = {}) => {
];
} catch (error) {
// Could not load instrumentation
DEBUG_BUILD && logger.log('Could not load NodeFetch instrumentation.');
}
}

Expand Down