From 378a5413b3e676d9d54aec307faa367dbdad2493 Mon Sep 17 00:00:00 2001 From: "matteo.gazzetta" Date: Sun, 22 Dec 2024 11:37:07 +0100 Subject: [PATCH 1/6] update nodejs autoinstrumetation, fix #2626 Signed-off-by: matteo.gazzetta --- autoinstrumentation/nodejs/package.json | 6 +- .../nodejs/src/autoinstrumentation.ts | 61 +++++++++++-------- 2 files changed, 37 insertions(+), 30 deletions(-) diff --git a/autoinstrumentation/nodejs/package.json b/autoinstrumentation/nodejs/package.json index 11fc4006ce..39dcd58d68 100644 --- a/autoinstrumentation/nodejs/package.json +++ b/autoinstrumentation/nodejs/package.json @@ -14,8 +14,8 @@ "typescript": "^5.6.3" }, "dependencies": { - "@opentelemetry/exporter-metrics-otlp-grpc": "0.55.0", - "@opentelemetry/auto-instrumentations-node": "0.53.0", - "@opentelemetry/exporter-prometheus": "0.55.0" + "@opentelemetry/exporter-metrics-otlp-grpc": "0.57.0", + "@opentelemetry/auto-instrumentations-node": "0.55.0", + "@opentelemetry/exporter-prometheus": "0.57.0" } } diff --git a/autoinstrumentation/nodejs/src/autoinstrumentation.ts b/autoinstrumentation/nodejs/src/autoinstrumentation.ts index 2a4aabc4a7..a11f4b2e82 100644 --- a/autoinstrumentation/nodejs/src/autoinstrumentation.ts +++ b/autoinstrumentation/nodejs/src/autoinstrumentation.ts @@ -1,18 +1,19 @@ -import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node'; +import { getNodeAutoInstrumentations, getResourceDetectorsFromEnv } from '@opentelemetry/auto-instrumentations-node'; import { OTLPTraceExporter as OTLPProtoTraceExporter } from '@opentelemetry/exporter-trace-otlp-proto'; import { OTLPTraceExporter as OTLPHttpTraceExporter } from '@opentelemetry/exporter-trace-otlp-http'; import { OTLPTraceExporter as OTLPGrpcTraceExporter } from '@opentelemetry/exporter-trace-otlp-grpc'; import { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-grpc'; import { PrometheusExporter } from '@opentelemetry/exporter-prometheus'; import { PeriodicExportingMetricReader } from '@opentelemetry/sdk-metrics'; -import { alibabaCloudEcsDetector } from '@opentelemetry/resource-detector-alibaba-cloud'; -import { awsEc2Detector, awsEksDetector } from '@opentelemetry/resource-detector-aws'; -import { containerDetector } from '@opentelemetry/resource-detector-container'; -import { gcpDetector } from '@opentelemetry/resource-detector-gcp'; -import { envDetector, hostDetector, osDetector, processDetector } from '@opentelemetry/resources'; -import { diag } from '@opentelemetry/api'; +import { diag, DiagConsoleLogger } from '@opentelemetry/api'; + +import { NodeSDK, core } from '@opentelemetry/sdk-node'; + +diag.setLogger( + new DiagConsoleLogger(), + core.getEnv().OTEL_LOG_LEVEL +); -import { NodeSDK } from '@opentelemetry/sdk-node'; function getTraceExporter() { let protocol = process.env.OTEL_EXPORTER_OTLP_PROTOCOL; @@ -52,26 +53,32 @@ function getMetricReader() { const sdk = new NodeSDK({ autoDetectResources: true, - instrumentations: [getNodeAutoInstrumentations()], + instrumentations: getNodeAutoInstrumentations(), traceExporter: getTraceExporter(), metricReader: getMetricReader(), - resourceDetectors: - [ - // Standard resource detectors. - containerDetector, - envDetector, - hostDetector, - osDetector, - processDetector, - - // Cloud resource detectors. - alibabaCloudEcsDetector, - // Ordered AWS Resource Detectors as per: - // https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/processor/resourcedetectionprocessor/README.md#ordering - awsEksDetector, - awsEc2Detector, - gcpDetector, - ], + resourceDetectors: getResourceDetectorsFromEnv() }); -sdk.start(); +try { + sdk.start(); + diag.info('OpenTelemetry automatic instrumentation started successfully'); +} catch (error) { + diag.error( + 'Error initializing OpenTelemetry SDK. Your application is not instrumented and will not produce telemetry', + error + ); +} + +async function shutdown(): Promise { + try { + await sdk.shutdown(); + diag.debug('OpenTelemetry SDK terminated'); + } catch (error) { + diag.error('Error terminating OpenTelemetry SDK', error); + } +} + +// Gracefully shutdown SDK if a SIGTERM is received +process.on('SIGTERM', shutdown); +// Gracefully shutdown SDK if Node.js is exiting normally +process.once('beforeExit', shutdown); From 54c793a208797f220eb3a42874869ec1737d3218 Mon Sep 17 00:00:00 2001 From: "matteo.gazzetta" Date: Tue, 7 Jan 2025 10:18:05 +0100 Subject: [PATCH 2/6] fix: getResourceDetectorsFromEnv as getResourceDetectors export Signed-off-by: matteo.gazzetta --- autoinstrumentation/nodejs/src/autoinstrumentation.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autoinstrumentation/nodejs/src/autoinstrumentation.ts b/autoinstrumentation/nodejs/src/autoinstrumentation.ts index a11f4b2e82..5b3388f69d 100644 --- a/autoinstrumentation/nodejs/src/autoinstrumentation.ts +++ b/autoinstrumentation/nodejs/src/autoinstrumentation.ts @@ -1,4 +1,4 @@ -import { getNodeAutoInstrumentations, getResourceDetectorsFromEnv } from '@opentelemetry/auto-instrumentations-node'; +import { getNodeAutoInstrumentations, getResourceDetectors } from '@opentelemetry/auto-instrumentations-node'; import { OTLPTraceExporter as OTLPProtoTraceExporter } from '@opentelemetry/exporter-trace-otlp-proto'; import { OTLPTraceExporter as OTLPHttpTraceExporter } from '@opentelemetry/exporter-trace-otlp-http'; import { OTLPTraceExporter as OTLPGrpcTraceExporter } from '@opentelemetry/exporter-trace-otlp-grpc'; @@ -56,7 +56,7 @@ const sdk = new NodeSDK({ instrumentations: getNodeAutoInstrumentations(), traceExporter: getTraceExporter(), metricReader: getMetricReader(), - resourceDetectors: getResourceDetectorsFromEnv() + resourceDetectors: getResourceDetectors() }); try { From b9319c65b213c62963ec676e8a330ab0068018db Mon Sep 17 00:00:00 2001 From: "matteo.gazzetta" Date: Wed, 15 Jan 2025 12:03:46 +0100 Subject: [PATCH 3/6] refactor to use directly register from metapackage and simplify deps Signed-off-by: matteo.gazzetta --- autoinstrumentation/nodejs/package.json | 7 +- .../nodejs/src/autoinstrumentation.ts | 84 ------------------- pkg/instrumentation/nodejs.go | 2 +- pkg/instrumentation/nodejs_test.go | 4 +- .../01-assert.yaml | 4 +- .../02-assert.yaml | 2 +- .../01-assert.yaml | 2 +- .../instrumentation-nodejs/01-assert.yaml | 2 +- .../01-assert.yaml | 2 +- .../01-assert.yaml | 2 +- .../must-gather/assert-install-app.yaml | 2 +- 11 files changed, 13 insertions(+), 100 deletions(-) delete mode 100644 autoinstrumentation/nodejs/src/autoinstrumentation.ts diff --git a/autoinstrumentation/nodejs/package.json b/autoinstrumentation/nodejs/package.json index 39dcd58d68..22b8e0dabb 100644 --- a/autoinstrumentation/nodejs/package.json +++ b/autoinstrumentation/nodejs/package.json @@ -4,8 +4,6 @@ "private": true, "scripts": { "clean": "rimraf build/*", - "prepare": "npm run compile", - "compile": "tsc -p .", "postcompile": "copyfiles -f 'build/src/**' build/workspace/ && copyfiles 'node_modules/**' package.json build/workspace/ && npm -C build/workspace prune --omit=dev --no-package-lock" }, "devDependencies": { @@ -14,8 +12,7 @@ "typescript": "^5.6.3" }, "dependencies": { - "@opentelemetry/exporter-metrics-otlp-grpc": "0.57.0", - "@opentelemetry/auto-instrumentations-node": "0.55.0", - "@opentelemetry/exporter-prometheus": "0.57.0" + "@opentelemetry/api": "1.9.0", + "@opentelemetry/auto-instrumentations-node": "0.55.2" } } diff --git a/autoinstrumentation/nodejs/src/autoinstrumentation.ts b/autoinstrumentation/nodejs/src/autoinstrumentation.ts deleted file mode 100644 index 5b3388f69d..0000000000 --- a/autoinstrumentation/nodejs/src/autoinstrumentation.ts +++ /dev/null @@ -1,84 +0,0 @@ -import { getNodeAutoInstrumentations, getResourceDetectors } from '@opentelemetry/auto-instrumentations-node'; -import { OTLPTraceExporter as OTLPProtoTraceExporter } from '@opentelemetry/exporter-trace-otlp-proto'; -import { OTLPTraceExporter as OTLPHttpTraceExporter } from '@opentelemetry/exporter-trace-otlp-http'; -import { OTLPTraceExporter as OTLPGrpcTraceExporter } from '@opentelemetry/exporter-trace-otlp-grpc'; -import { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-grpc'; -import { PrometheusExporter } from '@opentelemetry/exporter-prometheus'; -import { PeriodicExportingMetricReader } from '@opentelemetry/sdk-metrics'; -import { diag, DiagConsoleLogger } from '@opentelemetry/api'; - -import { NodeSDK, core } from '@opentelemetry/sdk-node'; - -diag.setLogger( - new DiagConsoleLogger(), - core.getEnv().OTEL_LOG_LEVEL -); - - -function getTraceExporter() { - let protocol = process.env.OTEL_EXPORTER_OTLP_PROTOCOL; - switch (protocol) { - case undefined: - case '': - case 'grpc': - return new OTLPGrpcTraceExporter(); - case 'http/json': - return new OTLPHttpTraceExporter(); - case 'http/protobuf': - return new OTLPProtoTraceExporter(); - default: - throw Error(`Creating traces exporter based on "${protocol}" protocol (configured via environment variable OTEL_EXPORTER_OTLP_PROTOCOL) is not implemented!`); - } -} - -function getMetricReader() { - switch (process.env.OTEL_METRICS_EXPORTER) { - case undefined: - case '': - case 'otlp': - diag.info('using otel metrics exporter'); - return new PeriodicExportingMetricReader({ - exporter: new OTLPMetricExporter(), - }); - case 'prometheus': - diag.info('using prometheus metrics exporter'); - return new PrometheusExporter({}); - case 'none': - diag.info('disabling metrics reader'); - return undefined; - default: - throw Error(`no valid option for OTEL_METRICS_EXPORTER: ${process.env.OTEL_METRICS_EXPORTER}`) - } -} - -const sdk = new NodeSDK({ - autoDetectResources: true, - instrumentations: getNodeAutoInstrumentations(), - traceExporter: getTraceExporter(), - metricReader: getMetricReader(), - resourceDetectors: getResourceDetectors() -}); - -try { - sdk.start(); - diag.info('OpenTelemetry automatic instrumentation started successfully'); -} catch (error) { - diag.error( - 'Error initializing OpenTelemetry SDK. Your application is not instrumented and will not produce telemetry', - error - ); -} - -async function shutdown(): Promise { - try { - await sdk.shutdown(); - diag.debug('OpenTelemetry SDK terminated'); - } catch (error) { - diag.error('Error terminating OpenTelemetry SDK', error); - } -} - -// Gracefully shutdown SDK if a SIGTERM is received -process.on('SIGTERM', shutdown); -// Gracefully shutdown SDK if Node.js is exiting normally -process.once('beforeExit', shutdown); diff --git a/pkg/instrumentation/nodejs.go b/pkg/instrumentation/nodejs.go index b1ca51c75c..da5f433a2c 100644 --- a/pkg/instrumentation/nodejs.go +++ b/pkg/instrumentation/nodejs.go @@ -11,7 +11,7 @@ import ( const ( envNodeOptions = "NODE_OPTIONS" - nodeRequireArgument = " --require /otel-auto-instrumentation-nodejs/autoinstrumentation.js" + nodeRequireArgument = " --require /otel-auto-instrumentation-nodejs/node_modules/@opentelemetry/auto-instrumentations-node/build/src/register.js" nodejsInitContainerName = initContainerName + "-nodejs" nodejsVolumeName = volumeName + "-nodejs" nodejsInstrMountPath = "/otel-auto-instrumentation-nodejs" diff --git a/pkg/instrumentation/nodejs_test.go b/pkg/instrumentation/nodejs_test.go index 0efe8b55f2..34888a5aa0 100644 --- a/pkg/instrumentation/nodejs_test.go +++ b/pkg/instrumentation/nodejs_test.go @@ -65,7 +65,7 @@ func TestInjectNodeJSSDK(t *testing.T) { Env: []corev1.EnvVar{ { Name: "NODE_OPTIONS", - Value: " --require /otel-auto-instrumentation-nodejs/autoinstrumentation.js", + Value: " --require /otel-auto-instrumentation-nodejs/node_modules/@opentelemetry/auto-instrumentations-node/build/src/register.js", }, }, }, @@ -126,7 +126,7 @@ func TestInjectNodeJSSDK(t *testing.T) { Env: []corev1.EnvVar{ { Name: "NODE_OPTIONS", - Value: "-Dbaz=bar" + " --require /otel-auto-instrumentation-nodejs/autoinstrumentation.js", + Value: "-Dbaz=bar" + " --require /otel-auto-instrumentation-nodejs/node_modules/@opentelemetry/auto-instrumentations-node/build/src/register.js", }, }, }, diff --git a/tests/e2e-instrumentation/instrumentation-nodejs-multicontainer/01-assert.yaml b/tests/e2e-instrumentation/instrumentation-nodejs-multicontainer/01-assert.yaml index 7da5c15637..d268417e1e 100644 --- a/tests/e2e-instrumentation/instrumentation-nodejs-multicontainer/01-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-nodejs-multicontainer/01-assert.yaml @@ -21,7 +21,7 @@ spec: - name: NODE_PATH value: /usr/local/lib/node_modules - name: NODE_OPTIONS - value: ' --require /otel-auto-instrumentation-nodejs/autoinstrumentation.js' + value: ' --require /otel-auto-instrumentation-nodejs/node_modules/@opentelemetry/auto-instrumentations-node/build/src/register.js' - name: OTEL_TRACES_EXPORTER value: otlp - name: OTEL_EXPORTER_OTLP_ENDPOINT @@ -65,7 +65,7 @@ spec: fieldRef: fieldPath: status.podIP - name: NODE_OPTIONS - value: ' --require /otel-auto-instrumentation-nodejs/autoinstrumentation.js' + value: ' --require /otel-auto-instrumentation-nodejs/node_modules/@opentelemetry/auto-instrumentations-node/build/src/register.js' - name: OTEL_TRACES_EXPORTER value: otlp - name: OTEL_EXPORTER_OTLP_ENDPOINT diff --git a/tests/e2e-instrumentation/instrumentation-nodejs-multicontainer/02-assert.yaml b/tests/e2e-instrumentation/instrumentation-nodejs-multicontainer/02-assert.yaml index 0738786abd..32265deea4 100644 --- a/tests/e2e-instrumentation/instrumentation-nodejs-multicontainer/02-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-nodejs-multicontainer/02-assert.yaml @@ -32,7 +32,7 @@ spec: - name: NODE_PATH value: /usr/local/lib/node_modules - name: NODE_OPTIONS - value: ' --require /otel-auto-instrumentation-nodejs/autoinstrumentation.js' + value: ' --require /otel-auto-instrumentation-nodejs/node_modules/@opentelemetry/auto-instrumentations-node/build/src/register.js' - name: OTEL_TRACES_EXPORTER value: otlp - name: OTEL_EXPORTER_OTLP_ENDPOINT diff --git a/tests/e2e-instrumentation/instrumentation-nodejs-volume/01-assert.yaml b/tests/e2e-instrumentation/instrumentation-nodejs-volume/01-assert.yaml index 83e32efc3a..d05d36b784 100644 --- a/tests/e2e-instrumentation/instrumentation-nodejs-volume/01-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-nodejs-volume/01-assert.yaml @@ -22,7 +22,7 @@ spec: - name: OTEL_NODEJS_DEBUG value: "true" - name: NODE_OPTIONS - value: " --require /otel-auto-instrumentation-nodejs/autoinstrumentation.js" + value: " --require /otel-auto-instrumentation-nodejs/node_modules/@opentelemetry/auto-instrumentations-node/build/src/register.js" - name: OTEL_TRACES_EXPORTER value: otlp - name: OTEL_EXPORTER_OTLP_ENDPOINT diff --git a/tests/e2e-instrumentation/instrumentation-nodejs/01-assert.yaml b/tests/e2e-instrumentation/instrumentation-nodejs/01-assert.yaml index 719727ca68..b8ae547ad6 100644 --- a/tests/e2e-instrumentation/instrumentation-nodejs/01-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-nodejs/01-assert.yaml @@ -22,7 +22,7 @@ spec: - name: OTEL_NODEJS_DEBUG value: "true" - name: NODE_OPTIONS - value: ' --require /otel-auto-instrumentation-nodejs/autoinstrumentation.js' + value: ' --require /otel-auto-instrumentation-nodejs/node_modules/@opentelemetry/auto-instrumentations-node/build/src/register.js' - name: OTEL_TRACES_EXPORTER value: otlp - name: OTEL_EXPORTER_OTLP_ENDPOINT diff --git a/tests/e2e-multi-instrumentation/instrumentation-multi-multicontainer/01-assert.yaml b/tests/e2e-multi-instrumentation/instrumentation-multi-multicontainer/01-assert.yaml index 3ba921ada1..41e950418b 100644 --- a/tests/e2e-multi-instrumentation/instrumentation-multi-multicontainer/01-assert.yaml +++ b/tests/e2e-multi-instrumentation/instrumentation-multi-multicontainer/01-assert.yaml @@ -131,7 +131,7 @@ spec: - name: OTEL_SERVICE_NAME value: nodejsapp - name: NODE_OPTIONS - value: ' --require /otel-auto-instrumentation-nodejs/autoinstrumentation.js' + value: ' --require /otel-auto-instrumentation-nodejs/node_modules/@opentelemetry/auto-instrumentations-node/build/src/register.js' - name: OTEL_TRACES_SAMPLER value: parentbased_traceidratio - name: OTEL_TRACES_SAMPLER_ARG diff --git a/tests/e2e-multi-instrumentation/instrumentation-single-instr-first-container/01-assert.yaml b/tests/e2e-multi-instrumentation/instrumentation-single-instr-first-container/01-assert.yaml index 704e8b12a7..7edd414732 100644 --- a/tests/e2e-multi-instrumentation/instrumentation-single-instr-first-container/01-assert.yaml +++ b/tests/e2e-multi-instrumentation/instrumentation-single-instr-first-container/01-assert.yaml @@ -22,7 +22,7 @@ spec: - name: OTEL_SERVICE_NAME value: nodejsapp - name: NODE_OPTIONS - value: ' --require /otel-auto-instrumentation-nodejs/autoinstrumentation.js' + value: ' --require /otel-auto-instrumentation-nodejs/node_modules/@opentelemetry/auto-instrumentations-node/build/src/register.js' - name: OTEL_TRACES_SAMPLER value: parentbased_traceidratio - name: OTEL_TRACES_SAMPLER_ARG diff --git a/tests/e2e-openshift/must-gather/assert-install-app.yaml b/tests/e2e-openshift/must-gather/assert-install-app.yaml index 719727ca68..b8ae547ad6 100644 --- a/tests/e2e-openshift/must-gather/assert-install-app.yaml +++ b/tests/e2e-openshift/must-gather/assert-install-app.yaml @@ -22,7 +22,7 @@ spec: - name: OTEL_NODEJS_DEBUG value: "true" - name: NODE_OPTIONS - value: ' --require /otel-auto-instrumentation-nodejs/autoinstrumentation.js' + value: ' --require /otel-auto-instrumentation-nodejs/node_modules/@opentelemetry/auto-instrumentations-node/build/src/register.js' - name: OTEL_TRACES_EXPORTER value: otlp - name: OTEL_EXPORTER_OTLP_ENDPOINT From 73e6692bdccb59781069f62ed10f7849a6c85cc8 Mon Sep 17 00:00:00 2001 From: "matteo.gazzetta" Date: Wed, 15 Jan 2025 15:05:20 +0100 Subject: [PATCH 4/6] fix dockerbuild Signed-off-by: matteo.gazzetta --- autoinstrumentation/nodejs/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoinstrumentation/nodejs/package.json b/autoinstrumentation/nodejs/package.json index 22b8e0dabb..d544f8637c 100644 --- a/autoinstrumentation/nodejs/package.json +++ b/autoinstrumentation/nodejs/package.json @@ -4,7 +4,7 @@ "private": true, "scripts": { "clean": "rimraf build/*", - "postcompile": "copyfiles -f 'build/src/**' build/workspace/ && copyfiles 'node_modules/**' package.json build/workspace/ && npm -C build/workspace prune --omit=dev --no-package-lock" + "postinstall": "copyfiles -f 'build/src/**' build/workspace/ && copyfiles 'node_modules/**' package.json build/workspace/ && npm -C build/workspace prune --omit=dev --no-package-lock" }, "devDependencies": { "copyfiles": "^2.4.1", From 4b9aef7616383223ce5b0c17702c89a0fa490269 Mon Sep 17 00:00:00 2001 From: "matteo.gazzetta" Date: Fri, 14 Feb 2025 09:04:37 +0100 Subject: [PATCH 5/6] add backward compatibility with old operator --- autoinstrumentation/nodejs/Dockerfile | 4 ++++ autoinstrumentation/nodejs/package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/autoinstrumentation/nodejs/Dockerfile b/autoinstrumentation/nodejs/Dockerfile index 48f1f9ae75..c37549e40c 100644 --- a/autoinstrumentation/nodejs/Dockerfile +++ b/autoinstrumentation/nodejs/Dockerfile @@ -21,3 +21,7 @@ FROM busybox COPY --from=build /operator-build/build/workspace /autoinstrumentation RUN chmod -R go+r /autoinstrumentation + +# Backward compatibility with old operator version +RUN cp -r /autoinstrumentation/node_modules/@opentelemetry/auto-instrumentations-node/build/src/. /autoinstrumentation +RUN ln /autoinstrumentation/register.js /autoinstrumentation/autoinstrumentation.js diff --git a/autoinstrumentation/nodejs/package.json b/autoinstrumentation/nodejs/package.json index d544f8637c..14734573d8 100644 --- a/autoinstrumentation/nodejs/package.json +++ b/autoinstrumentation/nodejs/package.json @@ -13,6 +13,6 @@ }, "dependencies": { "@opentelemetry/api": "1.9.0", - "@opentelemetry/auto-instrumentations-node": "0.55.2" + "@opentelemetry/auto-instrumentations-node": "0.56.0" } } From c9a1d336dfaef1079cfce80015d19afe37f2f8bb Mon Sep 17 00:00:00 2001 From: "matteo.gazzetta" Date: Mon, 17 Feb 2025 12:35:37 +0100 Subject: [PATCH 6/6] revert path nodejs instrumentation --- pkg/instrumentation/nodejs.go | 2 +- pkg/instrumentation/nodejs_test.go | 4 ++-- .../instrumentation-nodejs-multicontainer/01-assert.yaml | 4 ++-- .../instrumentation-nodejs-multicontainer/02-assert.yaml | 2 +- .../instrumentation-nodejs-volume/01-assert.yaml | 2 +- .../e2e-instrumentation/instrumentation-nodejs/01-assert.yaml | 2 +- .../instrumentation-multi-multicontainer/01-assert.yaml | 2 +- .../01-assert.yaml | 2 +- tests/e2e-openshift/must-gather/assert-install-app.yaml | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pkg/instrumentation/nodejs.go b/pkg/instrumentation/nodejs.go index da5f433a2c..b1ca51c75c 100644 --- a/pkg/instrumentation/nodejs.go +++ b/pkg/instrumentation/nodejs.go @@ -11,7 +11,7 @@ import ( const ( envNodeOptions = "NODE_OPTIONS" - nodeRequireArgument = " --require /otel-auto-instrumentation-nodejs/node_modules/@opentelemetry/auto-instrumentations-node/build/src/register.js" + nodeRequireArgument = " --require /otel-auto-instrumentation-nodejs/autoinstrumentation.js" nodejsInitContainerName = initContainerName + "-nodejs" nodejsVolumeName = volumeName + "-nodejs" nodejsInstrMountPath = "/otel-auto-instrumentation-nodejs" diff --git a/pkg/instrumentation/nodejs_test.go b/pkg/instrumentation/nodejs_test.go index 34888a5aa0..0efe8b55f2 100644 --- a/pkg/instrumentation/nodejs_test.go +++ b/pkg/instrumentation/nodejs_test.go @@ -65,7 +65,7 @@ func TestInjectNodeJSSDK(t *testing.T) { Env: []corev1.EnvVar{ { Name: "NODE_OPTIONS", - Value: " --require /otel-auto-instrumentation-nodejs/node_modules/@opentelemetry/auto-instrumentations-node/build/src/register.js", + Value: " --require /otel-auto-instrumentation-nodejs/autoinstrumentation.js", }, }, }, @@ -126,7 +126,7 @@ func TestInjectNodeJSSDK(t *testing.T) { Env: []corev1.EnvVar{ { Name: "NODE_OPTIONS", - Value: "-Dbaz=bar" + " --require /otel-auto-instrumentation-nodejs/node_modules/@opentelemetry/auto-instrumentations-node/build/src/register.js", + Value: "-Dbaz=bar" + " --require /otel-auto-instrumentation-nodejs/autoinstrumentation.js", }, }, }, diff --git a/tests/e2e-instrumentation/instrumentation-nodejs-multicontainer/01-assert.yaml b/tests/e2e-instrumentation/instrumentation-nodejs-multicontainer/01-assert.yaml index d268417e1e..7da5c15637 100644 --- a/tests/e2e-instrumentation/instrumentation-nodejs-multicontainer/01-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-nodejs-multicontainer/01-assert.yaml @@ -21,7 +21,7 @@ spec: - name: NODE_PATH value: /usr/local/lib/node_modules - name: NODE_OPTIONS - value: ' --require /otel-auto-instrumentation-nodejs/node_modules/@opentelemetry/auto-instrumentations-node/build/src/register.js' + value: ' --require /otel-auto-instrumentation-nodejs/autoinstrumentation.js' - name: OTEL_TRACES_EXPORTER value: otlp - name: OTEL_EXPORTER_OTLP_ENDPOINT @@ -65,7 +65,7 @@ spec: fieldRef: fieldPath: status.podIP - name: NODE_OPTIONS - value: ' --require /otel-auto-instrumentation-nodejs/node_modules/@opentelemetry/auto-instrumentations-node/build/src/register.js' + value: ' --require /otel-auto-instrumentation-nodejs/autoinstrumentation.js' - name: OTEL_TRACES_EXPORTER value: otlp - name: OTEL_EXPORTER_OTLP_ENDPOINT diff --git a/tests/e2e-instrumentation/instrumentation-nodejs-multicontainer/02-assert.yaml b/tests/e2e-instrumentation/instrumentation-nodejs-multicontainer/02-assert.yaml index 32265deea4..0738786abd 100644 --- a/tests/e2e-instrumentation/instrumentation-nodejs-multicontainer/02-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-nodejs-multicontainer/02-assert.yaml @@ -32,7 +32,7 @@ spec: - name: NODE_PATH value: /usr/local/lib/node_modules - name: NODE_OPTIONS - value: ' --require /otel-auto-instrumentation-nodejs/node_modules/@opentelemetry/auto-instrumentations-node/build/src/register.js' + value: ' --require /otel-auto-instrumentation-nodejs/autoinstrumentation.js' - name: OTEL_TRACES_EXPORTER value: otlp - name: OTEL_EXPORTER_OTLP_ENDPOINT diff --git a/tests/e2e-instrumentation/instrumentation-nodejs-volume/01-assert.yaml b/tests/e2e-instrumentation/instrumentation-nodejs-volume/01-assert.yaml index d05d36b784..83e32efc3a 100644 --- a/tests/e2e-instrumentation/instrumentation-nodejs-volume/01-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-nodejs-volume/01-assert.yaml @@ -22,7 +22,7 @@ spec: - name: OTEL_NODEJS_DEBUG value: "true" - name: NODE_OPTIONS - value: " --require /otel-auto-instrumentation-nodejs/node_modules/@opentelemetry/auto-instrumentations-node/build/src/register.js" + value: " --require /otel-auto-instrumentation-nodejs/autoinstrumentation.js" - name: OTEL_TRACES_EXPORTER value: otlp - name: OTEL_EXPORTER_OTLP_ENDPOINT diff --git a/tests/e2e-instrumentation/instrumentation-nodejs/01-assert.yaml b/tests/e2e-instrumentation/instrumentation-nodejs/01-assert.yaml index b8ae547ad6..719727ca68 100644 --- a/tests/e2e-instrumentation/instrumentation-nodejs/01-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-nodejs/01-assert.yaml @@ -22,7 +22,7 @@ spec: - name: OTEL_NODEJS_DEBUG value: "true" - name: NODE_OPTIONS - value: ' --require /otel-auto-instrumentation-nodejs/node_modules/@opentelemetry/auto-instrumentations-node/build/src/register.js' + value: ' --require /otel-auto-instrumentation-nodejs/autoinstrumentation.js' - name: OTEL_TRACES_EXPORTER value: otlp - name: OTEL_EXPORTER_OTLP_ENDPOINT diff --git a/tests/e2e-multi-instrumentation/instrumentation-multi-multicontainer/01-assert.yaml b/tests/e2e-multi-instrumentation/instrumentation-multi-multicontainer/01-assert.yaml index 41e950418b..3ba921ada1 100644 --- a/tests/e2e-multi-instrumentation/instrumentation-multi-multicontainer/01-assert.yaml +++ b/tests/e2e-multi-instrumentation/instrumentation-multi-multicontainer/01-assert.yaml @@ -131,7 +131,7 @@ spec: - name: OTEL_SERVICE_NAME value: nodejsapp - name: NODE_OPTIONS - value: ' --require /otel-auto-instrumentation-nodejs/node_modules/@opentelemetry/auto-instrumentations-node/build/src/register.js' + value: ' --require /otel-auto-instrumentation-nodejs/autoinstrumentation.js' - name: OTEL_TRACES_SAMPLER value: parentbased_traceidratio - name: OTEL_TRACES_SAMPLER_ARG diff --git a/tests/e2e-multi-instrumentation/instrumentation-single-instr-first-container/01-assert.yaml b/tests/e2e-multi-instrumentation/instrumentation-single-instr-first-container/01-assert.yaml index 7edd414732..704e8b12a7 100644 --- a/tests/e2e-multi-instrumentation/instrumentation-single-instr-first-container/01-assert.yaml +++ b/tests/e2e-multi-instrumentation/instrumentation-single-instr-first-container/01-assert.yaml @@ -22,7 +22,7 @@ spec: - name: OTEL_SERVICE_NAME value: nodejsapp - name: NODE_OPTIONS - value: ' --require /otel-auto-instrumentation-nodejs/node_modules/@opentelemetry/auto-instrumentations-node/build/src/register.js' + value: ' --require /otel-auto-instrumentation-nodejs/autoinstrumentation.js' - name: OTEL_TRACES_SAMPLER value: parentbased_traceidratio - name: OTEL_TRACES_SAMPLER_ARG diff --git a/tests/e2e-openshift/must-gather/assert-install-app.yaml b/tests/e2e-openshift/must-gather/assert-install-app.yaml index b8ae547ad6..719727ca68 100644 --- a/tests/e2e-openshift/must-gather/assert-install-app.yaml +++ b/tests/e2e-openshift/must-gather/assert-install-app.yaml @@ -22,7 +22,7 @@ spec: - name: OTEL_NODEJS_DEBUG value: "true" - name: NODE_OPTIONS - value: ' --require /otel-auto-instrumentation-nodejs/node_modules/@opentelemetry/auto-instrumentations-node/build/src/register.js' + value: ' --require /otel-auto-instrumentation-nodejs/autoinstrumentation.js' - name: OTEL_TRACES_EXPORTER value: otlp - name: OTEL_EXPORTER_OTLP_ENDPOINT