From 4ee53271836503f27331652cb010d7c19397f5cf Mon Sep 17 00:00:00 2001 From: liyanwei93 Date: Tue, 26 Nov 2024 10:35:41 -0800 Subject: [PATCH 1/2] add nodejs auto-intrumentation in paymentservice --- src/paymentservice/opentelemetry.js | 4 ++ src/paymentservice/package-lock.json | 62 ++++++++++++++++++++++++++-- src/paymentservice/package.json | 1 + 3 files changed, 64 insertions(+), 3 deletions(-) diff --git a/src/paymentservice/opentelemetry.js b/src/paymentservice/opentelemetry.js index 0ba569cd30..856910c416 100644 --- a/src/paymentservice/opentelemetry.js +++ b/src/paymentservice/opentelemetry.js @@ -11,6 +11,7 @@ const {awsEc2Detector, awsEksDetector} = require('@opentelemetry/resource-detect const {containerDetector} = require('@opentelemetry/resource-detector-container') const {gcpDetector} = require('@opentelemetry/resource-detector-gcp') const {envDetector, hostDetector, osDetector, processDetector} = require('@opentelemetry/resources') +const {RuntimeNodeInstrumentation} = require('@opentelemetry/instrumentation-runtime-node') const sdk = new opentelemetry.NodeSDK({ traceExporter: new OTLPTraceExporter(), @@ -20,6 +21,9 @@ const sdk = new opentelemetry.NodeSDK({ '@opentelemetry/instrumentation-fs': { requireParentSpan: true, }, + }), + new RuntimeNodeInstrumentation({ + monitoringPrecision: 5000, }) ], metricReader: new PeriodicExportingMetricReader({ diff --git a/src/paymentservice/package-lock.json b/src/paymentservice/package-lock.json index d2719f2bb3..fad9651dbb 100644 --- a/src/paymentservice/package-lock.json +++ b/src/paymentservice/package-lock.json @@ -18,6 +18,7 @@ "@opentelemetry/core": "1.24.1", "@opentelemetry/exporter-metrics-otlp-grpc": "0.51.1", "@opentelemetry/exporter-trace-otlp-grpc": "0.51.1", + "@opentelemetry/instrumentation-runtime-node": "^0.10.0", "@opentelemetry/resource-detector-alibaba-cloud": "0.28.9", "@opentelemetry/resource-detector-aws": "1.5.0", "@opentelemetry/resource-detector-container": "0.3.9", @@ -909,6 +910,61 @@ "@opentelemetry/api": "^1.3.0" } }, + "node_modules/@opentelemetry/instrumentation-runtime-node": { + "version": "0.10.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-runtime-node/-/instrumentation-runtime-node-0.10.0.tgz", + "integrity": "sha512-hvwbi9iSqiclqSkRNFLW/3/v5drUPfD8V9zAmXZWZA68X0yygb2nPQlGce9Aba7p3l+Z4wGL8WcPtHDN2XzpoQ==", + "dependencies": { + "@opentelemetry/instrumentation": "^0.55.0" + }, + "engines": { + "node": ">=17.4.0" + }, + "peerDependencies": { + "@opentelemetry/api": "^1.3.0" + } + }, + "node_modules/@opentelemetry/instrumentation-runtime-node/node_modules/@opentelemetry/api-logs": { + "version": "0.55.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/api-logs/-/api-logs-0.55.0.tgz", + "integrity": "sha512-3cpa+qI45VHYcA5c0bHM6VHo9gicv3p5mlLHNG3rLyjQU8b7e0st1rWtrUn3JbZ3DwwCfhKop4eQ9UuYlC6Pkg==", + "dependencies": { + "@opentelemetry/api": "^1.3.0" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/@opentelemetry/instrumentation-runtime-node/node_modules/@opentelemetry/instrumentation": { + "version": "0.55.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation/-/instrumentation-0.55.0.tgz", + "integrity": "sha512-YDCMlaQRZkziLL3t6TONRgmmGxDx6MyQDXRD0dknkkgUZtOK5+8MWft1OXzmNu6XfBOdT12MKN5rz+jHUkafKQ==", + "dependencies": { + "@opentelemetry/api-logs": "0.55.0", + "@types/shimmer": "^1.2.0", + "import-in-the-middle": "^1.8.1", + "require-in-the-middle": "^7.1.1", + "semver": "^7.5.2", + "shimmer": "^1.2.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": "^1.3.0" + } + }, + "node_modules/@opentelemetry/instrumentation-runtime-node/node_modules/import-in-the-middle": { + "version": "1.11.2", + "resolved": "https://registry.npmjs.org/import-in-the-middle/-/import-in-the-middle-1.11.2.tgz", + "integrity": "sha512-gK6Rr6EykBcc6cVWRSBR5TWf8nn6hZMYSRYqCcHa0l0d1fPK7JSYo6+Mlmck76jIX9aL/IZ71c06U2VpFwl1zA==", + "dependencies": { + "acorn": "^8.8.2", + "acorn-import-attributes": "^1.9.5", + "cjs-module-lexer": "^1.2.2", + "module-details-from-path": "^1.0.3" + } + }, "node_modules/@opentelemetry/instrumentation-socket.io": { "version": "0.39.0", "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-socket.io/-/instrumentation-socket.io-0.39.0.tgz", @@ -1571,9 +1627,9 @@ } }, "node_modules/@types/shimmer": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/@types/shimmer/-/shimmer-1.0.5.tgz", - "integrity": "sha512-9Hp0ObzwwO57DpLFF0InUjUm/II8GmKAvzbefxQTihCb7KI6yc9yzf0nLc4mVdby5N4DRCgQM2wCup9KTieeww==" + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@types/shimmer/-/shimmer-1.2.0.tgz", + "integrity": "sha512-UE7oxhQLLd9gub6JKIAhDq06T0F6FnztwMNRvYgjeQSBeMc1ZG/tA47EwfduvkuQS8apbkM/lpLpWsaCeYsXVg==" }, "node_modules/@types/tedious": { "version": "4.0.14", diff --git a/src/paymentservice/package.json b/src/paymentservice/package.json index f51782201d..4071520ea9 100644 --- a/src/paymentservice/package.json +++ b/src/paymentservice/package.json @@ -24,6 +24,7 @@ "@opentelemetry/exporter-trace-otlp-grpc": "0.51.1", "@opentelemetry/exporter-metrics-otlp-grpc": "0.51.1", "@opentelemetry/sdk-node": "0.51.1", + "@opentelemetry/instrumentation-runtime-node": "^0.10.0", "@opentelemetry/resource-detector-alibaba-cloud": "0.28.9", "@opentelemetry/resource-detector-aws": "1.5.0", "@opentelemetry/resource-detector-container": "0.3.9", From 104b3e62bc9826fd38877e85f0a78af83fb254a8 Mon Sep 17 00:00:00 2001 From: liyanwei93 Date: Tue, 26 Nov 2024 16:04:10 -0800 Subject: [PATCH 2/2] update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f40fed854b..30912e482f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,8 @@ the release. ([#1786](https://github.com/open-telemetry/opentelemetry-demo/pull/1786)) * [chore] Add multi-platform build support ([#1785](https://github.com/open-telemetry/opentelemetry-demo/pull/1785)) +* [paymentservice] Add nodejs auto-instrumentation for runtime metrics + ([#1797](https://github.com/open-telemetry/opentelemetry-demo/pull/1797)) ## 1.12.0