Skip to content

Commit 214305b

Browse files
authored
feat: Deprecate addOpenTelemetryInstrumentation (#14485)
1 parent be73e38 commit 214305b

File tree

15 files changed

+36
-21
lines changed

15 files changed

+36
-21
lines changed

docs/migration/draft-v9-migration-guide.md

+1
Original file line numberDiff line numberDiff line change
@@ -106,5 +106,6 @@
106106
- Deprecated `processThreadBreadcrumbIntegration` in favor of `childProcessIntegration`. Functionally they are the same.
107107
- Deprecated `nestIntegration`. Use the NestJS SDK (`@sentry/nestjs`) instead.
108108
- Deprecated `setupNestErrorHandler`. Use the NestJS SDK (`@sentry/nestjs`) instead.
109+
- Deprecated `addOpenTelemetryInstrumentation`. Use the `openTelemetryInstrumentations` option in `Sentry.init()` or your custom Sentry Client instead.
109110
- Deprecated `registerEsmLoaderHooks.include` and `registerEsmLoaderHooks.exclude`. Set `onlyIncludeInstrumentedModules: true` instead.
110111
- `registerEsmLoaderHooks` will only accept `true | false | undefined` in the future. The SDK will default to wrapping modules that are used as part of OpenTelemetry Instrumentation.

packages/astro/src/index.server.ts

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export {
1111
addBreadcrumb,
1212
addEventProcessor,
1313
addIntegration,
14+
// eslint-disable-next-line deprecation/deprecation
1415
addOpenTelemetryInstrumentation,
1516
// eslint-disable-next-line deprecation/deprecation
1617
addRequestDataToEvent,

packages/aws-serverless/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
"access": "public"
6565
},
6666
"dependencies": {
67+
"@opentelemetry/instrumentation": "^0.54.0",
6768
"@opentelemetry/instrumentation-aws-lambda": "0.44.0",
6869
"@opentelemetry/instrumentation-aws-sdk": "0.45.0",
6970
"@sentry/core": "8.41.0",

packages/aws-serverless/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ export {
120120
spanToTraceHeader,
121121
spanToBaggageHeader,
122122
trpcMiddleware,
123+
// eslint-disable-next-line deprecation/deprecation
123124
addOpenTelemetryInstrumentation,
124125
zodErrorsIntegration,
125126
profiler,
+15-16
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
1+
import { registerInstrumentations } from '@opentelemetry/instrumentation';
12
import { AwsInstrumentation } from '@opentelemetry/instrumentation-aws-sdk';
23
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, defineIntegration } from '@sentry/core';
3-
import { addOpenTelemetryInstrumentation } from '@sentry/node';
4-
import type { IntegrationFn } from '@sentry/types';
54

6-
const _awsIntegration = (() => {
5+
/**
6+
* Instrumentation for aws-sdk package
7+
*/
8+
export const awsIntegration = defineIntegration(() => {
79
return {
810
name: 'Aws',
911
setupOnce() {
10-
addOpenTelemetryInstrumentation(
11-
new AwsInstrumentation({
12-
preRequestHook(span) {
13-
span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, 'auto.otel.aws');
14-
},
15-
}),
16-
);
12+
registerInstrumentations({
13+
instrumentations: [
14+
new AwsInstrumentation({
15+
preRequestHook(span) {
16+
span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, 'auto.otel.aws');
17+
},
18+
}),
19+
],
20+
});
1721
},
1822
};
19-
}) satisfies IntegrationFn;
20-
21-
/**
22-
* Instrumentation for aws-sdk package
23-
*/
24-
export const awsIntegration = defineIntegration(_awsIntegration);
23+
});

