Skip to content

Commit e43cfd9

Browse files
committed
fix(nodejs): make aws-lambda and aws-sdk instrumentations respect OTEL_NODE_DISABLED_INSTRUMENTATIONS
Extends PR open-telemetry#1653 to make AWS-specific instrumentations (aws-lambda, aws-sdk) also respect the OTEL_NODE_DISABLED_INSTRUMENTATIONS environment variable. Previously, these instrumentations were always loaded regardless of the disable flag. Now they follow the same conditional loading pattern as other instrumentations. Fixes: Users can now disable AWS Lambda auto-instrumentation in dev mode
1 parent 1a9cbcb commit e43cfd9

File tree

1 file changed

+33
-13
lines changed

1 file changed

+33
-13
lines changed

nodejs/packages/layer/src/wrapper.ts

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ import { AWSXRayPropagator } from '@opentelemetry/propagator-aws-xray';
4848
import { AWSXRayLambdaPropagator } from '@opentelemetry/propagator-aws-xray-lambda';
4949

5050
const defaultInstrumentationList = [
51+
'aws-lambda',
52+
'aws-sdk',
5153
'dns',
5254
'express',
5355
'graphql',
@@ -309,21 +311,39 @@ async function defaultConfigureInstrumentations() {
309311
}
310312

311313
async function createInstrumentations() {
312-
return [
313-
new AwsInstrumentation(
314-
typeof configureAwsInstrumentation === 'function'
315-
? configureAwsInstrumentation({ suppressInternalInstrumentation: true })
316-
: { suppressInternalInstrumentation: true },
317-
),
318-
new AwsLambdaInstrumentation(
319-
typeof configureLambdaInstrumentation === 'function'
320-
? configureLambdaInstrumentation({})
321-
: {},
322-
),
314+
const activeInstrumentations = getActiveInstumentations();
315+
const instrumentations = [];
316+
317+
// Conditionally load AWS SDK instrumentation
318+
if (activeInstrumentations.has('aws-sdk')) {
319+
instrumentations.push(
320+
new AwsInstrumentation(
321+
typeof configureAwsInstrumentation === 'function'
322+
? configureAwsInstrumentation({ suppressInternalInstrumentation: true })
323+
: { suppressInternalInstrumentation: true },
324+
)
325+
);
326+
}
327+
328+
// Conditionally load AWS Lambda instrumentation
329+
if (activeInstrumentations.has('aws-lambda')) {
330+
instrumentations.push(
331+
new AwsLambdaInstrumentation(
332+
typeof configureLambdaInstrumentation === 'function'
333+
? configureLambdaInstrumentation({})
334+
: {},
335+
)
336+
);
337+
}
338+
339+
// Load other instrumentations
340+
instrumentations.push(
323341
...(typeof configureInstrumentations === 'function'
324342
? configureInstrumentations()
325-
: await defaultConfigureInstrumentations()),
326-
];
343+
: await defaultConfigureInstrumentations())
344+
);
345+
346+
return instrumentations;
327347
}
328348

329349
function getPropagator(): TextMapPropagator {

0 commit comments

Comments
 (0)