[operator/nodejs] document disabling node auto-instrumentations (#4824)

This commit is contained in:
Jamie Danielson 2024-07-24 05:55:18 -04:00 committed by GitHub
parent bf49f3af61
commit 114d136a9a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 63 additions and 6 deletions

View File

@ -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

View File

@ -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 %}}