packages/bun/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ export {
140140
spanToTraceHeader,
141141
spanToBaggageHeader,
142142
trpcMiddleware,
143+
// eslint-disable-next-line deprecation/deprecation
143144
addOpenTelemetryInstrumentation,
144145
zodErrorsIntegration,
145146
profiler,

packages/google-cloud-serverless/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ export {
117117
spanToTraceHeader,
118118
spanToBaggageHeader,
119119
trpcMiddleware,
120+
// eslint-disable-next-line deprecation/deprecation
120121
addOpenTelemetryInstrumentation,
121122
zodErrorsIntegration,
122123
profiler,

packages/node/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export type { NodeOptions } from './types';
6161
export { addRequestDataToEvent, DEFAULT_USER_INCLUDES, extractRequestData } from '@sentry/core';
6262

6363
export {
64+
// eslint-disable-next-line deprecation/deprecation
6465
addOpenTelemetryInstrumentation,
6566
// These are custom variants that need to be used instead of the core one
6667
// As they have slightly different implementations

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
import { registerInstrumentations } from '@opentelemetry/instrumentation';
12
import type { UndiciRequest, UndiciResponse } from '@opentelemetry/instrumentation-undici';
23
import { UndiciInstrumentation } from '@opentelemetry/instrumentation-undici';
34
import { LRUMap, getClient, getTraceData } from '@sentry/core';
45
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, addBreadcrumb, defineIntegration, hasTracingEnabled } from '@sentry/core';
56
import { getBreadcrumbLogLevelFromHttpStatusCode, getSanitizedUrlString, parseUrl } from '@sentry/core';
6-
import { addOpenTelemetryInstrumentation, shouldPropagateTraceForUrl } from '@sentry/opentelemetry';
7+
import { shouldPropagateTraceForUrl } from '@sentry/opentelemetry';
78
import type { IntegrationFn, SanitizedRequestData } from '@sentry/types';
89

910
interface NodeFetchOptions {
@@ -74,7 +75,7 @@ const _nativeNodeFetchIntegration = ((options: NodeFetchOptions = {}) => {
7475
},
7576
});
7677

77-
addOpenTelemetryInstrumentation(instrumentation);
78+
registerInstrumentations({ instrumentations: [instrumentation] });
7879
},
7980
};
8081
}) satisfies IntegrationFn;

packages/node/src/otel/instrument.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import type { Instrumentation } from '@opentelemetry/instrumentation';
2-
import { addOpenTelemetryInstrumentation } from '@sentry/opentelemetry';
1+
import { type Instrumentation, registerInstrumentations } from '@opentelemetry/instrumentation';
32

43
/** Exported only for tests. */
54
export const INSTRUMENTED: Record<string, Instrumentation> = {};
@@ -26,7 +25,9 @@ export function generateInstrumentOnce<Options = unknown>(
2625
const instrumentation = creator(options);
2726
INSTRUMENTED[name] = instrumentation;
2827

29-
addOpenTelemetryInstrumentation(instrumentation);
28+
registerInstrumentations({
29+
instrumentations: [instrumentation],
30+
});
3031
},
3132
{ id: name },
3233
);

packages/opentelemetry/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export {
5858

5959
export { openTelemetrySetupCheck } from './utils/setupCheck';
6060

61+
// eslint-disable-next-line deprecation/deprecation
6162
export { addOpenTelemetryInstrumentation } from './instrumentation';
6263

6364
// Legacy

packages/opentelemetry/src/instrumentation.ts

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import { registerInstrumentations } from '@opentelemetry/instrumentation';
44
/**
55
* This method takes an OpenTelemetry instrumentation or
66
* array of instrumentations and registers them with OpenTelemetry.
7+
*
8+
* @deprecated This method will be removed in the next major version of the SDK.
9+
* Use the `openTelemetryInstrumentations` option in `Sentry.init()` or your custom Sentry Client instead.
710
*/
811
export function addOpenTelemetryInstrumentation(...instrumentations: Instrumentation[]): void {
912
registerInstrumentations({

packages/remix/src/index.server.ts

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export {
1616
addBreadcrumb,
1717
addEventProcessor,
1818
addIntegration,
19+
// eslint-disable-next-line deprecation/deprecation
1920
addOpenTelemetryInstrumentation,
2021
// eslint-disable-next-line deprecation/deprecation
2122
addRequestDataToEvent,

packages/solidstart/src/server/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export {
77
addBreadcrumb,
88
addEventProcessor,
99
addIntegration,
10+
// eslint-disable-next-line deprecation/deprecation
1011
addOpenTelemetryInstrumentation,
1112
// eslint-disable-next-line deprecation/deprecation
1213
addRequestDataToEvent,

packages/sveltekit/src/server/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export {
77
addBreadcrumb,
88
addEventProcessor,
99
addIntegration,
10+
// eslint-disable-next-line deprecation/deprecation
1011
addOpenTelemetryInstrumentation,
1112
// eslint-disable-next-line deprecation/deprecation
1213
addRequestDataToEvent,

0 commit comments

Comments
 (0)