From 756f4093ba75f1743b83bd1a724052303380d723 Mon Sep 17 00:00:00 2001 From: Ats Uiboupin Date: Thu, 11 Apr 2024 14:14:16 +0300 Subject: [PATCH 1/2] doc(js-autoinstrumentation): document JS auto-instrumentation #4130 --- .../languages/js/automatic/configuration.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/content/en/docs/languages/js/automatic/configuration.md b/content/en/docs/languages/js/automatic/configuration.md index df0c7a12bc06..fd1d0df63d23 100644 --- a/content/en/docs/languages/js/automatic/configuration.md +++ b/content/en/docs/languages/js/automatic/configuration.md @@ -39,3 +39,22 @@ For example, to only enable the `env` and `host` detectors, you can set: ```shell OTEL_NODE_RESOURCE_DETECTORS=env,host ``` + +### Excluding auto-instrumentation + +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 package 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) +and +[@opentelemetry/instrumentation-express](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-express) +instrumentations: + +```shell +OTEL_NODE_ENABLED_INSTRUMENTATIONS="http,express" +``` From 87a3835fd90c53ff3d2a8471c553562caf46ae39 Mon Sep 17 00:00:00 2001 From: Ats Uiboupin Date: Tue, 12 Mar 2024 09:56:52 +0200 Subject: [PATCH 2/2] doc(k8s-operator): document customizing enabled auto-instrumentations for nodejs with kubernetes-operator Closes 4130 --- .../en/docs/kubernetes/operator/automatic.md | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/content/en/docs/kubernetes/operator/automatic.md b/content/en/docs/kubernetes/operator/automatic.md index 10899e528c46..f620ec2a37a7 100644 --- a/content/en/docs/kubernetes/operator/automatic.md +++ b/content/en/docs/kubernetes/operator/automatic.md @@ -282,12 +282,24 @@ must be able to receive OTLP over `grpc`. Therefore, the example uses #### Excluding auto-instrumentation {#js-excluding-auto-instrumentation} -By default, the Node.js auto-instrumentation ships with -[many instrumentation libraries](https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/metapackages/auto-instrumentations-node/README.md#supported-instrumentations). -At the moment, there is no way to opt-in to only specific packages or disable -specific packages. If you don't want to use a package included by the default -image you must either supply your own image that includes only the packages you -want or use manual instrumentation. +By default, the Node.js auto-instrumentation has all the instrumentation +libraries enabled. + +To enable only specific instrumentations you can use the +`OTEL_NODE_ENABLED_INSTRUMENTATIONS` environment variable as documented in the +[Node.js auto-instrumentation documentation](/docs/languages/js/automatic/configuration/#excluding-auto-instrumentation). + +```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_ENABLED_INSTRUMENTATIONS + value: http,nestjs-core # comma-separated list of the instrumentation package names without the `@opentelemetry/instrumentation-` prefix. +``` #### Learn more {#js-learn-more}