Skip to content

Commit 7538f3b

Browse files
committed
refactor how instrumentation works
1 parent 8ea51ef commit 7538f3b

File tree

3 files changed

+18
-26
lines changed

3 files changed

+18
-26
lines changed

docs/v8-node.md

+2-6
Original file line numberDiff line numberDiff line change
@@ -81,22 +81,18 @@ working on this during the v8 alpha/beta cycle.
8181
### Using Custom OpenTelemetry Instrumentation
8282

8383
While we include some vetted OpenTelemetry instrumentation out of the box, you can also add your own instrumentation on
84-
top of that. You can do that by installing an instrumentation package (as well as `@opentelemetry/instrumentation`) and
85-
setting it up like this:
84+
top of that. You can do that by installing an instrumentation package and setting it up like this:
8685

8786
```js
8887
const Sentry = require('@sentry/node');
8988
const { GenericPoolInstrumentation } = require('@opentelemetry/instrumentation-generic-pool');
90-
const { registerInstrumentations } = require('@opentelemetry/instrumentation');
9189

9290
Sentry.init({
9391
dsn: '__DSN__',
9492
});
9593

9694
// Afterwards, you can add additional instrumentation:
97-
registerInsturmentations({
98-
instrumentations: [new GenericPoolInstrumentation()],
99-
});
95+
Sentry.addOpenTelemetryInstrumentation(new GenericPoolInstrumentation());
10096
```
10197

10298
### Using a Custom OpenTelemetry Setup

packages/aws-serverless/src/integration/aws.ts

+8-10
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
1-
import { registerInstrumentations } from '@opentelemetry/instrumentation';
21
import { AwsInstrumentation } from '@opentelemetry/instrumentation-aws-sdk';
32
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, defineIntegration } from '@sentry/core';
3+
import { addOpenTelemetryInstrumentation } from '@sentry/node';
44
import type { IntegrationFn } from '@sentry/types';
55

66
const _awsIntegration = (() => {
77
return {
88
name: 'Aws',
99
setupOnce() {
10-
registerInstrumentations({
11-
instrumentations: [
12-
new AwsInstrumentation({
13-
preRequestHook(span) {
14-
span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, 'auto.otel.aws');
15-
},
16-
}),
17-
],
18-
});
10+
addOpenTelemetryInstrumentation(
11+
new AwsInstrumentation({
12+
preRequestHook(span) {
13+
span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, 'auto.otel.aws');
14+
},
15+
}),
16+
);
1917
},
2018
};
2119
}) satisfies IntegrationFn;

packages/aws-serverless/src/integration/awslambda.ts

+8-10
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
1-
import { registerInstrumentations } from '@opentelemetry/instrumentation';
21
import { AwsLambdaInstrumentation } from '@opentelemetry/instrumentation-aws-lambda';
32
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, defineIntegration } from '@sentry/core';
3+
import { addOpenTelemetryInstrumentation } from '@sentry/node';
44
import type { IntegrationFn } from '@sentry/types';
55

66
const _awsLambdaIntegration = (() => {
77
return {
88
name: 'AwsLambda',
99
setupOnce() {
10-
registerInstrumentations({
11-
instrumentations: [
12-
new AwsLambdaInstrumentation({
13-
requestHook(span) {
14-
span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, 'auto.otel.aws-lambda');
15-
},
16-
}),
17-
],
18-
});
10+
addOpenTelemetryInstrumentation(
11+
new AwsLambdaInstrumentation({
12+
requestHook(span) {
13+
span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, 'auto.otel.aws-lambda');
14+
},
15+
}),
16+
);
1917
},
2018
};
2119
}) satisfies IntegrationFn;

0 commit comments

Comments
 (0)