From c2fa8be658ffffd8010716355c7dfbf3996a5033 Mon Sep 17 00:00:00 2001 From: Daniel Li Date: Mon, 15 Jan 2024 23:38:34 +0000 Subject: [PATCH 01/14] feat(perf_hooks): add node instrumentation perf_hooks --- .github/component_owners.yml | 4 +- package-lock.json | 653 ++++++++++++++++++ .../.eslintignore | 1 + .../.eslintrc.js | 7 + .../LICENSE | 201 ++++++ .../README.md | 80 +++ .../package.json | 52 ++ .../src/index.ts | 17 + .../src/instrumentation.ts | 88 +++ .../src/types.ts | 26 + .../test/event_loop_utilization.test.ts | 89 +++ .../tsconfig.json | 11 + 12 files changed, 1228 insertions(+), 1 deletion(-) create mode 100644 plugins/node/opentelemetry-instrumentation-perf-hooks/.eslintignore create mode 100644 plugins/node/opentelemetry-instrumentation-perf-hooks/.eslintrc.js create mode 100644 plugins/node/opentelemetry-instrumentation-perf-hooks/LICENSE create mode 100644 plugins/node/opentelemetry-instrumentation-perf-hooks/README.md create mode 100644 plugins/node/opentelemetry-instrumentation-perf-hooks/package.json create mode 100644 plugins/node/opentelemetry-instrumentation-perf-hooks/src/index.ts create mode 100644 plugins/node/opentelemetry-instrumentation-perf-hooks/src/instrumentation.ts create mode 100644 plugins/node/opentelemetry-instrumentation-perf-hooks/src/types.ts create mode 100644 plugins/node/opentelemetry-instrumentation-perf-hooks/test/event_loop_utilization.test.ts create mode 100644 plugins/node/opentelemetry-instrumentation-perf-hooks/tsconfig.json diff --git a/.github/component_owners.yml b/.github/component_owners.yml index a9da78fd32..c7a8eddfc7 100644 --- a/.github/component_owners.yml +++ b/.github/component_owners.yml @@ -99,6 +99,8 @@ components: - rauno56 plugins/node/opentelemetry-instrumentation-net: - seemk + plugins/node/opentelemetry-instrumentation-perf-hooks: + - d4nyll plugins/node/opentelemetry-instrumentation-pg: - rauno56 plugins/node/opentelemetry-instrumentation-pino: @@ -115,7 +117,7 @@ components: - seemk plugins/web/opentelemetry-instrumentation-document-load: - pkanal - - martinkuba + - martinkuba plugins/web/opentelemetry-instrumentation-long-task: - mhennoch - t2t2 diff --git a/package-lock.json b/package-lock.json index 9606105e64..8955cc07e0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8119,6 +8119,10 @@ "resolved": "plugins/node/opentelemetry-instrumentation-net", "link": true }, + "node_modules/@opentelemetry/instrumentation-perf-hooks": { + "resolved": "plugins/node/opentelemetry-instrumentation-perf-hooks", + "link": true + }, "node_modules/@opentelemetry/instrumentation-pg": { "resolved": "plugins/node/opentelemetry-instrumentation-pg", "link": true @@ -23239,6 +23243,18 @@ "integrity": "sha512-W7tfG7vMOGtD30sHoZSSc/JVYiyDPEyQVso/Zz+/uQd0B0L46gtC+pHha5FFMRpil6fm/AoEcRWyOVi4+E/f8w==", "devOptional": true }, + "node_modules/nanoid": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.3.tgz", + "integrity": "sha512-p1sjXuopFs0xg+fPASzQ28agW1oHD7xDsd9Xkf3T15H3c/cifrFHVwrh74PdoklAPi+i7MdRsE47vm2r6JoB+w==", + "dev": true, + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, "node_modules/nanomatch": { "version": "1.2.13", "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz", @@ -32777,6 +32793,12 @@ "errno": "~0.1.7" } }, + "node_modules/workerpool": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.2.1.tgz", + "integrity": "sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw==", + "dev": true + }, "node_modules/wrap-ansi": { "version": "6.2.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", @@ -36152,6 +36174,365 @@ "@opentelemetry/api": "^1.3.0" } }, + "plugins/node/opentelemetry-instrumentation-perf-hooks": { + "version": "0.1.0", + "license": "Apache-2.0", + "devDependencies": { + "@opentelemetry/sdk-metrics": "^1.20.0", + "@types/mocha": "^10.0.6", + "@types/node": "^20.11.2", + "mocha": "^10.2.0", + "nyc": "^15.1.0", + "ts-mocha": "^10.0.0" + }, + "engines": { + "node": ">=14.10.0" + }, + "peerDependencies": { + "@opentelemetry/api": "^1.0.0" + } + }, + "plugins/node/opentelemetry-instrumentation-perf-hooks/node_modules/@opentelemetry/core": { + "version": "1.20.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/core/-/core-1.20.0.tgz", + "integrity": "sha512-lSRvk5AIdD6CtgYJcJXh0wGibQ3S/8bC2qbqKs9wK8e0K1tsWV6YkGFOqVc+jIRlCbZoIBeZzDe5UI+vb94uvg==", + "dev": true, + "dependencies": { + "@opentelemetry/semantic-conventions": "1.20.0" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.8.0" + } + }, + "plugins/node/opentelemetry-instrumentation-perf-hooks/node_modules/@opentelemetry/resources": { + "version": "1.20.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/resources/-/resources-1.20.0.tgz", + "integrity": "sha512-nOpV0vGegSq+9ze2cEDvO3BMA5pGBhmhKZiAlj+xQZjiEjPmJtdHIuBLRvptu2ahcbFJw85gIB9BYHZOvZK1JQ==", + "dev": true, + "dependencies": { + "@opentelemetry/core": "1.20.0", + "@opentelemetry/semantic-conventions": "1.20.0" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.8.0" + } + }, + "plugins/node/opentelemetry-instrumentation-perf-hooks/node_modules/@opentelemetry/sdk-metrics": { + "version": "1.20.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-metrics/-/sdk-metrics-1.20.0.tgz", + "integrity": "sha512-07bFOQUrpN/Q5biJ/cuBePztKwkc1VGkFblZxAcVkuvCLDAPJfsyr0NNWegWeYe0bpGt1jmXScpUWnVD+t8Q0w==", + "dev": true, + "dependencies": { + "@opentelemetry/core": "1.20.0", + "@opentelemetry/resources": "1.20.0", + "lodash.merge": "^4.6.2" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.3.0 <1.8.0" + } + }, + "plugins/node/opentelemetry-instrumentation-perf-hooks/node_modules/@opentelemetry/semantic-conventions": { + "version": "1.20.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/semantic-conventions/-/semantic-conventions-1.20.0.tgz", + "integrity": "sha512-3zLJJCgTKYpbqFX8drl8hOCHtdchELC+kGqlVcV4mHW1DiElTtv1Nt9EKBptTd1IfL56QkuYnWJ3DeHd2Gtu/A==", + "dev": true, + "engines": { + "node": ">=14" + } + }, + "plugins/node/opentelemetry-instrumentation-perf-hooks/node_modules/@types/mocha": { + "version": "10.0.6", + "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-10.0.6.tgz", + "integrity": "sha512-dJvrYWxP/UcXm36Qn36fxhUKu8A/xMRXVT2cliFF1Z7UA9liG5Psj3ezNSZw+5puH2czDXRLcXQxf8JbJt0ejg==", + "dev": true + }, + "plugins/node/opentelemetry-instrumentation-perf-hooks/node_modules/@types/node": { + "version": "20.11.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.3.tgz", + "integrity": "sha512-nrlmbvGPNGaj84IJZXMPhQuCMEVTT/hXZMJJG/aIqVL9fKxqk814sGGtJA4GI6hpJSLQjpi6cn0Qx9eOf9SDVg==", + "dev": true, + "dependencies": { + "undici-types": "~5.26.4" + } + }, + "plugins/node/opentelemetry-instrumentation-perf-hooks/node_modules/ansi-colors": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", + "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "plugins/node/opentelemetry-instrumentation-perf-hooks/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "plugins/node/opentelemetry-instrumentation-perf-hooks/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "plugins/node/opentelemetry-instrumentation-perf-hooks/node_modules/camelcase": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", + "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "plugins/node/opentelemetry-instrumentation-perf-hooks/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "plugins/node/opentelemetry-instrumentation-perf-hooks/node_modules/chalk/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "plugins/node/opentelemetry-instrumentation-perf-hooks/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "plugins/node/opentelemetry-instrumentation-perf-hooks/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "plugins/node/opentelemetry-instrumentation-perf-hooks/node_modules/decamelize": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz", + "integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "plugins/node/opentelemetry-instrumentation-perf-hooks/node_modules/diff": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", + "integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==", + "dev": true, + "engines": { + "node": ">=0.3.1" + } + }, + "plugins/node/opentelemetry-instrumentation-perf-hooks/node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "plugins/node/opentelemetry-instrumentation-perf-hooks/node_modules/glob": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", + "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "plugins/node/opentelemetry-instrumentation-perf-hooks/node_modules/is-plain-obj": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", + "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "plugins/node/opentelemetry-instrumentation-perf-hooks/node_modules/log-symbols": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", + "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", + "dev": true, + "dependencies": { + "chalk": "^4.1.0", + "is-unicode-supported": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "plugins/node/opentelemetry-instrumentation-perf-hooks/node_modules/mocha": { + "version": "10.2.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.2.0.tgz", + "integrity": "sha512-IDY7fl/BecMwFHzoqF2sg/SHHANeBoMMXFlS9r0OXKDssYE1M5O43wUY/9BVPeIvfH2zmEbBfseqN9gBQZzXkg==", + "dev": true, + "dependencies": { + "ansi-colors": "4.1.1", + "browser-stdout": "1.3.1", + "chokidar": "3.5.3", + "debug": "4.3.4", + "diff": "5.0.0", + "escape-string-regexp": "4.0.0", + "find-up": "5.0.0", + "glob": "7.2.0", + "he": "1.2.0", + "js-yaml": "4.1.0", + "log-symbols": "4.1.0", + "minimatch": "5.0.1", + "ms": "2.1.3", + "nanoid": "3.3.3", + "serialize-javascript": "6.0.0", + "strip-json-comments": "3.1.1", + "supports-color": "8.1.1", + "workerpool": "6.2.1", + "yargs": "16.2.0", + "yargs-parser": "20.2.4", + "yargs-unparser": "2.0.0" + }, + "bin": { + "_mocha": "bin/_mocha", + "mocha": "bin/mocha.js" + }, + "engines": { + "node": ">= 14.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/mochajs" + } + }, + "plugins/node/opentelemetry-instrumentation-perf-hooks/node_modules/mocha/node_modules/minimatch": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", + "integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=10" + } + }, + "plugins/node/opentelemetry-instrumentation-perf-hooks/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true + }, + "plugins/node/opentelemetry-instrumentation-perf-hooks/node_modules/serialize-javascript": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz", + "integrity": "sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==", + "dev": true, + "dependencies": { + "randombytes": "^2.1.0" + } + }, + "plugins/node/opentelemetry-instrumentation-perf-hooks/node_modules/yargs": { + "version": "16.2.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", + "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", + "dev": true, + "dependencies": { + "cliui": "^7.0.2", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.0", + "y18n": "^5.0.5", + "yargs-parser": "^20.2.2" + }, + "engines": { + "node": ">=10" + } + }, + "plugins/node/opentelemetry-instrumentation-perf-hooks/node_modules/yargs-unparser": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-2.0.0.tgz", + "integrity": "sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==", + "dev": true, + "dependencies": { + "camelcase": "^6.0.0", + "decamelize": "^4.0.0", + "flat": "^5.0.2", + "is-plain-obj": "^2.1.0" + }, + "engines": { + "node": ">=10" + } + }, "plugins/node/opentelemetry-instrumentation-pg": { "name": "@opentelemetry/instrumentation-pg", "version": "0.37.2", @@ -44841,6 +45222,266 @@ "typescript": "4.4.4" } }, + "@opentelemetry/instrumentation-perf-hooks": { + "version": "file:plugins/node/opentelemetry-instrumentation-perf-hooks", + "requires": { + "@opentelemetry/sdk-metrics": "^1.20.0", + "@types/mocha": "^10.0.6", + "@types/node": "^20.11.2", + "mocha": "^10.2.0", + "nyc": "^15.1.0", + "ts-mocha": "^10.0.0" + }, + "dependencies": { + "@opentelemetry/core": { + "version": "1.20.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/core/-/core-1.20.0.tgz", + "integrity": "sha512-lSRvk5AIdD6CtgYJcJXh0wGibQ3S/8bC2qbqKs9wK8e0K1tsWV6YkGFOqVc+jIRlCbZoIBeZzDe5UI+vb94uvg==", + "dev": true, + "requires": { + "@opentelemetry/semantic-conventions": "1.20.0" + } + }, + "@opentelemetry/resources": { + "version": "1.20.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/resources/-/resources-1.20.0.tgz", + "integrity": "sha512-nOpV0vGegSq+9ze2cEDvO3BMA5pGBhmhKZiAlj+xQZjiEjPmJtdHIuBLRvptu2ahcbFJw85gIB9BYHZOvZK1JQ==", + "dev": true, + "requires": { + "@opentelemetry/core": "1.20.0", + "@opentelemetry/semantic-conventions": "1.20.0" + } + }, + "@opentelemetry/sdk-metrics": { + "version": "1.20.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-metrics/-/sdk-metrics-1.20.0.tgz", + "integrity": "sha512-07bFOQUrpN/Q5biJ/cuBePztKwkc1VGkFblZxAcVkuvCLDAPJfsyr0NNWegWeYe0bpGt1jmXScpUWnVD+t8Q0w==", + "dev": true, + "requires": { + "@opentelemetry/core": "1.20.0", + "@opentelemetry/resources": "1.20.0", + "lodash.merge": "^4.6.2" + } + }, + "@opentelemetry/semantic-conventions": { + "version": "1.20.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/semantic-conventions/-/semantic-conventions-1.20.0.tgz", + "integrity": "sha512-3zLJJCgTKYpbqFX8drl8hOCHtdchELC+kGqlVcV4mHW1DiElTtv1Nt9EKBptTd1IfL56QkuYnWJ3DeHd2Gtu/A==", + "dev": true + }, + "@types/mocha": { + "version": "10.0.6", + "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-10.0.6.tgz", + "integrity": "sha512-dJvrYWxP/UcXm36Qn36fxhUKu8A/xMRXVT2cliFF1Z7UA9liG5Psj3ezNSZw+5puH2czDXRLcXQxf8JbJt0ejg==", + "dev": true + }, + "@types/node": { + "version": "20.11.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.3.tgz", + "integrity": "sha512-nrlmbvGPNGaj84IJZXMPhQuCMEVTT/hXZMJJG/aIqVL9fKxqk814sGGtJA4GI6hpJSLQjpi6cn0Qx9eOf9SDVg==", + "dev": true, + "requires": { + "undici-types": "~5.26.4" + } + }, + "ansi-colors": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", + "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", + "dev": true + }, + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0" + } + }, + "camelcase": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", + "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", + "dev": true + }, + "chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "dependencies": { + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "decamelize": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz", + "integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==", + "dev": true + }, + "diff": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", + "integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==", + "dev": true + }, + "escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true + }, + "glob": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", + "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "is-plain-obj": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", + "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==", + "dev": true + }, + "log-symbols": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", + "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", + "dev": true, + "requires": { + "chalk": "^4.1.0", + "is-unicode-supported": "^0.1.0" + } + }, + "mocha": { + "version": "10.2.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.2.0.tgz", + "integrity": "sha512-IDY7fl/BecMwFHzoqF2sg/SHHANeBoMMXFlS9r0OXKDssYE1M5O43wUY/9BVPeIvfH2zmEbBfseqN9gBQZzXkg==", + "dev": true, + "requires": { + "ansi-colors": "4.1.1", + "browser-stdout": "1.3.1", + "chokidar": "3.5.3", + "debug": "4.3.4", + "diff": "5.0.0", + "escape-string-regexp": "4.0.0", + "find-up": "5.0.0", + "glob": "7.2.0", + "he": "1.2.0", + "js-yaml": "4.1.0", + "log-symbols": "4.1.0", + "minimatch": "5.0.1", + "ms": "2.1.3", + "nanoid": "3.3.3", + "serialize-javascript": "6.0.0", + "strip-json-comments": "3.1.1", + "supports-color": "8.1.1", + "workerpool": "6.2.1", + "yargs": "16.2.0", + "yargs-parser": "20.2.4", + "yargs-unparser": "2.0.0" + }, + "dependencies": { + "minimatch": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", + "integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==", + "dev": true, + "requires": { + "brace-expansion": "^2.0.1" + } + } + } + }, + "ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true + }, + "serialize-javascript": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz", + "integrity": "sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==", + "dev": true, + "requires": { + "randombytes": "^2.1.0" + } + }, + "yargs": { + "version": "16.2.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", + "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", + "dev": true, + "requires": { + "cliui": "^7.0.2", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.0", + "y18n": "^5.0.5", + "yargs-parser": "^20.2.2" + } + }, + "yargs-unparser": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-2.0.0.tgz", + "integrity": "sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==", + "dev": true, + "requires": { + "camelcase": "^6.0.0", + "decamelize": "^4.0.0", + "flat": "^5.0.2", + "is-plain-obj": "^2.1.0" + } + } + } + }, "@opentelemetry/instrumentation-pg": { "version": "file:plugins/node/opentelemetry-instrumentation-pg", "requires": { @@ -58388,6 +59029,12 @@ "integrity": "sha512-W7tfG7vMOGtD30sHoZSSc/JVYiyDPEyQVso/Zz+/uQd0B0L46gtC+pHha5FFMRpil6fm/AoEcRWyOVi4+E/f8w==", "devOptional": true }, + "nanoid": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.3.tgz", + "integrity": "sha512-p1sjXuopFs0xg+fPASzQ28agW1oHD7xDsd9Xkf3T15H3c/cifrFHVwrh74PdoklAPi+i7MdRsE47vm2r6JoB+w==", + "dev": true + }, "nanomatch": { "version": "1.2.13", "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz", @@ -65979,6 +66626,12 @@ "errno": "~0.1.7" } }, + "workerpool": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.2.1.tgz", + "integrity": "sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw==", + "dev": true + }, "wrap-ansi": { "version": "6.2.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", diff --git a/plugins/node/opentelemetry-instrumentation-perf-hooks/.eslintignore b/plugins/node/opentelemetry-instrumentation-perf-hooks/.eslintignore new file mode 100644 index 0000000000..378eac25d3 --- /dev/null +++ b/plugins/node/opentelemetry-instrumentation-perf-hooks/.eslintignore @@ -0,0 +1 @@ +build diff --git a/plugins/node/opentelemetry-instrumentation-perf-hooks/.eslintrc.js b/plugins/node/opentelemetry-instrumentation-perf-hooks/.eslintrc.js new file mode 100644 index 0000000000..0c986a856c --- /dev/null +++ b/plugins/node/opentelemetry-instrumentation-perf-hooks/.eslintrc.js @@ -0,0 +1,7 @@ +module.exports = { + env: { + mocha: true, + node: true, + }, + ...require('../../../eslint.config.js'), +}; diff --git a/plugins/node/opentelemetry-instrumentation-perf-hooks/LICENSE b/plugins/node/opentelemetry-instrumentation-perf-hooks/LICENSE new file mode 100644 index 0000000000..e50e8c80f9 --- /dev/null +++ b/plugins/node/opentelemetry-instrumentation-perf-hooks/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [2022] OpenTelemetry Authors + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/plugins/node/opentelemetry-instrumentation-perf-hooks/README.md b/plugins/node/opentelemetry-instrumentation-perf-hooks/README.md new file mode 100644 index 0000000000..e4405e5959 --- /dev/null +++ b/plugins/node/opentelemetry-instrumentation-perf-hooks/README.md @@ -0,0 +1,80 @@ +# OpenTelemetry Node.js Performance Hooks Instrumentation + +[![NPM Published Version][npm-img]][npm-url] +[![Apache License][license-image]][license-image] + +This module provides automatic metric instrumentation that exposes measurements from the [Performance measurement APIs](https://nodejs.org/api/perf_hooks.html) (i.e. `perf_hooks`). + +## Example + +```bash +npm install --save @opentelemetry/sdk-node @opentelemetry/exporter-prometheus +npm install --save @opentelemetry/instrumentation-perf-hooks +``` + +```js +import { NodeSDK } from '@opentelemetry/sdk-node'; +import { PrometheusExporter } from '@opentelemetry/exporter-prometheus'; +import { PerfHooksInstrumentation } from '@opentelemetry/instrumentation-perf-hooks'; + +const prometheusExporter = new PrometheusExporter({ + port: 9464, + startServer: true +}); + +const sdk = new NodeSDK({ + metricReader: prometheusExporter, + instrumentations: [new PerfHooksInstrumentation({ + eventLoopUtilizationMeasurementInterval: 5000, + })], +}); + +sdk.start() +``` + +[`NodeSDK`](https://www.npmjs.com/package/@opentelemetry/sdk-node) is the full OpenTelemetry SDK for Node.js that is a layer of abstraction on top of the `@opentelemetry/sdk-metrics` and `@opentelemetry/sdk-trace-*` packages. By specifying `metricReader`, it will initialize the metrics SDK and creates a `MeterProvider`. [`@opentelemetry/exporter-prometheus`](https://www.npmjs.com/package/@opentelemetry/exporter-prometheus) will output metrics collected by registered instrumentation on a `/metrics` endpoint. + +Go to [`localhost:9464/metrics`](http://localhost:9464/metrics), and you should see: + +``` +# HELP nodejs_performance_event_loop_utilization Event loop utilization +# UNIT nodejs_performance_event_loop_utilization 1 +# TYPE nodejs_performance_event_loop_utilization gauge +nodejs_performance_event_loop_utilization 0.010140079547955264 +``` + +> Metrics will only be exported after it has collected two ELU readings (at least approximately `PerfHooksInstrumentationConfig.eventLoopUtilizationMeasurementInterval` milliseconds after initialization). Otherwise, you may see: +> ``` +> # no registered metrics +> ``` + +### Options + +`PerfHooksInstrumentation`'s constructor accepts the following options: + +| name | type | unit | default | description | +|---|---|---|---|---| +| [`eventLoopUtilizationMeasurementInterval`](./src/types.ts#L25) | `int` | millisecond | `5000` | The approximate number of milliseconds for which to calculate event loop utilization averages. A larger value will result in more accurate averages at the expense of less granular data. Should be set to below the scrape interval of your metrics collector to avoid duplicated data points. | + +## Supported Node.js versions + +v14.10.0+ + + + +## Useful links + +- For more information on OpenTelemetry, visit: +- For more about OpenTelemetry JavaScript: +- For help or feedback on this project, join us in [GitHub Discussions][discussions-url] + +## License + +Apache 2.0 - See [LICENSE][license-url] for more information. + +[discussions-url]: https://github.com/open-telemetry/opentelemetry-js/discussions +[license-url]: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/LICENSE +[license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat +[npm-url]: https://www.npmjs.com/package/@opentelemetry/instrumentation-pg +[npm-img]: https://badge.fury.io/js/%40opentelemetry%2Finstrumentation-pg.svg + diff --git a/plugins/node/opentelemetry-instrumentation-perf-hooks/package.json b/plugins/node/opentelemetry-instrumentation-perf-hooks/package.json new file mode 100644 index 0000000000..434520c6c7 --- /dev/null +++ b/plugins/node/opentelemetry-instrumentation-perf-hooks/package.json @@ -0,0 +1,52 @@ +{ + "name": "@opentelemetry/instrumentation-perf-hooks", + "version": "0.1.0", + "description": "OpenTelemetry Node.js Performance measurement API automatic instrumentation package", + "main": "build/src/index.js", + "types": "build/src/index.d.ts", + "repository": "open-telemetry/opentelemetry-js-contrib", + "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-perf-hooks", + "scripts": { + "clean": "rimraf build/*", + "compile": "tsc -p .", + "lint": "eslint . --ext .ts", + "lint:fix": "eslint . --ext .ts --fix", + "precompile": "tsc --version && lerna run version:update --scope @opentelemetry/instrumentation-perf-hooks --include-dependencies", + "prewatch": "npm run precompile", + "prepare": "npm run compile", + "test": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts'", + "version:update": "node ../../../scripts/version-update.js" + }, + "author": "OpenTelemetry Authors", + "license": "Apache-2.0", + "engines": { + "node": ">=14.10.0" + }, + "keywords": [ + "perf_hooks", + "instrumentation", + "nodejs", + "opentelemetry" + ], + "files": [ + "build/src/**/*.js", + "build/src/**/*.js.map", + "build/src/**/*.d.ts", + "LICENSE", + "README.md" + ], + "publishConfig": { + "access": "public" + }, + "peerDependencies": { + "@opentelemetry/api": "^1.0.0" + }, + "devDependencies": { + "@opentelemetry/sdk-metrics": "^1.20.0", + "@types/mocha": "^10.0.6", + "@types/node": "^20.11.2", + "mocha": "^10.2.0", + "nyc": "^15.1.0", + "ts-mocha": "^10.0.0" + } +} diff --git a/plugins/node/opentelemetry-instrumentation-perf-hooks/src/index.ts b/plugins/node/opentelemetry-instrumentation-perf-hooks/src/index.ts new file mode 100644 index 0000000000..0cd1fbc2e8 --- /dev/null +++ b/plugins/node/opentelemetry-instrumentation-perf-hooks/src/index.ts @@ -0,0 +1,17 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export * from './instrumentation'; +export * from './types'; diff --git a/plugins/node/opentelemetry-instrumentation-perf-hooks/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-perf-hooks/src/instrumentation.ts new file mode 100644 index 0000000000..d545abfd67 --- /dev/null +++ b/plugins/node/opentelemetry-instrumentation-perf-hooks/src/instrumentation.ts @@ -0,0 +1,88 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { EventLoopUtilization, performance } from 'node:perf_hooks'; +import { clearInterval, setInterval } from 'node:timers'; +const { eventLoopUtilization } = performance; + +import { InstrumentationBase } from '@opentelemetry/instrumentation'; + +import { VERSION } from './version'; +import { PerfHooksInstrumentationConfig } from './types'; + +const ELUS_LENGTH = 2; +const DEFAULT_CONFIG: PerfHooksInstrumentationConfig = { + eventLoopUtilizationMeasurementInterval: 5000, +}; + +export class PerfHooksInstrumentation extends InstrumentationBase { + private _ELUs: EventLoopUtilization[] = []; + private _interval: NodeJS.Timeout | undefined; + + constructor(config: PerfHooksInstrumentationConfig = DEFAULT_CONFIG) { + super('@opentelemetry/instrumentation-perf-hooks', VERSION, config); + } + + private _addELU() { + this._ELUs.unshift(eventLoopUtilization()); + if (this._ELUs.length > ELUS_LENGTH) { + this._ELUs.pop(); + } + } + + private _clearELU() { + if (!this._ELUs) { + this._ELUs = []; + } + this._ELUs.length = 0; + } + + // Called when a new `MeterProvider` is set + // the Meter (result of @opentelemetry/api's getMeter) is available as this.meter within this method + override _updateMetricInstruments() { + this.meter + .createObservableGauge('nodejs.performance.event_loop.utilization', { + description: 'Event loop utilization', + unit: '1', + }) + .addCallback(async observableResult => { + if (this._ELUs.length !== ELUS_LENGTH) { + return; + } + const elu = eventLoopUtilization(...this._ELUs); + observableResult.observe(elu.utilization); + }); + } + + init() { + // Not instrumenting or patching a Node.js module + } + + override enable() { + this._clearELU(); + this._addELU(); + clearInterval(this._interval); + this._interval = setInterval( + () => this._addELU(), + (this._config as PerfHooksInstrumentationConfig) + .eventLoopUtilizationMeasurementInterval + ); + } + + override disable() { + clearInterval(this._interval); + this._interval = undefined; + } +} diff --git a/plugins/node/opentelemetry-instrumentation-perf-hooks/src/types.ts b/plugins/node/opentelemetry-instrumentation-perf-hooks/src/types.ts new file mode 100644 index 0000000000..45b2790009 --- /dev/null +++ b/plugins/node/opentelemetry-instrumentation-perf-hooks/src/types.ts @@ -0,0 +1,26 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { InstrumentationConfig } from '@opentelemetry/instrumentation'; + +export interface PerfHooksInstrumentationConfig extends InstrumentationConfig { + /** + * The approximate number of milliseconds for which to calculate event loop utilization averages. + * A larger value will result in more accurate averages at the expense of less granular data. + * Should be set to below the scrape interval of your metrics collector to avoid duplicated data points. + * @default 5000 + */ + eventLoopUtilizationMeasurementInterval?: number; +} diff --git a/plugins/node/opentelemetry-instrumentation-perf-hooks/test/event_loop_utilization.test.ts b/plugins/node/opentelemetry-instrumentation-perf-hooks/test/event_loop_utilization.test.ts new file mode 100644 index 0000000000..e00ebbafd8 --- /dev/null +++ b/plugins/node/opentelemetry-instrumentation-perf-hooks/test/event_loop_utilization.test.ts @@ -0,0 +1,89 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { + AggregationTemporality, + InMemoryMetricExporter, + MeterProvider, + DataPointType, + PeriodicExportingMetricReader, +} from '@opentelemetry/sdk-metrics'; + +import { PerfHooksInstrumentation } from '../src'; +import * as assert from 'assert'; + +const EXPORT_INTERVAL = 200; + +const metricExporter = new InMemoryMetricExporter(AggregationTemporality.DELTA); +const metricReader = new PeriodicExportingMetricReader({ + exporter: metricExporter, + exportIntervalMillis: EXPORT_INTERVAL, +}); +const meterProvider = new MeterProvider(); +meterProvider.addMetricReader(metricReader); + +const instrumentation = new PerfHooksInstrumentation({ + eventLoopUtilizationMeasurementInterval: EXPORT_INTERVAL / 2, +}); + +instrumentation.setMeterProvider(meterProvider); + +describe('nodejs.performance.event_loop.utilization', () => { + before(async () => { + instrumentation.enable(); + }); + + after(() => { + instrumentation.disable(); + meterProvider.shutdown(); + }); + + afterEach(() => { + metricExporter.reset(); + }); + + it('should not export immediately after enable', async () => { + // default interval is 5000, which is much higher than EXPORT_INTERVAL + const instrumentation = new PerfHooksInstrumentation(); + instrumentation.setMeterProvider(meterProvider); + instrumentation.disable(); + instrumentation.enable(); + await new Promise(resolve => setTimeout(resolve, EXPORT_INTERVAL / 2)); + assert.deepEqual(metricExporter.getMetrics(), []); + instrumentation.disable(); + }); + + it('should export event loop utilization metrics after eventLoopUtilizationMeasurementInterval', async () => { + // Wait for the ELU data to be collected and exported + await new Promise(resolve => setTimeout(resolve, EXPORT_INTERVAL)); + const resourceMetrics = metricExporter.getMetrics(); + const scopeMetrics = resourceMetrics[0].scopeMetrics; + const metrics = scopeMetrics[0].metrics; + assert.strictEqual(metrics.length, 1); + assert.strictEqual(metrics[0].dataPointType, DataPointType.GAUGE); + assert.strictEqual(metrics[0].dataPoints.length, 1); + assert.strictEqual(metrics[0].dataPoints[0].value > 0, true); + assert.strictEqual(metrics[0].dataPoints[0].value < 1, true); + assert.strictEqual( + metrics[0].descriptor.name, + 'nodejs.performance.event_loop.utilization' + ); + assert.strictEqual( + metrics[0].descriptor.description, + 'Event loop utilization' + ); + assert.strictEqual(metrics[0].descriptor.unit, '1'); + }); +}); diff --git a/plugins/node/opentelemetry-instrumentation-perf-hooks/tsconfig.json b/plugins/node/opentelemetry-instrumentation-perf-hooks/tsconfig.json new file mode 100644 index 0000000000..28be80d266 --- /dev/null +++ b/plugins/node/opentelemetry-instrumentation-perf-hooks/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../../../tsconfig.base", + "compilerOptions": { + "rootDir": ".", + "outDir": "build" + }, + "include": [ + "src/**/*.ts", + "test/**/*.ts" + ] +} From 9fdcf0809510aaf240ad6ec1c3e1cdb7b061bbcb Mon Sep 17 00:00:00 2001 From: Daniel Li Date: Tue, 16 Jan 2024 10:11:20 +0000 Subject: [PATCH 02/14] chore(perf_hooks): rename to instrumentation-perf-hooks --- .../.eslintignore | 0 .../.eslintrc.js | 0 .../LICENSE | 0 .../README.md | 0 .../package.json | 2 +- .../src/index.ts | 0 .../src/instrumentation.ts | 0 .../src/types.ts | 0 .../test/event_loop_utilization.test.ts | 0 .../tsconfig.json | 0 10 files changed, 1 insertion(+), 1 deletion(-) rename plugins/node/{opentelemetry-instrumentation-perf-hooks => instrumentation-perf-hooks}/.eslintignore (100%) rename plugins/node/{opentelemetry-instrumentation-perf-hooks => instrumentation-perf-hooks}/.eslintrc.js (100%) rename plugins/node/{opentelemetry-instrumentation-perf-hooks => instrumentation-perf-hooks}/LICENSE (100%) rename plugins/node/{opentelemetry-instrumentation-perf-hooks => instrumentation-perf-hooks}/README.md (100%) rename plugins/node/{opentelemetry-instrumentation-perf-hooks => instrumentation-perf-hooks}/package.json (95%) rename plugins/node/{opentelemetry-instrumentation-perf-hooks => instrumentation-perf-hooks}/src/index.ts (100%) rename plugins/node/{opentelemetry-instrumentation-perf-hooks => instrumentation-perf-hooks}/src/instrumentation.ts (100%) rename plugins/node/{opentelemetry-instrumentation-perf-hooks => instrumentation-perf-hooks}/src/types.ts (100%) rename plugins/node/{opentelemetry-instrumentation-perf-hooks => instrumentation-perf-hooks}/test/event_loop_utilization.test.ts (100%) rename plugins/node/{opentelemetry-instrumentation-perf-hooks => instrumentation-perf-hooks}/tsconfig.json (100%) diff --git a/plugins/node/opentelemetry-instrumentation-perf-hooks/.eslintignore b/plugins/node/instrumentation-perf-hooks/.eslintignore similarity index 100% rename from plugins/node/opentelemetry-instrumentation-perf-hooks/.eslintignore rename to plugins/node/instrumentation-perf-hooks/.eslintignore diff --git a/plugins/node/opentelemetry-instrumentation-perf-hooks/.eslintrc.js b/plugins/node/instrumentation-perf-hooks/.eslintrc.js similarity index 100% rename from plugins/node/opentelemetry-instrumentation-perf-hooks/.eslintrc.js rename to plugins/node/instrumentation-perf-hooks/.eslintrc.js diff --git a/plugins/node/opentelemetry-instrumentation-perf-hooks/LICENSE b/plugins/node/instrumentation-perf-hooks/LICENSE similarity index 100% rename from plugins/node/opentelemetry-instrumentation-perf-hooks/LICENSE rename to plugins/node/instrumentation-perf-hooks/LICENSE diff --git a/plugins/node/opentelemetry-instrumentation-perf-hooks/README.md b/plugins/node/instrumentation-perf-hooks/README.md similarity index 100% rename from plugins/node/opentelemetry-instrumentation-perf-hooks/README.md rename to plugins/node/instrumentation-perf-hooks/README.md diff --git a/plugins/node/opentelemetry-instrumentation-perf-hooks/package.json b/plugins/node/instrumentation-perf-hooks/package.json similarity index 95% rename from plugins/node/opentelemetry-instrumentation-perf-hooks/package.json rename to plugins/node/instrumentation-perf-hooks/package.json index 434520c6c7..76a06460b8 100644 --- a/plugins/node/opentelemetry-instrumentation-perf-hooks/package.json +++ b/plugins/node/instrumentation-perf-hooks/package.json @@ -5,7 +5,7 @@ "main": "build/src/index.js", "types": "build/src/index.d.ts", "repository": "open-telemetry/opentelemetry-js-contrib", - "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-perf-hooks", + "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/instrumentation-perf-hooks", "scripts": { "clean": "rimraf build/*", "compile": "tsc -p .", diff --git a/plugins/node/opentelemetry-instrumentation-perf-hooks/src/index.ts b/plugins/node/instrumentation-perf-hooks/src/index.ts similarity index 100% rename from plugins/node/opentelemetry-instrumentation-perf-hooks/src/index.ts rename to plugins/node/instrumentation-perf-hooks/src/index.ts diff --git a/plugins/node/opentelemetry-instrumentation-perf-hooks/src/instrumentation.ts b/plugins/node/instrumentation-perf-hooks/src/instrumentation.ts similarity index 100% rename from plugins/node/opentelemetry-instrumentation-perf-hooks/src/instrumentation.ts rename to plugins/node/instrumentation-perf-hooks/src/instrumentation.ts diff --git a/plugins/node/opentelemetry-instrumentation-perf-hooks/src/types.ts b/plugins/node/instrumentation-perf-hooks/src/types.ts similarity index 100% rename from plugins/node/opentelemetry-instrumentation-perf-hooks/src/types.ts rename to plugins/node/instrumentation-perf-hooks/src/types.ts diff --git a/plugins/node/opentelemetry-instrumentation-perf-hooks/test/event_loop_utilization.test.ts b/plugins/node/instrumentation-perf-hooks/test/event_loop_utilization.test.ts similarity index 100% rename from plugins/node/opentelemetry-instrumentation-perf-hooks/test/event_loop_utilization.test.ts rename to plugins/node/instrumentation-perf-hooks/test/event_loop_utilization.test.ts diff --git a/plugins/node/opentelemetry-instrumentation-perf-hooks/tsconfig.json b/plugins/node/instrumentation-perf-hooks/tsconfig.json similarity index 100% rename from plugins/node/opentelemetry-instrumentation-perf-hooks/tsconfig.json rename to plugins/node/instrumentation-perf-hooks/tsconfig.json From 0ecc3e420e7c97b7f592f68493376cdeeb54dd2b Mon Sep 17 00:00:00 2001 From: Daniel Li Date: Tue, 16 Jan 2024 11:45:39 +0000 Subject: [PATCH 03/14] test(perf_hooks): decrease wait time for tests --- .../test/event_loop_utilization.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/node/instrumentation-perf-hooks/test/event_loop_utilization.test.ts b/plugins/node/instrumentation-perf-hooks/test/event_loop_utilization.test.ts index e00ebbafd8..bc4a0a7e2f 100644 --- a/plugins/node/instrumentation-perf-hooks/test/event_loop_utilization.test.ts +++ b/plugins/node/instrumentation-perf-hooks/test/event_loop_utilization.test.ts @@ -24,7 +24,7 @@ import { import { PerfHooksInstrumentation } from '../src'; import * as assert from 'assert'; -const EXPORT_INTERVAL = 200; +const EXPORT_INTERVAL = 20; const metricExporter = new InMemoryMetricExporter(AggregationTemporality.DELTA); const metricReader = new PeriodicExportingMetricReader({ From e8e81a723a5814d40a843408cd17a4101fad3c5d Mon Sep 17 00:00:00 2001 From: Daniel Li Date: Tue, 16 Jan 2024 11:46:33 +0000 Subject: [PATCH 04/14] fix(perf_hooks): don't export when disabled --- .../instrumentation-perf-hooks/src/instrumentation.ts | 1 + .../test/event_loop_utilization.test.ts | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/plugins/node/instrumentation-perf-hooks/src/instrumentation.ts b/plugins/node/instrumentation-perf-hooks/src/instrumentation.ts index d545abfd67..a414fe4cd0 100644 --- a/plugins/node/instrumentation-perf-hooks/src/instrumentation.ts +++ b/plugins/node/instrumentation-perf-hooks/src/instrumentation.ts @@ -82,6 +82,7 @@ export class PerfHooksInstrumentation extends InstrumentationBase { } override disable() { + this._clearELU(); clearInterval(this._interval); this._interval = undefined; } diff --git a/plugins/node/instrumentation-perf-hooks/test/event_loop_utilization.test.ts b/plugins/node/instrumentation-perf-hooks/test/event_loop_utilization.test.ts index bc4a0a7e2f..c05dbf342b 100644 --- a/plugins/node/instrumentation-perf-hooks/test/event_loop_utilization.test.ts +++ b/plugins/node/instrumentation-perf-hooks/test/event_loop_utilization.test.ts @@ -86,4 +86,12 @@ describe('nodejs.performance.event_loop.utilization', () => { ); assert.strictEqual(metrics[0].descriptor.unit, '1'); }); + + it('should stop exporting metrics when disabled', async () => { + instrumentation.disable(); + await new Promise(resolve => setTimeout(resolve, EXPORT_INTERVAL)); + const resourceMetrics = metricExporter.getMetrics(); + const scopeMetrics = resourceMetrics[0].scopeMetrics; + assert.strictEqual(scopeMetrics.length, 0); + }); }); From ed5a7be097bba45e2c7c134d5795c5a970aac098 Mon Sep 17 00:00:00 2001 From: Daniel Li Date: Tue, 16 Jan 2024 11:54:39 +0000 Subject: [PATCH 05/14] chore(perf_hooks): add empty CHANGELOG --- plugins/node/instrumentation-perf-hooks/CHANGELOG.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 plugins/node/instrumentation-perf-hooks/CHANGELOG.md diff --git a/plugins/node/instrumentation-perf-hooks/CHANGELOG.md b/plugins/node/instrumentation-perf-hooks/CHANGELOG.md new file mode 100644 index 0000000000..e69de29bb2 From 1d17f1214b765a13ccf808fa14f375e7817da30d Mon Sep 17 00:00:00 2001 From: Daniel Li Date: Tue, 16 Jan 2024 12:09:53 +0000 Subject: [PATCH 06/14] refactor(perf_hooks): use import type over import --- plugins/node/instrumentation-perf-hooks/src/types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/node/instrumentation-perf-hooks/src/types.ts b/plugins/node/instrumentation-perf-hooks/src/types.ts index 45b2790009..84f43b0162 100644 --- a/plugins/node/instrumentation-perf-hooks/src/types.ts +++ b/plugins/node/instrumentation-perf-hooks/src/types.ts @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { InstrumentationConfig } from '@opentelemetry/instrumentation'; +import type { InstrumentationConfig } from '@opentelemetry/instrumentation'; export interface PerfHooksInstrumentationConfig extends InstrumentationConfig { /** From c3aec39ec6fe247dd745d64022b9105cfc03a9e4 Mon Sep 17 00:00:00 2001 From: Daniel Li Date: Tue, 16 Jan 2024 12:10:13 +0000 Subject: [PATCH 07/14] chore(perf_hooks): add @opentelemetry/instrumentation dependency --- package-lock.json | 711 +++++++++--------- .../instrumentation-perf-hooks/package.json | 7 +- 2 files changed, 370 insertions(+), 348 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8955cc07e0..e601cd038c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8120,7 +8120,7 @@ "link": true }, "node_modules/@opentelemetry/instrumentation-perf-hooks": { - "resolved": "plugins/node/opentelemetry-instrumentation-perf-hooks", + "resolved": "plugins/node/instrumentation-perf-hooks", "link": true }, "node_modules/@opentelemetry/instrumentation-pg": { @@ -33885,6 +33885,365 @@ "integrity": "sha512-ekGvFhFgrc2zYQoX4JeZPmVzZxw6Dtllga7iGHzfbYIYkAMUx/sAFP2GdFpLff+vdHXu5fl7WX9AT+TtqYcsyw==", "dev": true }, + "plugins/node/instrumentation-perf-hooks": { + "version": "0.1.0", + "license": "Apache-2.0", + "devDependencies": { + "@opentelemetry/sdk-metrics": "^1.20.0", + "@types/mocha": "^10.0.6", + "@types/node": "^20.11.2", + "mocha": "^10.2.0", + "nyc": "^15.1.0", + "ts-mocha": "^10.0.0" + }, + "engines": { + "node": ">=14.10.0" + }, + "peerDependencies": { + "@opentelemetry/api": "^1.0.0" + } + }, + "plugins/node/instrumentation-perf-hooks/node_modules/@opentelemetry/core": { + "version": "1.20.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/core/-/core-1.20.0.tgz", + "integrity": "sha512-lSRvk5AIdD6CtgYJcJXh0wGibQ3S/8bC2qbqKs9wK8e0K1tsWV6YkGFOqVc+jIRlCbZoIBeZzDe5UI+vb94uvg==", + "dev": true, + "dependencies": { + "@opentelemetry/semantic-conventions": "1.20.0" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.8.0" + } + }, + "plugins/node/instrumentation-perf-hooks/node_modules/@opentelemetry/resources": { + "version": "1.20.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/resources/-/resources-1.20.0.tgz", + "integrity": "sha512-nOpV0vGegSq+9ze2cEDvO3BMA5pGBhmhKZiAlj+xQZjiEjPmJtdHIuBLRvptu2ahcbFJw85gIB9BYHZOvZK1JQ==", + "dev": true, + "dependencies": { + "@opentelemetry/core": "1.20.0", + "@opentelemetry/semantic-conventions": "1.20.0" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.8.0" + } + }, + "plugins/node/instrumentation-perf-hooks/node_modules/@opentelemetry/sdk-metrics": { + "version": "1.20.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-metrics/-/sdk-metrics-1.20.0.tgz", + "integrity": "sha512-07bFOQUrpN/Q5biJ/cuBePztKwkc1VGkFblZxAcVkuvCLDAPJfsyr0NNWegWeYe0bpGt1jmXScpUWnVD+t8Q0w==", + "dev": true, + "dependencies": { + "@opentelemetry/core": "1.20.0", + "@opentelemetry/resources": "1.20.0", + "lodash.merge": "^4.6.2" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.3.0 <1.8.0" + } + }, + "plugins/node/instrumentation-perf-hooks/node_modules/@opentelemetry/semantic-conventions": { + "version": "1.20.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/semantic-conventions/-/semantic-conventions-1.20.0.tgz", + "integrity": "sha512-3zLJJCgTKYpbqFX8drl8hOCHtdchELC+kGqlVcV4mHW1DiElTtv1Nt9EKBptTd1IfL56QkuYnWJ3DeHd2Gtu/A==", + "dev": true, + "engines": { + "node": ">=14" + } + }, + "plugins/node/instrumentation-perf-hooks/node_modules/@types/mocha": { + "version": "10.0.6", + "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-10.0.6.tgz", + "integrity": "sha512-dJvrYWxP/UcXm36Qn36fxhUKu8A/xMRXVT2cliFF1Z7UA9liG5Psj3ezNSZw+5puH2czDXRLcXQxf8JbJt0ejg==", + "dev": true + }, + "plugins/node/instrumentation-perf-hooks/node_modules/@types/node": { + "version": "20.11.4", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.4.tgz", + "integrity": "sha512-6I0fMH8Aoy2lOejL3s4LhyIYX34DPwY8bl5xlNjBvUEk8OHrcuzsFt+Ied4LvJihbtXPM+8zUqdydfIti86v9g==", + "dev": true, + "dependencies": { + "undici-types": "~5.26.4" + } + }, + "plugins/node/instrumentation-perf-hooks/node_modules/ansi-colors": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", + "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "plugins/node/instrumentation-perf-hooks/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "plugins/node/instrumentation-perf-hooks/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "plugins/node/instrumentation-perf-hooks/node_modules/camelcase": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", + "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "plugins/node/instrumentation-perf-hooks/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "plugins/node/instrumentation-perf-hooks/node_modules/chalk/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "plugins/node/instrumentation-perf-hooks/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "plugins/node/instrumentation-perf-hooks/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "plugins/node/instrumentation-perf-hooks/node_modules/decamelize": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz", + "integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "plugins/node/instrumentation-perf-hooks/node_modules/diff": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", + "integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==", + "dev": true, + "engines": { + "node": ">=0.3.1" + } + }, + "plugins/node/instrumentation-perf-hooks/node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "plugins/node/instrumentation-perf-hooks/node_modules/glob": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", + "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "plugins/node/instrumentation-perf-hooks/node_modules/is-plain-obj": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", + "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "plugins/node/instrumentation-perf-hooks/node_modules/log-symbols": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", + "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", + "dev": true, + "dependencies": { + "chalk": "^4.1.0", + "is-unicode-supported": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "plugins/node/instrumentation-perf-hooks/node_modules/mocha": { + "version": "10.2.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.2.0.tgz", + "integrity": "sha512-IDY7fl/BecMwFHzoqF2sg/SHHANeBoMMXFlS9r0OXKDssYE1M5O43wUY/9BVPeIvfH2zmEbBfseqN9gBQZzXkg==", + "dev": true, + "dependencies": { + "ansi-colors": "4.1.1", + "browser-stdout": "1.3.1", + "chokidar": "3.5.3", + "debug": "4.3.4", + "diff": "5.0.0", + "escape-string-regexp": "4.0.0", + "find-up": "5.0.0", + "glob": "7.2.0", + "he": "1.2.0", + "js-yaml": "4.1.0", + "log-symbols": "4.1.0", + "minimatch": "5.0.1", + "ms": "2.1.3", + "nanoid": "3.3.3", + "serialize-javascript": "6.0.0", + "strip-json-comments": "3.1.1", + "supports-color": "8.1.1", + "workerpool": "6.2.1", + "yargs": "16.2.0", + "yargs-parser": "20.2.4", + "yargs-unparser": "2.0.0" + }, + "bin": { + "_mocha": "bin/_mocha", + "mocha": "bin/mocha.js" + }, + "engines": { + "node": ">= 14.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/mochajs" + } + }, + "plugins/node/instrumentation-perf-hooks/node_modules/mocha/node_modules/minimatch": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", + "integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=10" + } + }, + "plugins/node/instrumentation-perf-hooks/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true + }, + "plugins/node/instrumentation-perf-hooks/node_modules/serialize-javascript": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz", + "integrity": "sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==", + "dev": true, + "dependencies": { + "randombytes": "^2.1.0" + } + }, + "plugins/node/instrumentation-perf-hooks/node_modules/yargs": { + "version": "16.2.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", + "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", + "dev": true, + "dependencies": { + "cliui": "^7.0.2", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.0", + "y18n": "^5.0.5", + "yargs-parser": "^20.2.2" + }, + "engines": { + "node": ">=10" + } + }, + "plugins/node/instrumentation-perf-hooks/node_modules/yargs-unparser": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-2.0.0.tgz", + "integrity": "sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==", + "dev": true, + "dependencies": { + "camelcase": "^6.0.0", + "decamelize": "^4.0.0", + "flat": "^5.0.2", + "is-plain-obj": "^2.1.0" + }, + "engines": { + "node": ">=10" + } + }, "plugins/node/instrumentation-socket.io": { "name": "@opentelemetry/instrumentation-socket.io", "version": "0.35.0", @@ -36176,6 +36535,7 @@ }, "plugins/node/opentelemetry-instrumentation-perf-hooks": { "version": "0.1.0", + "extraneous": true, "license": "Apache-2.0", "devDependencies": { "@opentelemetry/sdk-metrics": "^1.20.0", @@ -36192,347 +36552,6 @@ "@opentelemetry/api": "^1.0.0" } }, - "plugins/node/opentelemetry-instrumentation-perf-hooks/node_modules/@opentelemetry/core": { - "version": "1.20.0", - "resolved": "https://registry.npmjs.org/@opentelemetry/core/-/core-1.20.0.tgz", - "integrity": "sha512-lSRvk5AIdD6CtgYJcJXh0wGibQ3S/8bC2qbqKs9wK8e0K1tsWV6YkGFOqVc+jIRlCbZoIBeZzDe5UI+vb94uvg==", - "dev": true, - "dependencies": { - "@opentelemetry/semantic-conventions": "1.20.0" - }, - "engines": { - "node": ">=14" - }, - "peerDependencies": { - "@opentelemetry/api": ">=1.0.0 <1.8.0" - } - }, - "plugins/node/opentelemetry-instrumentation-perf-hooks/node_modules/@opentelemetry/resources": { - "version": "1.20.0", - "resolved": "https://registry.npmjs.org/@opentelemetry/resources/-/resources-1.20.0.tgz", - "integrity": "sha512-nOpV0vGegSq+9ze2cEDvO3BMA5pGBhmhKZiAlj+xQZjiEjPmJtdHIuBLRvptu2ahcbFJw85gIB9BYHZOvZK1JQ==", - "dev": true, - "dependencies": { - "@opentelemetry/core": "1.20.0", - "@opentelemetry/semantic-conventions": "1.20.0" - }, - "engines": { - "node": ">=14" - }, - "peerDependencies": { - "@opentelemetry/api": ">=1.0.0 <1.8.0" - } - }, - "plugins/node/opentelemetry-instrumentation-perf-hooks/node_modules/@opentelemetry/sdk-metrics": { - "version": "1.20.0", - "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-metrics/-/sdk-metrics-1.20.0.tgz", - "integrity": "sha512-07bFOQUrpN/Q5biJ/cuBePztKwkc1VGkFblZxAcVkuvCLDAPJfsyr0NNWegWeYe0bpGt1jmXScpUWnVD+t8Q0w==", - "dev": true, - "dependencies": { - "@opentelemetry/core": "1.20.0", - "@opentelemetry/resources": "1.20.0", - "lodash.merge": "^4.6.2" - }, - "engines": { - "node": ">=14" - }, - "peerDependencies": { - "@opentelemetry/api": ">=1.3.0 <1.8.0" - } - }, - "plugins/node/opentelemetry-instrumentation-perf-hooks/node_modules/@opentelemetry/semantic-conventions": { - "version": "1.20.0", - "resolved": "https://registry.npmjs.org/@opentelemetry/semantic-conventions/-/semantic-conventions-1.20.0.tgz", - "integrity": "sha512-3zLJJCgTKYpbqFX8drl8hOCHtdchELC+kGqlVcV4mHW1DiElTtv1Nt9EKBptTd1IfL56QkuYnWJ3DeHd2Gtu/A==", - "dev": true, - "engines": { - "node": ">=14" - } - }, - "plugins/node/opentelemetry-instrumentation-perf-hooks/node_modules/@types/mocha": { - "version": "10.0.6", - "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-10.0.6.tgz", - "integrity": "sha512-dJvrYWxP/UcXm36Qn36fxhUKu8A/xMRXVT2cliFF1Z7UA9liG5Psj3ezNSZw+5puH2czDXRLcXQxf8JbJt0ejg==", - "dev": true - }, - "plugins/node/opentelemetry-instrumentation-perf-hooks/node_modules/@types/node": { - "version": "20.11.3", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.3.tgz", - "integrity": "sha512-nrlmbvGPNGaj84IJZXMPhQuCMEVTT/hXZMJJG/aIqVL9fKxqk814sGGtJA4GI6hpJSLQjpi6cn0Qx9eOf9SDVg==", - "dev": true, - "dependencies": { - "undici-types": "~5.26.4" - } - }, - "plugins/node/opentelemetry-instrumentation-perf-hooks/node_modules/ansi-colors": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", - "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", - "dev": true, - "engines": { - "node": ">=6" - } - }, - "plugins/node/opentelemetry-instrumentation-perf-hooks/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "plugins/node/opentelemetry-instrumentation-perf-hooks/node_modules/brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", - "dev": true, - "dependencies": { - "balanced-match": "^1.0.0" - } - }, - "plugins/node/opentelemetry-instrumentation-perf-hooks/node_modules/camelcase": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", - "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", - "dev": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "plugins/node/opentelemetry-instrumentation-perf-hooks/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "plugins/node/opentelemetry-instrumentation-perf-hooks/node_modules/chalk/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "plugins/node/opentelemetry-instrumentation-perf-hooks/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "plugins/node/opentelemetry-instrumentation-perf-hooks/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "plugins/node/opentelemetry-instrumentation-perf-hooks/node_modules/decamelize": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz", - "integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==", - "dev": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "plugins/node/opentelemetry-instrumentation-perf-hooks/node_modules/diff": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", - "integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==", - "dev": true, - "engines": { - "node": ">=0.3.1" - } - }, - "plugins/node/opentelemetry-instrumentation-perf-hooks/node_modules/escape-string-regexp": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", - "dev": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "plugins/node/opentelemetry-instrumentation-perf-hooks/node_modules/glob": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", - "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", - "dev": true, - "dependencies": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - }, - "engines": { - "node": "*" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "plugins/node/opentelemetry-instrumentation-perf-hooks/node_modules/is-plain-obj": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", - "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "plugins/node/opentelemetry-instrumentation-perf-hooks/node_modules/log-symbols": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", - "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", - "dev": true, - "dependencies": { - "chalk": "^4.1.0", - "is-unicode-supported": "^0.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "plugins/node/opentelemetry-instrumentation-perf-hooks/node_modules/mocha": { - "version": "10.2.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.2.0.tgz", - "integrity": "sha512-IDY7fl/BecMwFHzoqF2sg/SHHANeBoMMXFlS9r0OXKDssYE1M5O43wUY/9BVPeIvfH2zmEbBfseqN9gBQZzXkg==", - "dev": true, - "dependencies": { - "ansi-colors": "4.1.1", - "browser-stdout": "1.3.1", - "chokidar": "3.5.3", - "debug": "4.3.4", - "diff": "5.0.0", - "escape-string-regexp": "4.0.0", - "find-up": "5.0.0", - "glob": "7.2.0", - "he": "1.2.0", - "js-yaml": "4.1.0", - "log-symbols": "4.1.0", - "minimatch": "5.0.1", - "ms": "2.1.3", - "nanoid": "3.3.3", - "serialize-javascript": "6.0.0", - "strip-json-comments": "3.1.1", - "supports-color": "8.1.1", - "workerpool": "6.2.1", - "yargs": "16.2.0", - "yargs-parser": "20.2.4", - "yargs-unparser": "2.0.0" - }, - "bin": { - "_mocha": "bin/_mocha", - "mocha": "bin/mocha.js" - }, - "engines": { - "node": ">= 14.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/mochajs" - } - }, - "plugins/node/opentelemetry-instrumentation-perf-hooks/node_modules/mocha/node_modules/minimatch": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", - "integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==", - "dev": true, - "dependencies": { - "brace-expansion": "^2.0.1" - }, - "engines": { - "node": ">=10" - } - }, - "plugins/node/opentelemetry-instrumentation-perf-hooks/node_modules/ms": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "dev": true - }, - "plugins/node/opentelemetry-instrumentation-perf-hooks/node_modules/serialize-javascript": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz", - "integrity": "sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==", - "dev": true, - "dependencies": { - "randombytes": "^2.1.0" - } - }, - "plugins/node/opentelemetry-instrumentation-perf-hooks/node_modules/yargs": { - "version": "16.2.0", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", - "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", - "dev": true, - "dependencies": { - "cliui": "^7.0.2", - "escalade": "^3.1.1", - "get-caller-file": "^2.0.5", - "require-directory": "^2.1.1", - "string-width": "^4.2.0", - "y18n": "^5.0.5", - "yargs-parser": "^20.2.2" - }, - "engines": { - "node": ">=10" - } - }, - "plugins/node/opentelemetry-instrumentation-perf-hooks/node_modules/yargs-unparser": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-2.0.0.tgz", - "integrity": "sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==", - "dev": true, - "dependencies": { - "camelcase": "^6.0.0", - "decamelize": "^4.0.0", - "flat": "^5.0.2", - "is-plain-obj": "^2.1.0" - }, - "engines": { - "node": ">=10" - } - }, "plugins/node/opentelemetry-instrumentation-pg": { "name": "@opentelemetry/instrumentation-pg", "version": "0.37.2", @@ -45223,7 +45242,7 @@ } }, "@opentelemetry/instrumentation-perf-hooks": { - "version": "file:plugins/node/opentelemetry-instrumentation-perf-hooks", + "version": "file:plugins/node/instrumentation-perf-hooks", "requires": { "@opentelemetry/sdk-metrics": "^1.20.0", "@types/mocha": "^10.0.6", @@ -45276,9 +45295,9 @@ "dev": true }, "@types/node": { - "version": "20.11.3", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.3.tgz", - "integrity": "sha512-nrlmbvGPNGaj84IJZXMPhQuCMEVTT/hXZMJJG/aIqVL9fKxqk814sGGtJA4GI6hpJSLQjpi6cn0Qx9eOf9SDVg==", + "version": "20.11.4", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.4.tgz", + "integrity": "sha512-6I0fMH8Aoy2lOejL3s4LhyIYX34DPwY8bl5xlNjBvUEk8OHrcuzsFt+Ied4LvJihbtXPM+8zUqdydfIti86v9g==", "dev": true, "requires": { "undici-types": "~5.26.4" diff --git a/plugins/node/instrumentation-perf-hooks/package.json b/plugins/node/instrumentation-perf-hooks/package.json index 76a06460b8..b1e031a5e3 100644 --- a/plugins/node/instrumentation-perf-hooks/package.json +++ b/plugins/node/instrumentation-perf-hooks/package.json @@ -38,8 +38,8 @@ "publishConfig": { "access": "public" }, - "peerDependencies": { - "@opentelemetry/api": "^1.0.0" + "dependencies": { + "@opentelemetry/instrumentation": "^0.40.0" }, "devDependencies": { "@opentelemetry/sdk-metrics": "^1.20.0", @@ -48,5 +48,8 @@ "mocha": "^10.2.0", "nyc": "^15.1.0", "ts-mocha": "^10.0.0" + }, + "peerDependencies": { + "@opentelemetry/api": "^1.0.0" } } From a46448cba10c7bfa2ba4cf2f7e4b156c7c0e5291 Mon Sep 17 00:00:00 2001 From: Daniel Li Date: Tue, 16 Jan 2024 12:52:32 +0000 Subject: [PATCH 08/14] fix(perf_hooks): sync package-lock.json --- package-lock.json | 51 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/package-lock.json b/package-lock.json index e601cd038c..72ac7b8218 100644 --- a/package-lock.json +++ b/package-lock.json @@ -33886,8 +33886,12 @@ "dev": true }, "plugins/node/instrumentation-perf-hooks": { + "name": "@opentelemetry/instrumentation-perf-hooks", "version": "0.1.0", "license": "Apache-2.0", + "dependencies": { + "@opentelemetry/instrumentation": "^0.40.0" + }, "devDependencies": { "@opentelemetry/sdk-metrics": "^1.20.0", "@types/mocha": "^10.0.6", @@ -33918,6 +33922,24 @@ "@opentelemetry/api": ">=1.0.0 <1.8.0" } }, + "plugins/node/instrumentation-perf-hooks/node_modules/@opentelemetry/instrumentation": { + "version": "0.40.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation/-/instrumentation-0.40.0.tgz", + "integrity": "sha512-23TzBKPflUS1uEq5SXymnQKQDSda35KvHjnvxdcDQGE+wg6hwDHgScUCWiBmZW4sxAaPcANfs+Wc9B7yDuyT6Q==", + "dependencies": { + "@types/shimmer": "^1.0.2", + "import-in-the-middle": "1.3.5", + "require-in-the-middle": "^7.1.0", + "semver": "^7.3.2", + "shimmer": "^1.2.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": "^1.3.0" + } + }, "plugins/node/instrumentation-perf-hooks/node_modules/@opentelemetry/resources": { "version": "1.20.0", "resolved": "https://registry.npmjs.org/@opentelemetry/resources/-/resources-1.20.0.tgz", @@ -34119,6 +34141,14 @@ "url": "https://github.com/sponsors/isaacs" } }, + "plugins/node/instrumentation-perf-hooks/node_modules/import-in-the-middle": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/import-in-the-middle/-/import-in-the-middle-1.3.5.tgz", + "integrity": "sha512-yzHlBqi1EBFrkieAnSt8eTgO5oLSl+YJ7qaOpUH/PMqQOMZoQ/RmDlwnTLQrwYto+gHYjRG+i/IbsB1eDx32NQ==", + "dependencies": { + "module-details-from-path": "^1.0.3" + } + }, "plugins/node/instrumentation-perf-hooks/node_modules/is-plain-obj": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", @@ -45244,6 +45274,7 @@ "@opentelemetry/instrumentation-perf-hooks": { "version": "file:plugins/node/instrumentation-perf-hooks", "requires": { + "@opentelemetry/instrumentation": "^0.40.0", "@opentelemetry/sdk-metrics": "^1.20.0", "@types/mocha": "^10.0.6", "@types/node": "^20.11.2", @@ -45261,6 +45292,18 @@ "@opentelemetry/semantic-conventions": "1.20.0" } }, + "@opentelemetry/instrumentation": { + "version": "0.40.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation/-/instrumentation-0.40.0.tgz", + "integrity": "sha512-23TzBKPflUS1uEq5SXymnQKQDSda35KvHjnvxdcDQGE+wg6hwDHgScUCWiBmZW4sxAaPcANfs+Wc9B7yDuyT6Q==", + "requires": { + "@types/shimmer": "^1.0.2", + "import-in-the-middle": "1.3.5", + "require-in-the-middle": "^7.1.0", + "semver": "^7.3.2", + "shimmer": "^1.2.1" + } + }, "@opentelemetry/resources": { "version": "1.20.0", "resolved": "https://registry.npmjs.org/@opentelemetry/resources/-/resources-1.20.0.tgz", @@ -45401,6 +45444,14 @@ "path-is-absolute": "^1.0.0" } }, + "import-in-the-middle": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/import-in-the-middle/-/import-in-the-middle-1.3.5.tgz", + "integrity": "sha512-yzHlBqi1EBFrkieAnSt8eTgO5oLSl+YJ7qaOpUH/PMqQOMZoQ/RmDlwnTLQrwYto+gHYjRG+i/IbsB1eDx32NQ==", + "requires": { + "module-details-from-path": "^1.0.3" + } + }, "is-plain-obj": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", From 193ea77c1e0ba2282610625f3b49503f060c6202 Mon Sep 17 00:00:00 2001 From: Daniel Li Date: Tue, 16 Jan 2024 12:52:41 +0000 Subject: [PATCH 09/14] fix(perf_hooks): Markdown lint errors --- plugins/node/instrumentation-perf-hooks/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/node/instrumentation-perf-hooks/README.md b/plugins/node/instrumentation-perf-hooks/README.md index e4405e5959..d09b9716d5 100644 --- a/plugins/node/instrumentation-perf-hooks/README.md +++ b/plugins/node/instrumentation-perf-hooks/README.md @@ -36,7 +36,7 @@ sdk.start() Go to [`localhost:9464/metrics`](http://localhost:9464/metrics), and you should see: -``` +```txt # HELP nodejs_performance_event_loop_utilization Event loop utilization # UNIT nodejs_performance_event_loop_utilization 1 # TYPE nodejs_performance_event_loop_utilization gauge @@ -44,7 +44,8 @@ nodejs_performance_event_loop_utilization 0.010140079547955264 ``` > Metrics will only be exported after it has collected two ELU readings (at least approximately `PerfHooksInstrumentationConfig.eventLoopUtilizationMeasurementInterval` milliseconds after initialization). Otherwise, you may see: -> ``` +> +> ```txt > # no registered metrics > ``` @@ -77,4 +78,3 @@ Apache 2.0 - See [LICENSE][license-url] for more information. [license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat [npm-url]: https://www.npmjs.com/package/@opentelemetry/instrumentation-pg [npm-img]: https://badge.fury.io/js/%40opentelemetry%2Finstrumentation-pg.svg - From 0f643bfe80b26d48a353b9781ce2255667ea4409 Mon Sep 17 00:00:00 2001 From: Daniel Li Date: Mon, 29 Jan 2024 10:01:34 +0000 Subject: [PATCH 10/14] chore: remove 'performance' from gauge name --- .../node/instrumentation-perf-hooks/src/instrumentation.ts | 2 +- .../test/event_loop_utilization.test.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/node/instrumentation-perf-hooks/src/instrumentation.ts b/plugins/node/instrumentation-perf-hooks/src/instrumentation.ts index a414fe4cd0..bc67492a34 100644 --- a/plugins/node/instrumentation-perf-hooks/src/instrumentation.ts +++ b/plugins/node/instrumentation-perf-hooks/src/instrumentation.ts @@ -53,7 +53,7 @@ export class PerfHooksInstrumentation extends InstrumentationBase { // the Meter (result of @opentelemetry/api's getMeter) is available as this.meter within this method override _updateMetricInstruments() { this.meter - .createObservableGauge('nodejs.performance.event_loop.utilization', { + .createObservableGauge('nodejs.event_loop.utilization', { description: 'Event loop utilization', unit: '1', }) diff --git a/plugins/node/instrumentation-perf-hooks/test/event_loop_utilization.test.ts b/plugins/node/instrumentation-perf-hooks/test/event_loop_utilization.test.ts index c05dbf342b..ff9726a725 100644 --- a/plugins/node/instrumentation-perf-hooks/test/event_loop_utilization.test.ts +++ b/plugins/node/instrumentation-perf-hooks/test/event_loop_utilization.test.ts @@ -40,7 +40,7 @@ const instrumentation = new PerfHooksInstrumentation({ instrumentation.setMeterProvider(meterProvider); -describe('nodejs.performance.event_loop.utilization', () => { +describe('nodejs.event_loop.utilization', () => { before(async () => { instrumentation.enable(); }); @@ -78,7 +78,7 @@ describe('nodejs.performance.event_loop.utilization', () => { assert.strictEqual(metrics[0].dataPoints[0].value < 1, true); assert.strictEqual( metrics[0].descriptor.name, - 'nodejs.performance.event_loop.utilization' + 'nodejs.event_loop.utilization' ); assert.strictEqual( metrics[0].descriptor.description, From 69d89018acb94753b415584a8321a23c3f59cc1f Mon Sep 17 00:00:00 2001 From: Daniel Li Date: Mon, 29 Jan 2024 10:39:40 +0000 Subject: [PATCH 11/14] fix: update release-please-config --- .release-please-manifest.json | 2 +- release-please-config.json | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index fb0eec407e..535157078e 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1 +1 @@ -{"detectors/node/opentelemetry-resource-detector-alibaba-cloud":"0.28.6","detectors/node/opentelemetry-resource-detector-aws":"1.3.6","detectors/node/opentelemetry-resource-detector-azure":"0.2.4","detectors/node/opentelemetry-resource-detector-container":"0.3.6","detectors/node/opentelemetry-resource-detector-gcp":"0.29.6","detectors/node/opentelemetry-resource-detector-github":"0.28.1","detectors/node/opentelemetry-resource-detector-instana":"0.6.0","metapackages/auto-instrumentations-node":"0.41.0","metapackages/auto-instrumentations-web":"0.36.0","packages/opentelemetry-host-metrics":"0.35.0","packages/opentelemetry-id-generator-aws-xray":"1.2.1","packages/opentelemetry-propagation-utils":"0.30.6","packages/opentelemetry-redis-common":"0.36.1","packages/opentelemetry-sql-common":"0.40.0","packages/opentelemetry-test-utils":"0.36.0","plugins/node/instrumentation-amqplib":"0.34.0","plugins/node/instrumentation-cucumber":"0.3.0","plugins/node/instrumentation-dataloader":"0.6.0","plugins/node/instrumentation-fs":"0.9.0","plugins/node/instrumentation-lru-memoizer":"0.34.0","plugins/node/instrumentation-mongoose":"0.35.0","plugins/node/instrumentation-socket.io":"0.36.0","plugins/node/instrumentation-tedious":"0.7.0","plugins/node/opentelemetry-instrumentation-aws-lambda":"0.38.0","plugins/node/opentelemetry-instrumentation-aws-sdk":"0.38.0","plugins/node/opentelemetry-instrumentation-bunyan":"0.35.0","plugins/node/opentelemetry-instrumentation-cassandra":"0.35.0","plugins/node/opentelemetry-instrumentation-connect":"0.33.0","plugins/node/opentelemetry-instrumentation-dns":"0.33.0","plugins/node/opentelemetry-instrumentation-express":"0.35.0","plugins/node/opentelemetry-instrumentation-fastify":"0.33.0","plugins/node/opentelemetry-instrumentation-generic-pool":"0.33.0","plugins/node/opentelemetry-instrumentation-graphql":"0.37.0","plugins/node/opentelemetry-instrumentation-hapi":"0.34.0","plugins/node/opentelemetry-instrumentation-ioredis":"0.37.0","plugins/node/opentelemetry-instrumentation-knex":"0.33.0","plugins/node/opentelemetry-instrumentation-koa":"0.37.0","plugins/node/opentelemetry-instrumentation-memcached":"0.33.0","plugins/node/opentelemetry-instrumentation-mongodb":"0.39.0","plugins/node/opentelemetry-instrumentation-mysql":"0.35.0","plugins/node/opentelemetry-instrumentation-mysql2":"0.35.0","plugins/node/opentelemetry-instrumentation-nestjs-core":"0.34.0","plugins/node/opentelemetry-instrumentation-net":"0.33.0","plugins/node/opentelemetry-instrumentation-pg":"0.38.0","plugins/node/opentelemetry-instrumentation-pino":"0.35.0","plugins/node/opentelemetry-instrumentation-redis":"0.36.0","plugins/node/opentelemetry-instrumentation-redis-4":"0.36.0","plugins/node/opentelemetry-instrumentation-restify":"0.35.0","plugins/node/opentelemetry-instrumentation-router":"0.34.0","plugins/node/opentelemetry-instrumentation-winston":"0.34.0","plugins/web/opentelemetry-instrumentation-document-load":"0.35.0","plugins/web/opentelemetry-instrumentation-long-task":"0.35.0","plugins/web/opentelemetry-instrumentation-user-interaction":"0.35.0","plugins/web/opentelemetry-plugin-react-load":"0.30.0","propagators/opentelemetry-propagator-aws-xray":"1.3.1","propagators/opentelemetry-propagator-grpc-census-binary":"0.27.1","propagators/opentelemetry-propagator-instana":"0.3.1","propagators/opentelemetry-propagator-ot-trace":"0.27.1"} +{"detectors/node/opentelemetry-resource-detector-alibaba-cloud":"0.28.6","detectors/node/opentelemetry-resource-detector-aws":"1.3.6","detectors/node/opentelemetry-resource-detector-azure":"0.2.4","detectors/node/opentelemetry-resource-detector-container":"0.3.6","detectors/node/opentelemetry-resource-detector-gcp":"0.29.6","detectors/node/opentelemetry-resource-detector-github":"0.28.1","detectors/node/opentelemetry-resource-detector-instana":"0.6.0","metapackages/auto-instrumentations-node":"0.41.0","metapackages/auto-instrumentations-web":"0.36.0","packages/opentelemetry-host-metrics":"0.35.0","packages/opentelemetry-id-generator-aws-xray":"1.2.1","packages/opentelemetry-propagation-utils":"0.30.6","packages/opentelemetry-redis-common":"0.36.1","packages/opentelemetry-sql-common":"0.40.0","packages/opentelemetry-test-utils":"0.36.0","plugins/node/instrumentation-amqplib":"0.34.0","plugins/node/instrumentation-cucumber":"0.3.0","plugins/node/instrumentation-dataloader":"0.6.0","plugins/node/instrumentation-fs":"0.9.0","plugins/node/instrumentation-lru-memoizer":"0.34.0","plugins/node/instrumentation-mongoose":"0.35.0","plugins/node/instrumentation-perf-hooks": "0.1.0","plugins/node/instrumentation-socket.io":"0.36.0","plugins/node/instrumentation-tedious":"0.7.0","plugins/node/opentelemetry-instrumentation-aws-lambda":"0.38.0","plugins/node/opentelemetry-instrumentation-aws-sdk":"0.38.0","plugins/node/opentelemetry-instrumentation-bunyan":"0.35.0","plugins/node/opentelemetry-instrumentation-cassandra":"0.35.0","plugins/node/opentelemetry-instrumentation-connect":"0.33.0","plugins/node/opentelemetry-instrumentation-dns":"0.33.0","plugins/node/opentelemetry-instrumentation-express":"0.35.0","plugins/node/opentelemetry-instrumentation-fastify":"0.33.0","plugins/node/opentelemetry-instrumentation-generic-pool":"0.33.0","plugins/node/opentelemetry-instrumentation-graphql":"0.37.0","plugins/node/opentelemetry-instrumentation-hapi":"0.34.0","plugins/node/opentelemetry-instrumentation-ioredis":"0.37.0","plugins/node/opentelemetry-instrumentation-knex":"0.33.0","plugins/node/opentelemetry-instrumentation-koa":"0.37.0","plugins/node/opentelemetry-instrumentation-memcached":"0.33.0","plugins/node/opentelemetry-instrumentation-mongodb":"0.39.0","plugins/node/opentelemetry-instrumentation-mysql":"0.35.0","plugins/node/opentelemetry-instrumentation-mysql2":"0.35.0","plugins/node/opentelemetry-instrumentation-nestjs-core":"0.34.0","plugins/node/opentelemetry-instrumentation-net":"0.33.0","plugins/node/opentelemetry-instrumentation-pg":"0.38.0","plugins/node/opentelemetry-instrumentation-pino":"0.35.0","plugins/node/opentelemetry-instrumentation-redis":"0.36.0","plugins/node/opentelemetry-instrumentation-redis-4":"0.36.0","plugins/node/opentelemetry-instrumentation-restify":"0.35.0","plugins/node/opentelemetry-instrumentation-router":"0.34.0","plugins/node/opentelemetry-instrumentation-winston":"0.34.0","plugins/web/opentelemetry-instrumentation-document-load":"0.35.0","plugins/web/opentelemetry-instrumentation-long-task":"0.35.0","plugins/web/opentelemetry-instrumentation-user-interaction":"0.35.0","plugins/web/opentelemetry-plugin-react-load":"0.30.0","propagators/opentelemetry-propagator-aws-xray":"1.3.1","propagators/opentelemetry-propagator-grpc-census-binary":"0.27.1","propagators/opentelemetry-propagator-instana":"0.3.1","propagators/opentelemetry-propagator-ot-trace":"0.27.1"} diff --git a/release-please-config.json b/release-please-config.json index e55af5702e..7f2fe5a1bb 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -27,6 +27,7 @@ "plugins/node/instrumentation-fs": {}, "plugins/node/instrumentation-lru-memoizer": {}, "plugins/node/instrumentation-mongoose": {}, + "plugins/node/instrumentation-perf-hooks": {}, "plugins/node/instrumentation-socket.io": {}, "plugins/node/instrumentation-tedious": {}, "plugins/node/opentelemetry-instrumentation-aws-lambda": {}, From dfe284055d9cd8ba5d719e933ba28cf17c3d7cc1 Mon Sep 17 00:00:00 2001 From: Daniel Li Date: Mon, 29 Jan 2024 10:43:28 +0000 Subject: [PATCH 12/14] fix(perf_hooks): peer-api-check --- plugins/node/instrumentation-perf-hooks/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/node/instrumentation-perf-hooks/package.json b/plugins/node/instrumentation-perf-hooks/package.json index b1e031a5e3..6a7a9fa97b 100644 --- a/plugins/node/instrumentation-perf-hooks/package.json +++ b/plugins/node/instrumentation-perf-hooks/package.json @@ -42,6 +42,7 @@ "@opentelemetry/instrumentation": "^0.40.0" }, "devDependencies": { + "@opentelemetry/api": "^1.0.0", "@opentelemetry/sdk-metrics": "^1.20.0", "@types/mocha": "^10.0.6", "@types/node": "^20.11.2", From 928f8ac9ef9759725d8c27ad39e79dfe3b066b38 Mon Sep 17 00:00:00 2001 From: Daniel Li Date: Tue, 30 Jan 2024 15:16:59 +0000 Subject: [PATCH 13/14] chore(perf_hooks): update devDependencies --- package-lock.json | 10 ++++++++-- plugins/node/instrumentation-perf-hooks/package.json | 4 +++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index acaba4e999..21ed3dc792 100644 --- a/package-lock.json +++ b/package-lock.json @@ -34231,12 +34231,15 @@ "@opentelemetry/instrumentation": "^0.40.0" }, "devDependencies": { + "@opentelemetry/api": "^1.0.0", "@opentelemetry/sdk-metrics": "^1.20.0", "@types/mocha": "^10.0.6", "@types/node": "^20.11.2", "mocha": "^10.2.0", "nyc": "^15.1.0", - "ts-mocha": "^10.0.0" + "rimraf": "5.0.5", + "ts-mocha": "10.0.0", + "typescript": "4.4.4" }, "engines": { "node": ">=14.10.0" @@ -45514,13 +45517,16 @@ "@opentelemetry/instrumentation-perf-hooks": { "version": "file:plugins/node/instrumentation-perf-hooks", "requires": { + "@opentelemetry/api": "^1.0.0", "@opentelemetry/instrumentation": "^0.40.0", "@opentelemetry/sdk-metrics": "^1.20.0", "@types/mocha": "^10.0.6", "@types/node": "^20.11.2", "mocha": "^10.2.0", "nyc": "^15.1.0", - "ts-mocha": "^10.0.0" + "rimraf": "5.0.5", + "ts-mocha": "10.0.0", + "typescript": "4.4.4" }, "dependencies": { "@opentelemetry/core": { diff --git a/plugins/node/instrumentation-perf-hooks/package.json b/plugins/node/instrumentation-perf-hooks/package.json index 6a7a9fa97b..6e40c2aeb5 100644 --- a/plugins/node/instrumentation-perf-hooks/package.json +++ b/plugins/node/instrumentation-perf-hooks/package.json @@ -48,7 +48,9 @@ "@types/node": "^20.11.2", "mocha": "^10.2.0", "nyc": "^15.1.0", - "ts-mocha": "^10.0.0" + "rimraf": "5.0.5", + "ts-mocha": "10.0.0", + "typescript": "4.4.4" }, "peerDependencies": { "@opentelemetry/api": "^1.0.0" From c0ef756ac716fe477b6b750db8aa704dba2dfd83 Mon Sep 17 00:00:00 2001 From: Daniel Li Date: Tue, 30 Jan 2024 19:28:16 +0000 Subject: [PATCH 14/14] test(perf_hooks): fix flakey tests --- .../test/event_loop_utilization.test.ts | 54 +++++++++++-------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/plugins/node/instrumentation-perf-hooks/test/event_loop_utilization.test.ts b/plugins/node/instrumentation-perf-hooks/test/event_loop_utilization.test.ts index ff9726a725..89c2420cfb 100644 --- a/plugins/node/instrumentation-perf-hooks/test/event_loop_utilization.test.ts +++ b/plugins/node/instrumentation-perf-hooks/test/event_loop_utilization.test.ts @@ -24,25 +24,26 @@ import { import { PerfHooksInstrumentation } from '../src'; import * as assert from 'assert'; -const EXPORT_INTERVAL = 20; +const MEASUREMENT_INTERVAL = 10; const metricExporter = new InMemoryMetricExporter(AggregationTemporality.DELTA); const metricReader = new PeriodicExportingMetricReader({ exporter: metricExporter, - exportIntervalMillis: EXPORT_INTERVAL, + exportIntervalMillis: MEASUREMENT_INTERVAL * 2, }); const meterProvider = new MeterProvider(); meterProvider.addMetricReader(metricReader); const instrumentation = new PerfHooksInstrumentation({ - eventLoopUtilizationMeasurementInterval: EXPORT_INTERVAL / 2, + eventLoopUtilizationMeasurementInterval: MEASUREMENT_INTERVAL, }); instrumentation.setMeterProvider(meterProvider); describe('nodejs.event_loop.utilization', () => { - before(async () => { - instrumentation.enable(); + beforeEach(async () => { + instrumentation.disable(); // Stops future metrics from being collected + metricExporter.reset(); // Remove existing collected metrics }); after(() => { @@ -50,26 +51,41 @@ describe('nodejs.event_loop.utilization', () => { meterProvider.shutdown(); }); - afterEach(() => { - metricExporter.reset(); + it('should stop exporting metrics when disabled', async () => { + // Wait for the ELU data to be collected and exported + // MEASUREMENT_INTERVAL * 2 is the export interval, plus MEASUREMENT_INTERVAL as a buffer + await new Promise(resolve => setTimeout(resolve, MEASUREMENT_INTERVAL * 3)); + // Retrieve exported metrics + const resourceMetrics = metricExporter.getMetrics(); + const scopeMetrics = + resourceMetrics[resourceMetrics.length - 1].scopeMetrics; + assert.strictEqual(scopeMetrics.length, 0); }); it('should not export immediately after enable', async () => { - // default interval is 5000, which is much higher than EXPORT_INTERVAL - const instrumentation = new PerfHooksInstrumentation(); - instrumentation.setMeterProvider(meterProvider); - instrumentation.disable(); instrumentation.enable(); - await new Promise(resolve => setTimeout(resolve, EXPORT_INTERVAL / 2)); assert.deepEqual(metricExporter.getMetrics(), []); - instrumentation.disable(); + }); + + it('can use default eventLoopUtilizationMeasurementInterval', async () => { + // Repeat of 'should not export immediately after enable' but with defaults + const localInstrumentation = new PerfHooksInstrumentation(); + localInstrumentation.setMeterProvider(meterProvider); + localInstrumentation.disable(); + metricExporter.reset(); + localInstrumentation.enable(); + assert.deepEqual(metricExporter.getMetrics(), []); + localInstrumentation.disable(); }); it('should export event loop utilization metrics after eventLoopUtilizationMeasurementInterval', async () => { + instrumentation.enable(); // Wait for the ELU data to be collected and exported - await new Promise(resolve => setTimeout(resolve, EXPORT_INTERVAL)); + // MEASUREMENT_INTERVAL * 2 is the export interval, plus MEASUREMENT_INTERVAL as a buffer + await new Promise(resolve => setTimeout(resolve, MEASUREMENT_INTERVAL * 3)); const resourceMetrics = metricExporter.getMetrics(); - const scopeMetrics = resourceMetrics[0].scopeMetrics; + const scopeMetrics = + resourceMetrics[resourceMetrics.length - 1].scopeMetrics; const metrics = scopeMetrics[0].metrics; assert.strictEqual(metrics.length, 1); assert.strictEqual(metrics[0].dataPointType, DataPointType.GAUGE); @@ -86,12 +102,4 @@ describe('nodejs.event_loop.utilization', () => { ); assert.strictEqual(metrics[0].descriptor.unit, '1'); }); - - it('should stop exporting metrics when disabled', async () => { - instrumentation.disable(); - await new Promise(resolve => setTimeout(resolve, EXPORT_INTERVAL)); - const resourceMetrics = metricExporter.getMetrics(); - const scopeMetrics = resourceMetrics[0].scopeMetrics; - assert.strictEqual(scopeMetrics.length, 0); - }); });