Skip to content

Commit 51e6aa1

Browse files
committed
feat: Deprecate addOpenTelemetryInstrumentation
1 parent 1d32374 commit 51e6aa1

File tree

11 files changed

+32
-25
lines changed

11 files changed

+32
-25
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,4 @@
9090
- Deprecated `processThreadBreadcrumbIntegration` in favor of `childProcessIntegration`. Functionally they are the same.
9191
- Deprecated `nestIntegration`. Use the NestJS SDK (`@sentry/nestjs`) instead.
9292
- Deprecated `setupNestErrorHandler`. Use the NestJS SDK (`@sentry/nestjs`) instead.
93+
- Deprecated `addOpenTelemetryInstrumentation`. Use the `openTelemetryInstrumentations` option in `Sentry.init()` or your custom Sentry Client instead.

packages/astro/src/index.server.ts

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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.40.0",

packages/aws-serverless/src/index.ts

Lines changed: 1 addition & 0 deletions
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,
Lines changed: 15 additions & 16 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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/integrations/node-fetch.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { context, propagation, trace } from '@opentelemetry/api';
2+
import { registerInstrumentations } from '@opentelemetry/instrumentation';
23
import type { UndiciRequest, UndiciResponse } from '@opentelemetry/instrumentation-undici';
34
import { UndiciInstrumentation } from '@opentelemetry/instrumentation-undici';
45
import {
@@ -9,11 +10,7 @@ import {
910
hasTracingEnabled,
1011
} from '@sentry/core';
1112
import { getBreadcrumbLogLevelFromHttpStatusCode, getSanitizedUrlString, parseUrl } from '@sentry/core';
12-
import {
13-
addOpenTelemetryInstrumentation,
14-
generateSpanContextForPropagationContext,
15-
getPropagationContextFromSpan,
16-
} from '@sentry/opentelemetry';
13+
import { generateSpanContextForPropagationContext, getPropagationContextFromSpan } from '@sentry/opentelemetry';
1714
import type { IntegrationFn, SanitizedRequestData } from '@sentry/types';
1815

1916
interface NodeFetchOptions {
@@ -94,7 +91,7 @@ const _nativeNodeFetchIntegration = ((options: NodeFetchOptions = {}) => {
9491
},
9592
});
9693

97-
addOpenTelemetryInstrumentation(instrumentation);
94+
registerInstrumentations({ instrumentations: [instrumentation] });
9895
},
9996
};
10097
}) satisfies IntegrationFn;

packages/node/src/otel/instrument.ts

Lines changed: 4 additions & 3 deletions
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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export {
5353

5454
export { openTelemetrySetupCheck } from './utils/setupCheck';
5555

56+
// eslint-disable-next-line deprecation/deprecation
5657
export { addOpenTelemetryInstrumentation } from './instrumentation';
5758

5859
// Legacy

packages/opentelemetry/src/instrumentation.ts

Lines changed: 3 additions & 0 deletions
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({

0 commit comments

Comments
 (0)