diff --git a/content/en/docs/kubernetes/operator/automatic.md b/content/en/docs/kubernetes/operator/automatic.md index 3fe3c12a41f6..00bd1227fa36 100644 --- a/content/en/docs/kubernetes/operator/automatic.md +++ b/content/en/docs/kubernetes/operator/automatic.md @@ -300,6 +300,32 @@ spec: value: http,nestjs-core # comma-separated list of the instrumentation package names without the `@opentelemetry/instrumentation-` prefix. ``` +To keep all default libraries and disable only specific instrumentation +libraries you can use the `OTEL_NODE_DISABLED_INSTRUMENTATIONS` environment +variable. For details, see +[Excluding instrumentation libraries](/docs/zero-code/js/configuration/#excluding-instrumentation-libraries). + +```yaml +apiVersion: opentelemetry.io/v1alpha1 +kind: Instrumentation +# ... other fields skipped from this example +spec: + # ... other fields skipped from this example + nodejs: + env: + - name: OTEL_NODE_DISABLED_INSTRUMENTATIONS + value: fs,grpc # comma-separated list of the instrumentation package names without the `@opentelemetry/instrumentation-` prefix. +``` + +{{% alert title="Note" color="info" %}} + +If both environment variables are set, `OTEL_NODE_ENABLED_INSTRUMENTATIONS` is +applied first, and then `OTEL_NODE_DISABLED_INSTRUMENTATIONS` is applied to that +list. Therefore, if the same instrumentation is included in both lists, that +instrumentation will be disabled. + +{{% /alert %}} + #### Learn more {#js-learn-more} For more details, see diff --git a/content/en/docs/zero-code/js/configuration.md b/content/en/docs/zero-code/js/configuration.md index 0511991b6373..3bf7fc47cf99 100644 --- a/content/en/docs/zero-code/js/configuration.md +++ b/content/en/docs/zero-code/js/configuration.md @@ -45,17 +45,22 @@ For example, to only enable the `env` and `host` detectors, you can set: OTEL_NODE_RESOURCE_DETECTORS=env,host ``` -### Excluding instrumentation libraries +## Excluding instrumentation libraries By default, all [supported instrumentation libraries](https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/metapackages/auto-instrumentations-node/README.md#supported-instrumentations) -are enabled, but you can use the environment variable -`OTEL_NODE_ENABLED_INSTRUMENTATIONS` to enable only certain instrumentations by -providing a comma-separated list of the instrumentation library names without -the `@opentelemetry/instrumentation-` prefix. +are enabled, but you can use environment variables to enable or disable specific +instrumentations. + +### Enable specific instrumentations + +Use the environment variable `OTEL_NODE_ENABLED_INSTRUMENTATIONS` to enable only +certain instrumentations by providing a comma-separated list of the +instrumentation library names without the `@opentelemetry/instrumentation-` +prefix. For example, to enable only -[@opentelemetry/instrumentation-http](https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-instrumentation-http) +[@opentelemetry/instrumentation-http](https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/opentelemetry-instrumentation-http) and [@opentelemetry/instrumentation-express](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-express) instrumentations: @@ -63,3 +68,29 @@ instrumentations: ```shell OTEL_NODE_ENABLED_INSTRUMENTATIONS="http,express" ``` + +### Disable specific instrumentations + +Use the environment variable `OTEL_NODE_DISABLED_INSTRUMENTATIONS` to keep the +fully enabled list and only disable certain instrumentations by providing a +comma-separated list of the instrumentation library names without the +`@opentelemetry/instrumentation-` prefix. + +For example, to disable only +[@opentelemetry/instrumentation-fs](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/instrumentation-fs) +and +[@opentelemetry/instrumentation-grpc](https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/opentelemetry-instrumentation-grpc) +instrumentations: + +```shell +OTEL_NODE_DISABLED_INSTRUMENTATIONS="fs,grpc" +``` + +{{% alert title="Note" color="info" %}} + +If both environment variables are set, `OTEL_NODE_ENABLED_INSTRUMENTATIONS` is +applied first, and then `OTEL_NODE_DISABLED_INSTRUMENTATIONS` is applied to that +list. Therefore, if the same instrumentation is included in both lists, that +instrumentation will be disabled. + +{{% /alert %}}