Skip to content

Commit

Permalink
feat: allow disabling auto-instrumentations using env variable
Browse files Browse the repository at this point in the history
While I am pretty happy with provided default instrumentations I would like
to be able to disable some of them based on environment variables alone
without getting into business of configuring integration manually
  • Loading branch information
maxkomarychev committed Oct 12, 2023
1 parent a8c225d commit 8907b2b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion metapackages/auto-instrumentations-node/src/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,17 @@ diag.setLogger(
opentelemetry.core.getEnv().OTEL_LOG_LEVEL
);

const disabledAutoinstrumentations = (
process.env.OTEL_DISABLED_AUTOINSTRUMENTATIONS ?? ''
).split(',');

const sdk = new opentelemetry.NodeSDK({
instrumentations: getNodeAutoInstrumentations(),
instrumentations: getNodeAutoInstrumentations(
Object.fromEntries(
disabledAutoinstrumentations.map(instrumentationName =>
[instrumentationName, { enabled: false }]
))
),
resourceDetectors: getResourceDetectorsFromEnv(),
});

Expand Down

0 comments on commit 8907b2b

Please sign in to comment.