From ebca53765196c0fe45591fb85e6bb8adfb01be78 Mon Sep 17 00:00:00 2001 From: JGAntunes Date: Tue, 14 Nov 2023 18:41:27 +0000 Subject: [PATCH 01/16] chore: move opentelemetry sdk init logic --- package-lock.json | 1238 ++++++++++++++++- packages/opentelemetry-sdk-setup/README.md | 0 packages/opentelemetry-sdk-setup/package.json | 52 + packages/opentelemetry-sdk-setup/src/bin.ts | 42 + .../opentelemetry-sdk-setup/src/sdk-setup.ts | 86 ++ packages/opentelemetry-sdk-setup/src/util.ts | 102 ++ .../opentelemetry-sdk-setup/tsconfig.json | 8 + .../opentelemetry-sdk-setup/vitest.config.ts | 11 + 8 files changed, 1537 insertions(+), 2 deletions(-) create mode 100644 packages/opentelemetry-sdk-setup/README.md create mode 100644 packages/opentelemetry-sdk-setup/package.json create mode 100644 packages/opentelemetry-sdk-setup/src/bin.ts create mode 100644 packages/opentelemetry-sdk-setup/src/sdk-setup.ts create mode 100644 packages/opentelemetry-sdk-setup/src/util.ts create mode 100644 packages/opentelemetry-sdk-setup/tsconfig.json create mode 100644 packages/opentelemetry-sdk-setup/vitest.config.ts diff --git a/package-lock.json b/package-lock.json index be96e209ef..2cadbb8b27 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6819,6 +6819,10 @@ "resolved": "https://registry.npmjs.org/@netlify/open-api/-/open-api-2.26.0.tgz", "integrity": "sha512-B7q+ySzQm6rJhaGbY0Pzqnb1p3FsBqwiPLnLtA17JgTsqmXgQ7j6OQImW9fRJy/Al1ob9M6Oxng/FA2c7aIW1g==" }, + "node_modules/@netlify/opentelemetry-sdk-setup": { + "resolved": "packages/opentelemetry-sdk-setup", + "link": true + }, "node_modules/@netlify/plugins-list": { "version": "6.72.0", "resolved": "https://registry.npmjs.org/@netlify/plugins-list/-/plugins-list-6.72.0.tgz", @@ -9791,6 +9795,11 @@ "integrity": "sha512-+d+WYC1BxJ6yVOgUgzK8gWvp5qF8ssV5r4nsDcZWKRWcDQLQ619tvWAxJQYGgBrO1MnLJC7a5GtiYsAoQ47dJg==", "dev": true }, + "node_modules/@types/shimmer": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@types/shimmer/-/shimmer-1.0.5.tgz", + "integrity": "sha512-9Hp0ObzwwO57DpLFF0InUjUm/II8GmKAvzbefxQTihCb7KI6yc9yzf0nLc4mVdby5N4DRCgQM2wCup9KTieeww==" + }, "node_modules/@types/yargs": { "version": "16.0.5", "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-16.0.5.tgz", @@ -10555,8 +10564,6 @@ "version": "1.9.0", "resolved": "https://registry.npmjs.org/acorn-import-assertions/-/acorn-import-assertions-1.9.0.tgz", "integrity": "sha512-cmMwop9x+8KFhxvKrKfPYmN6/pKTYYHBqLa0DfvVZcKMJWNyWLnaqND7dx/qn66R7ewM1UX5XMaDVP5wlVTaVA==", - "dev": true, - "peer": true, "peerDependencies": { "acorn": "^8" } @@ -11986,6 +11993,11 @@ "integrity": "sha512-uvzpYrpmidaoxvIQHM+rKSrigjOe9feHYbw4uOI2gdfe1C3xIlxO+kVXq83WQWNniTf8bAxVpy+cQeFQsMERKg==", "dev": true }, + "node_modules/cjs-module-lexer": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/cjs-module-lexer/-/cjs-module-lexer-1.2.3.tgz", + "integrity": "sha512-0TNiGstbQmCFwt4akjjBg5pLRTSyj/PkWQ1ZoO2zntmg9yLqSRxwEa4iCfQLGjqhiqBfOJa7W/E8wfGrTDmlZQ==" + }, "node_modules/clean-stack": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-4.2.0.tgz", @@ -16448,6 +16460,17 @@ "node": ">=4" } }, + "node_modules/import-in-the-middle": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/import-in-the-middle/-/import-in-the-middle-1.4.2.tgz", + "integrity": "sha512-9WOz1Yh/cvO/p69sxRmhyQwrIGGSp7EIdcb+fFNVi7CzQGQB8U1/1XrKVSbEd/GNOAeM0peJtmi7+qphe7NvAw==", + "dependencies": { + "acorn": "^8.8.2", + "acorn-import-assertions": "^1.9.0", + "cjs-module-lexer": "^1.2.2", + "module-details-from-path": "^1.0.3" + } + }, "node_modules/import-local": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/import-local/-/import-local-3.1.0.tgz", @@ -27108,6 +27131,1217 @@ "node": "^14.16.0 || >=16.0.0" } }, + "packages/opentelemetry-sdk-setup": { + "name": "@netlify/opentelemetry-sdk-setup", + "version": "1.0.0", + "license": "MIT", + "dependencies": { + "@honeycombio/opentelemetry-node": "^0.6.0", + "@opentelemetry/api": "~1.6.0", + "@opentelemetry/core": "^1.17.1", + "@opentelemetry/resources": "^1.18.1", + "@opentelemetry/semantic-conventions": "^1.18.1", + "yargs-parser": "^21.1.1" + }, + "bin": { + "otel-sdk-setup": "lib/bin.js" + }, + "devDependencies": { + "@types/node": "^14.18.53", + "@types/semver": "^7.3.13", + "@vitest/coverage-c8": "^0.30.1", + "@vitest/ui": "^0.30.1", + "typescript": "^5.0.0", + "unionfs": "^4.4.0", + "vite": "^4.0.4", + "vitest": "^0.30.1" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@honeycombio/opentelemetry-node": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/@honeycombio/opentelemetry-node/-/opentelemetry-node-0.6.0.tgz", + "integrity": "sha512-wUXNGZj0DAVV+ICiRnqdKhJl+u5XB9lDi44LNpmtvfOt4atbu2LP04m6pxNQyDkk/Ue5Xu4YhkCZ+VO0Izbrsg==", + "dependencies": { + "@grpc/grpc-js": "^1.7.3", + "@opentelemetry/api": "^1.6.0", + "@opentelemetry/core": "^1.17.1", + "@opentelemetry/exporter-metrics-otlp-grpc": "^0.44.0", + "@opentelemetry/exporter-metrics-otlp-proto": "^0.44.0", + "@opentelemetry/exporter-trace-otlp-grpc": "^0.44.0", + "@opentelemetry/exporter-trace-otlp-proto": "^0.44.0", + "@opentelemetry/resources": "^1.17.1", + "@opentelemetry/sdk-metrics": "^1.17.1", + "@opentelemetry/sdk-node": "^0.44.0", + "@opentelemetry/sdk-trace-base": "^1.17.1", + "axios": "^1.1.3" + }, + "engines": { + "node": ">=14" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@honeycombio/opentelemetry-node/node_modules/@opentelemetry/api-logs": { + "version": "0.44.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/api-logs/-/api-logs-0.44.0.tgz", + "integrity": "sha512-OctojdKGmXHKAJa4/Ml+Nf7MD9jtYXvZyP64xTh0pNTmtgaTdWW3FURri2DdB/+l7YxRy0tYYZS3/tYEM1pj3w==", + "dependencies": { + "@opentelemetry/api": "^1.0.0" + }, + "engines": { + "node": ">=14" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@honeycombio/opentelemetry-node/node_modules/@opentelemetry/context-async-hooks": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/context-async-hooks/-/context-async-hooks-1.17.1.tgz", + "integrity": "sha512-up5I+RiQEkGrVEHtbAtmRgS+ZOnFh3shaDNHqZPBlGy+O92auL6yMmjzYpSKmJOGWowvs3fhVHePa8Exb5iHUg==", + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.7.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@honeycombio/opentelemetry-node/node_modules/@opentelemetry/core": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/core/-/core-1.17.1.tgz", + "integrity": "sha512-I6LrZvl1FF97FQXPR0iieWQmKnGxYtMbWA1GrAXnLUR+B1Hn2m8KqQNEIlZAucyv00GBgpWkpllmULmZfG8P3g==", + "dependencies": { + "@opentelemetry/semantic-conventions": "1.17.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.7.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@honeycombio/opentelemetry-node/node_modules/@opentelemetry/exporter-trace-otlp-http": { + "version": "0.44.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/exporter-trace-otlp-http/-/exporter-trace-otlp-http-0.44.0.tgz", + "integrity": "sha512-RkorGE6wf6PF5OjMUGBnbUDyaVgmN+vL7OgClJJUTxqbE7WqgbW8dkU04O+1mcB1znXZ1Aej1uDm0pS+eW/upA==", + "dependencies": { + "@opentelemetry/core": "1.17.1", + "@opentelemetry/otlp-exporter-base": "0.44.0", + "@opentelemetry/otlp-transformer": "0.44.0", + "@opentelemetry/resources": "1.17.1", + "@opentelemetry/sdk-trace-base": "1.17.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": "^1.0.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@honeycombio/opentelemetry-node/node_modules/@opentelemetry/exporter-zipkin": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/exporter-zipkin/-/exporter-zipkin-1.17.1.tgz", + "integrity": "sha512-FaLZlIhdpxlZiKu/G8OvA+so4xoCL1hCo/JgNdeSxzI4GnJrmFFbZT6DXgUzXJO7F9Qw3KDE1cBFUHawLVz58g==", + "dependencies": { + "@opentelemetry/core": "1.17.1", + "@opentelemetry/resources": "1.17.1", + "@opentelemetry/sdk-trace-base": "1.17.1", + "@opentelemetry/semantic-conventions": "1.17.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": "^1.0.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@honeycombio/opentelemetry-node/node_modules/@opentelemetry/instrumentation": { + "version": "0.44.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation/-/instrumentation-0.44.0.tgz", + "integrity": "sha512-B6OxJTRRCceAhhnPDBshyQO7K07/ltX3quOLu0icEvPK9QZ7r9P1y0RQX8O5DxB4vTv4URRkxkg+aFU/plNtQw==", + "dependencies": { + "@types/shimmer": "^1.0.2", + "import-in-the-middle": "1.4.2", + "require-in-the-middle": "^7.1.1", + "semver": "^7.5.2", + "shimmer": "^1.2.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": "^1.3.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@honeycombio/opentelemetry-node/node_modules/@opentelemetry/otlp-transformer": { + "version": "0.44.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/otlp-transformer/-/otlp-transformer-0.44.0.tgz", + "integrity": "sha512-1/KC+aHM1oGEsXyNy7QoxpvErxGdzt26bg9VHyNb4TDILkUFdwrnywnxPc6lXZ6h/8T8Mt718UWOKjNHC514kQ==", + "dependencies": { + "@opentelemetry/api-logs": "0.44.0", + "@opentelemetry/core": "1.17.1", + "@opentelemetry/resources": "1.17.1", + "@opentelemetry/sdk-logs": "0.44.0", + "@opentelemetry/sdk-metrics": "1.17.1", + "@opentelemetry/sdk-trace-base": "1.17.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.3.0 <1.7.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@honeycombio/opentelemetry-node/node_modules/@opentelemetry/propagator-b3": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/propagator-b3/-/propagator-b3-1.17.1.tgz", + "integrity": "sha512-XEbXYb81AM3ayJLlbJqITPIgKBQCuby45ZHiB9mchnmQOffh6ZJOmXONdtZAV7TWzmzwvAd28vGSUk57Aw/5ZA==", + "dependencies": { + "@opentelemetry/core": "1.17.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.7.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@honeycombio/opentelemetry-node/node_modules/@opentelemetry/propagator-jaeger": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/propagator-jaeger/-/propagator-jaeger-1.17.1.tgz", + "integrity": "sha512-p+P4lf2pbqd3YMfZO15QCGsDwR2m1ke2q5+dq6YBLa/q0qiC2eq4cD/qhYBBed5/X4PtdamaVGHGsp+u3GXHDA==", + "dependencies": { + "@opentelemetry/core": "1.17.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.7.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@honeycombio/opentelemetry-node/node_modules/@opentelemetry/resources": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/resources/-/resources-1.17.1.tgz", + "integrity": "sha512-M2e5emqg5I7qRKqlzKx0ROkcPyF8PbcSaWEdsm72od9txP7Z/Pl8PDYOyu80xWvbHAWk5mDxOF6v3vNdifzclA==", + "dependencies": { + "@opentelemetry/core": "1.17.1", + "@opentelemetry/semantic-conventions": "1.17.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.7.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@honeycombio/opentelemetry-node/node_modules/@opentelemetry/sdk-logs": { + "version": "0.44.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-logs/-/sdk-logs-0.44.0.tgz", + "integrity": "sha512-UN3ofh9Jj54gIgrSXNRWAoaH6iPvrrjed5YAtqO9cW65U+5QPzk1Rv95vjAcY9VTrmMWvuqgEK1CYObG6Hu4OQ==", + "dependencies": { + "@opentelemetry/core": "1.17.1", + "@opentelemetry/resources": "1.17.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.4.0 <1.7.0", + "@opentelemetry/api-logs": ">=0.39.1" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@honeycombio/opentelemetry-node/node_modules/@opentelemetry/sdk-metrics": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-metrics/-/sdk-metrics-1.17.1.tgz", + "integrity": "sha512-eHdpsMCKhKhwznxvEfls8Wv3y4ZBWkkXlD3m7vtHIiWBqsMHspWSfie1s07mM45i/bBCf6YBMgz17FUxIXwmZA==", + "dependencies": { + "@opentelemetry/core": "1.17.1", + "@opentelemetry/resources": "1.17.1", + "lodash.merge": "^4.6.2" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.3.0 <1.7.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@honeycombio/opentelemetry-node/node_modules/@opentelemetry/sdk-node": { + "version": "0.44.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-node/-/sdk-node-0.44.0.tgz", + "integrity": "sha512-MkMJcUcqjNV/A5/y6quedSO3CIDXY17jM8sxQa0Hwmx77+/QiXJkSe4Zv0ysf37mV5+8QEt4rsq7adKg+LtaEg==", + "dependencies": { + "@opentelemetry/api-logs": "0.44.0", + "@opentelemetry/core": "1.17.1", + "@opentelemetry/exporter-jaeger": "1.17.1", + "@opentelemetry/exporter-trace-otlp-grpc": "0.44.0", + "@opentelemetry/exporter-trace-otlp-http": "0.44.0", + "@opentelemetry/exporter-trace-otlp-proto": "0.44.0", + "@opentelemetry/exporter-zipkin": "1.17.1", + "@opentelemetry/instrumentation": "0.44.0", + "@opentelemetry/resources": "1.17.1", + "@opentelemetry/sdk-logs": "0.44.0", + "@opentelemetry/sdk-metrics": "1.17.1", + "@opentelemetry/sdk-trace-base": "1.17.1", + "@opentelemetry/sdk-trace-node": "1.17.1", + "@opentelemetry/semantic-conventions": "1.17.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.3.0 <1.7.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@honeycombio/opentelemetry-node/node_modules/@opentelemetry/sdk-trace-base": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-trace-base/-/sdk-trace-base-1.17.1.tgz", + "integrity": "sha512-pfSJJSjZj5jkCJUQZicSpzN8Iz9UKMryPWikZRGObPnJo6cUSoKkjZh6BM3j+D47G4olMBN+YZKYqkFM1L6zNA==", + "dependencies": { + "@opentelemetry/core": "1.17.1", + "@opentelemetry/resources": "1.17.1", + "@opentelemetry/semantic-conventions": "1.17.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.7.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@honeycombio/opentelemetry-node/node_modules/@opentelemetry/sdk-trace-node": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-trace-node/-/sdk-trace-node-1.17.1.tgz", + "integrity": "sha512-J56DaG4cusjw5crpI7x9rv4bxDF27DtKYGxXJF56KIvopbNKpdck5ZWXBttEyqgAVPDwHMAXWDL1KchHzF0a3A==", + "dependencies": { + "@opentelemetry/context-async-hooks": "1.17.1", + "@opentelemetry/core": "1.17.1", + "@opentelemetry/propagator-b3": "1.17.1", + "@opentelemetry/propagator-jaeger": "1.17.1", + "@opentelemetry/sdk-trace-base": "1.17.1", + "semver": "^7.5.2" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.7.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@honeycombio/opentelemetry-node/node_modules/@opentelemetry/semantic-conventions": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/semantic-conventions/-/semantic-conventions-1.17.1.tgz", + "integrity": "sha512-xbR2U+2YjauIuo42qmE8XyJK6dYeRMLJuOlUP5SO4auET4VtOHOzgkRVOq+Ik18N+Xf3YPcqJs9dZMiDddz1eQ==", + "engines": { + "node": ">=14" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/api": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.6.0.tgz", + "integrity": "sha512-OWlrQAnWn9577PhVgqjUvMr1pg57Bc4jv0iL4w0PRuOSRvq67rvHW9Ie/dZVMvCzhSCB+UxhcY/PmCmFj33Q+g==", + "engines": { + "node": ">=8.0.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/core": { + "version": "1.18.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/core/-/core-1.18.1.tgz", + "integrity": "sha512-kvnUqezHMhsQvdsnhnqTNfAJs3ox/isB0SVrM1dhVFw7SsB7TstuVa6fgWnN2GdPyilIFLUvvbTZoVRmx6eiRg==", + "dependencies": { + "@opentelemetry/semantic-conventions": "1.18.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.8.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/exporter-jaeger": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/exporter-jaeger/-/exporter-jaeger-1.17.1.tgz", + "integrity": "sha512-NW4qm04q4bSmhU6es1AXBWt3itJ2gkrXbKLfwDleC+ZMp3bVV47stByDqhuJzic2f47Im+C733N9RMeBkyqKMQ==", + "dependencies": { + "@opentelemetry/core": "1.17.1", + "@opentelemetry/sdk-trace-base": "1.17.1", + "@opentelemetry/semantic-conventions": "1.17.1", + "jaeger-client": "^3.15.0" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": "^1.0.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/exporter-jaeger/node_modules/@opentelemetry/core": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/core/-/core-1.17.1.tgz", + "integrity": "sha512-I6LrZvl1FF97FQXPR0iieWQmKnGxYtMbWA1GrAXnLUR+B1Hn2m8KqQNEIlZAucyv00GBgpWkpllmULmZfG8P3g==", + "dependencies": { + "@opentelemetry/semantic-conventions": "1.17.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.7.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/exporter-jaeger/node_modules/@opentelemetry/sdk-trace-base": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-trace-base/-/sdk-trace-base-1.17.1.tgz", + "integrity": "sha512-pfSJJSjZj5jkCJUQZicSpzN8Iz9UKMryPWikZRGObPnJo6cUSoKkjZh6BM3j+D47G4olMBN+YZKYqkFM1L6zNA==", + "dependencies": { + "@opentelemetry/core": "1.17.1", + "@opentelemetry/resources": "1.17.1", + "@opentelemetry/semantic-conventions": "1.17.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.7.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/exporter-jaeger/node_modules/@opentelemetry/sdk-trace-base/node_modules/@opentelemetry/resources": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/resources/-/resources-1.17.1.tgz", + "integrity": "sha512-M2e5emqg5I7qRKqlzKx0ROkcPyF8PbcSaWEdsm72od9txP7Z/Pl8PDYOyu80xWvbHAWk5mDxOF6v3vNdifzclA==", + "dependencies": { + "@opentelemetry/core": "1.17.1", + "@opentelemetry/semantic-conventions": "1.17.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.7.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/exporter-jaeger/node_modules/@opentelemetry/semantic-conventions": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/semantic-conventions/-/semantic-conventions-1.17.1.tgz", + "integrity": "sha512-xbR2U+2YjauIuo42qmE8XyJK6dYeRMLJuOlUP5SO4auET4VtOHOzgkRVOq+Ik18N+Xf3YPcqJs9dZMiDddz1eQ==", + "engines": { + "node": ">=14" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/exporter-metrics-otlp-grpc": { + "version": "0.44.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/exporter-metrics-otlp-grpc/-/exporter-metrics-otlp-grpc-0.44.0.tgz", + "integrity": "sha512-7A2Ed7mKsa2edRUS8Au5susMNGHeiO/LNxc/XC73g848aBF8Xo8xlNWnV78fa+EYJZLzEKDzts4vpKgtwyvo/Q==", + "dependencies": { + "@grpc/grpc-js": "^1.7.1", + "@opentelemetry/core": "1.17.1", + "@opentelemetry/exporter-metrics-otlp-http": "0.44.0", + "@opentelemetry/otlp-grpc-exporter-base": "0.44.0", + "@opentelemetry/otlp-transformer": "0.44.0", + "@opentelemetry/resources": "1.17.1", + "@opentelemetry/sdk-metrics": "1.17.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": "^1.3.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/exporter-metrics-otlp-grpc/node_modules/@opentelemetry/api-logs": { + "version": "0.44.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/api-logs/-/api-logs-0.44.0.tgz", + "integrity": "sha512-OctojdKGmXHKAJa4/Ml+Nf7MD9jtYXvZyP64xTh0pNTmtgaTdWW3FURri2DdB/+l7YxRy0tYYZS3/tYEM1pj3w==", + "dependencies": { + "@opentelemetry/api": "^1.0.0" + }, + "engines": { + "node": ">=14" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/exporter-metrics-otlp-grpc/node_modules/@opentelemetry/core": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/core/-/core-1.17.1.tgz", + "integrity": "sha512-I6LrZvl1FF97FQXPR0iieWQmKnGxYtMbWA1GrAXnLUR+B1Hn2m8KqQNEIlZAucyv00GBgpWkpllmULmZfG8P3g==", + "dependencies": { + "@opentelemetry/semantic-conventions": "1.17.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.7.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/exporter-metrics-otlp-grpc/node_modules/@opentelemetry/otlp-transformer": { + "version": "0.44.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/otlp-transformer/-/otlp-transformer-0.44.0.tgz", + "integrity": "sha512-1/KC+aHM1oGEsXyNy7QoxpvErxGdzt26bg9VHyNb4TDILkUFdwrnywnxPc6lXZ6h/8T8Mt718UWOKjNHC514kQ==", + "dependencies": { + "@opentelemetry/api-logs": "0.44.0", + "@opentelemetry/core": "1.17.1", + "@opentelemetry/resources": "1.17.1", + "@opentelemetry/sdk-logs": "0.44.0", + "@opentelemetry/sdk-metrics": "1.17.1", + "@opentelemetry/sdk-trace-base": "1.17.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.3.0 <1.7.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/exporter-metrics-otlp-grpc/node_modules/@opentelemetry/otlp-transformer/node_modules/@opentelemetry/sdk-logs": { + "version": "0.44.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-logs/-/sdk-logs-0.44.0.tgz", + "integrity": "sha512-UN3ofh9Jj54gIgrSXNRWAoaH6iPvrrjed5YAtqO9cW65U+5QPzk1Rv95vjAcY9VTrmMWvuqgEK1CYObG6Hu4OQ==", + "dependencies": { + "@opentelemetry/core": "1.17.1", + "@opentelemetry/resources": "1.17.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.4.0 <1.7.0", + "@opentelemetry/api-logs": ">=0.39.1" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/exporter-metrics-otlp-grpc/node_modules/@opentelemetry/otlp-transformer/node_modules/@opentelemetry/sdk-trace-base": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-trace-base/-/sdk-trace-base-1.17.1.tgz", + "integrity": "sha512-pfSJJSjZj5jkCJUQZicSpzN8Iz9UKMryPWikZRGObPnJo6cUSoKkjZh6BM3j+D47G4olMBN+YZKYqkFM1L6zNA==", + "dependencies": { + "@opentelemetry/core": "1.17.1", + "@opentelemetry/resources": "1.17.1", + "@opentelemetry/semantic-conventions": "1.17.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.7.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/exporter-metrics-otlp-grpc/node_modules/@opentelemetry/resources": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/resources/-/resources-1.17.1.tgz", + "integrity": "sha512-M2e5emqg5I7qRKqlzKx0ROkcPyF8PbcSaWEdsm72od9txP7Z/Pl8PDYOyu80xWvbHAWk5mDxOF6v3vNdifzclA==", + "dependencies": { + "@opentelemetry/core": "1.17.1", + "@opentelemetry/semantic-conventions": "1.17.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.7.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/exporter-metrics-otlp-grpc/node_modules/@opentelemetry/sdk-metrics": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-metrics/-/sdk-metrics-1.17.1.tgz", + "integrity": "sha512-eHdpsMCKhKhwznxvEfls8Wv3y4ZBWkkXlD3m7vtHIiWBqsMHspWSfie1s07mM45i/bBCf6YBMgz17FUxIXwmZA==", + "dependencies": { + "@opentelemetry/core": "1.17.1", + "@opentelemetry/resources": "1.17.1", + "lodash.merge": "^4.6.2" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.3.0 <1.7.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/exporter-metrics-otlp-grpc/node_modules/@opentelemetry/semantic-conventions": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/semantic-conventions/-/semantic-conventions-1.17.1.tgz", + "integrity": "sha512-xbR2U+2YjauIuo42qmE8XyJK6dYeRMLJuOlUP5SO4auET4VtOHOzgkRVOq+Ik18N+Xf3YPcqJs9dZMiDddz1eQ==", + "engines": { + "node": ">=14" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/exporter-metrics-otlp-http": { + "version": "0.44.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/exporter-metrics-otlp-http/-/exporter-metrics-otlp-http-0.44.0.tgz", + "integrity": "sha512-OiEkP9XWbh5ufjnP+xe8EQ2LShMY5f1NYBm9W/BgLaHPtlMNZnR7JB1t6Ut4gaZ7LA/yFnyrB0TnZcxntpBZ3Q==", + "dependencies": { + "@opentelemetry/core": "1.17.1", + "@opentelemetry/otlp-exporter-base": "0.44.0", + "@opentelemetry/otlp-transformer": "0.44.0", + "@opentelemetry/resources": "1.17.1", + "@opentelemetry/sdk-metrics": "1.17.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": "^1.3.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/exporter-metrics-otlp-http/node_modules/@opentelemetry/api-logs": { + "version": "0.44.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/api-logs/-/api-logs-0.44.0.tgz", + "integrity": "sha512-OctojdKGmXHKAJa4/Ml+Nf7MD9jtYXvZyP64xTh0pNTmtgaTdWW3FURri2DdB/+l7YxRy0tYYZS3/tYEM1pj3w==", + "dependencies": { + "@opentelemetry/api": "^1.0.0" + }, + "engines": { + "node": ">=14" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/exporter-metrics-otlp-http/node_modules/@opentelemetry/core": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/core/-/core-1.17.1.tgz", + "integrity": "sha512-I6LrZvl1FF97FQXPR0iieWQmKnGxYtMbWA1GrAXnLUR+B1Hn2m8KqQNEIlZAucyv00GBgpWkpllmULmZfG8P3g==", + "dependencies": { + "@opentelemetry/semantic-conventions": "1.17.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.7.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/exporter-metrics-otlp-http/node_modules/@opentelemetry/otlp-transformer": { + "version": "0.44.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/otlp-transformer/-/otlp-transformer-0.44.0.tgz", + "integrity": "sha512-1/KC+aHM1oGEsXyNy7QoxpvErxGdzt26bg9VHyNb4TDILkUFdwrnywnxPc6lXZ6h/8T8Mt718UWOKjNHC514kQ==", + "dependencies": { + "@opentelemetry/api-logs": "0.44.0", + "@opentelemetry/core": "1.17.1", + "@opentelemetry/resources": "1.17.1", + "@opentelemetry/sdk-logs": "0.44.0", + "@opentelemetry/sdk-metrics": "1.17.1", + "@opentelemetry/sdk-trace-base": "1.17.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.3.0 <1.7.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/exporter-metrics-otlp-http/node_modules/@opentelemetry/otlp-transformer/node_modules/@opentelemetry/sdk-logs": { + "version": "0.44.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-logs/-/sdk-logs-0.44.0.tgz", + "integrity": "sha512-UN3ofh9Jj54gIgrSXNRWAoaH6iPvrrjed5YAtqO9cW65U+5QPzk1Rv95vjAcY9VTrmMWvuqgEK1CYObG6Hu4OQ==", + "dependencies": { + "@opentelemetry/core": "1.17.1", + "@opentelemetry/resources": "1.17.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.4.0 <1.7.0", + "@opentelemetry/api-logs": ">=0.39.1" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/exporter-metrics-otlp-http/node_modules/@opentelemetry/otlp-transformer/node_modules/@opentelemetry/sdk-trace-base": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-trace-base/-/sdk-trace-base-1.17.1.tgz", + "integrity": "sha512-pfSJJSjZj5jkCJUQZicSpzN8Iz9UKMryPWikZRGObPnJo6cUSoKkjZh6BM3j+D47G4olMBN+YZKYqkFM1L6zNA==", + "dependencies": { + "@opentelemetry/core": "1.17.1", + "@opentelemetry/resources": "1.17.1", + "@opentelemetry/semantic-conventions": "1.17.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.7.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/exporter-metrics-otlp-http/node_modules/@opentelemetry/resources": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/resources/-/resources-1.17.1.tgz", + "integrity": "sha512-M2e5emqg5I7qRKqlzKx0ROkcPyF8PbcSaWEdsm72od9txP7Z/Pl8PDYOyu80xWvbHAWk5mDxOF6v3vNdifzclA==", + "dependencies": { + "@opentelemetry/core": "1.17.1", + "@opentelemetry/semantic-conventions": "1.17.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.7.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/exporter-metrics-otlp-http/node_modules/@opentelemetry/sdk-metrics": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-metrics/-/sdk-metrics-1.17.1.tgz", + "integrity": "sha512-eHdpsMCKhKhwznxvEfls8Wv3y4ZBWkkXlD3m7vtHIiWBqsMHspWSfie1s07mM45i/bBCf6YBMgz17FUxIXwmZA==", + "dependencies": { + "@opentelemetry/core": "1.17.1", + "@opentelemetry/resources": "1.17.1", + "lodash.merge": "^4.6.2" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.3.0 <1.7.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/exporter-metrics-otlp-http/node_modules/@opentelemetry/semantic-conventions": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/semantic-conventions/-/semantic-conventions-1.17.1.tgz", + "integrity": "sha512-xbR2U+2YjauIuo42qmE8XyJK6dYeRMLJuOlUP5SO4auET4VtOHOzgkRVOq+Ik18N+Xf3YPcqJs9dZMiDddz1eQ==", + "engines": { + "node": ">=14" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/exporter-metrics-otlp-proto": { + "version": "0.44.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/exporter-metrics-otlp-proto/-/exporter-metrics-otlp-proto-0.44.0.tgz", + "integrity": "sha512-GnxFAtb42OkE8sHmty5Ex5rEOfS+psAhCUq/Jod+7ZKMwUrxGvUWAa3nS9CkihhL2lj4rBU7o8SV8TO0Nn85/A==", + "dependencies": { + "@opentelemetry/core": "1.17.1", + "@opentelemetry/exporter-metrics-otlp-http": "0.44.0", + "@opentelemetry/otlp-exporter-base": "0.44.0", + "@opentelemetry/otlp-proto-exporter-base": "0.44.0", + "@opentelemetry/otlp-transformer": "0.44.0", + "@opentelemetry/resources": "1.17.1", + "@opentelemetry/sdk-metrics": "1.17.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": "^1.3.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/exporter-metrics-otlp-proto/node_modules/@opentelemetry/api-logs": { + "version": "0.44.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/api-logs/-/api-logs-0.44.0.tgz", + "integrity": "sha512-OctojdKGmXHKAJa4/Ml+Nf7MD9jtYXvZyP64xTh0pNTmtgaTdWW3FURri2DdB/+l7YxRy0tYYZS3/tYEM1pj3w==", + "dependencies": { + "@opentelemetry/api": "^1.0.0" + }, + "engines": { + "node": ">=14" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/exporter-metrics-otlp-proto/node_modules/@opentelemetry/core": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/core/-/core-1.17.1.tgz", + "integrity": "sha512-I6LrZvl1FF97FQXPR0iieWQmKnGxYtMbWA1GrAXnLUR+B1Hn2m8KqQNEIlZAucyv00GBgpWkpllmULmZfG8P3g==", + "dependencies": { + "@opentelemetry/semantic-conventions": "1.17.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.7.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/exporter-metrics-otlp-proto/node_modules/@opentelemetry/otlp-transformer": { + "version": "0.44.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/otlp-transformer/-/otlp-transformer-0.44.0.tgz", + "integrity": "sha512-1/KC+aHM1oGEsXyNy7QoxpvErxGdzt26bg9VHyNb4TDILkUFdwrnywnxPc6lXZ6h/8T8Mt718UWOKjNHC514kQ==", + "dependencies": { + "@opentelemetry/api-logs": "0.44.0", + "@opentelemetry/core": "1.17.1", + "@opentelemetry/resources": "1.17.1", + "@opentelemetry/sdk-logs": "0.44.0", + "@opentelemetry/sdk-metrics": "1.17.1", + "@opentelemetry/sdk-trace-base": "1.17.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.3.0 <1.7.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/exporter-metrics-otlp-proto/node_modules/@opentelemetry/otlp-transformer/node_modules/@opentelemetry/sdk-logs": { + "version": "0.44.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-logs/-/sdk-logs-0.44.0.tgz", + "integrity": "sha512-UN3ofh9Jj54gIgrSXNRWAoaH6iPvrrjed5YAtqO9cW65U+5QPzk1Rv95vjAcY9VTrmMWvuqgEK1CYObG6Hu4OQ==", + "dependencies": { + "@opentelemetry/core": "1.17.1", + "@opentelemetry/resources": "1.17.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.4.0 <1.7.0", + "@opentelemetry/api-logs": ">=0.39.1" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/exporter-metrics-otlp-proto/node_modules/@opentelemetry/otlp-transformer/node_modules/@opentelemetry/sdk-trace-base": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-trace-base/-/sdk-trace-base-1.17.1.tgz", + "integrity": "sha512-pfSJJSjZj5jkCJUQZicSpzN8Iz9UKMryPWikZRGObPnJo6cUSoKkjZh6BM3j+D47G4olMBN+YZKYqkFM1L6zNA==", + "dependencies": { + "@opentelemetry/core": "1.17.1", + "@opentelemetry/resources": "1.17.1", + "@opentelemetry/semantic-conventions": "1.17.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.7.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/exporter-metrics-otlp-proto/node_modules/@opentelemetry/resources": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/resources/-/resources-1.17.1.tgz", + "integrity": "sha512-M2e5emqg5I7qRKqlzKx0ROkcPyF8PbcSaWEdsm72od9txP7Z/Pl8PDYOyu80xWvbHAWk5mDxOF6v3vNdifzclA==", + "dependencies": { + "@opentelemetry/core": "1.17.1", + "@opentelemetry/semantic-conventions": "1.17.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.7.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/exporter-metrics-otlp-proto/node_modules/@opentelemetry/sdk-metrics": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-metrics/-/sdk-metrics-1.17.1.tgz", + "integrity": "sha512-eHdpsMCKhKhwznxvEfls8Wv3y4ZBWkkXlD3m7vtHIiWBqsMHspWSfie1s07mM45i/bBCf6YBMgz17FUxIXwmZA==", + "dependencies": { + "@opentelemetry/core": "1.17.1", + "@opentelemetry/resources": "1.17.1", + "lodash.merge": "^4.6.2" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.3.0 <1.7.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/exporter-metrics-otlp-proto/node_modules/@opentelemetry/semantic-conventions": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/semantic-conventions/-/semantic-conventions-1.17.1.tgz", + "integrity": "sha512-xbR2U+2YjauIuo42qmE8XyJK6dYeRMLJuOlUP5SO4auET4VtOHOzgkRVOq+Ik18N+Xf3YPcqJs9dZMiDddz1eQ==", + "engines": { + "node": ">=14" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/exporter-trace-otlp-grpc": { + "version": "0.44.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/exporter-trace-otlp-grpc/-/exporter-trace-otlp-grpc-0.44.0.tgz", + "integrity": "sha512-S1kT/9tVlgZDRYyVfCLYyWZoQTplPD9WcyX+qUPbhJTETORxzJVW9HN8mHwQsXaN7ngqwRLy5GW/nXHL8aqA0w==", + "dependencies": { + "@grpc/grpc-js": "^1.7.1", + "@opentelemetry/core": "1.17.1", + "@opentelemetry/otlp-grpc-exporter-base": "0.44.0", + "@opentelemetry/otlp-transformer": "0.44.0", + "@opentelemetry/resources": "1.17.1", + "@opentelemetry/sdk-trace-base": "1.17.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": "^1.0.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/exporter-trace-otlp-grpc/node_modules/@opentelemetry/api-logs": { + "version": "0.44.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/api-logs/-/api-logs-0.44.0.tgz", + "integrity": "sha512-OctojdKGmXHKAJa4/Ml+Nf7MD9jtYXvZyP64xTh0pNTmtgaTdWW3FURri2DdB/+l7YxRy0tYYZS3/tYEM1pj3w==", + "dependencies": { + "@opentelemetry/api": "^1.0.0" + }, + "engines": { + "node": ">=14" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/exporter-trace-otlp-grpc/node_modules/@opentelemetry/core": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/core/-/core-1.17.1.tgz", + "integrity": "sha512-I6LrZvl1FF97FQXPR0iieWQmKnGxYtMbWA1GrAXnLUR+B1Hn2m8KqQNEIlZAucyv00GBgpWkpllmULmZfG8P3g==", + "dependencies": { + "@opentelemetry/semantic-conventions": "1.17.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.7.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/exporter-trace-otlp-grpc/node_modules/@opentelemetry/otlp-transformer": { + "version": "0.44.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/otlp-transformer/-/otlp-transformer-0.44.0.tgz", + "integrity": "sha512-1/KC+aHM1oGEsXyNy7QoxpvErxGdzt26bg9VHyNb4TDILkUFdwrnywnxPc6lXZ6h/8T8Mt718UWOKjNHC514kQ==", + "dependencies": { + "@opentelemetry/api-logs": "0.44.0", + "@opentelemetry/core": "1.17.1", + "@opentelemetry/resources": "1.17.1", + "@opentelemetry/sdk-logs": "0.44.0", + "@opentelemetry/sdk-metrics": "1.17.1", + "@opentelemetry/sdk-trace-base": "1.17.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.3.0 <1.7.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/exporter-trace-otlp-grpc/node_modules/@opentelemetry/otlp-transformer/node_modules/@opentelemetry/sdk-logs": { + "version": "0.44.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-logs/-/sdk-logs-0.44.0.tgz", + "integrity": "sha512-UN3ofh9Jj54gIgrSXNRWAoaH6iPvrrjed5YAtqO9cW65U+5QPzk1Rv95vjAcY9VTrmMWvuqgEK1CYObG6Hu4OQ==", + "dependencies": { + "@opentelemetry/core": "1.17.1", + "@opentelemetry/resources": "1.17.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.4.0 <1.7.0", + "@opentelemetry/api-logs": ">=0.39.1" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/exporter-trace-otlp-grpc/node_modules/@opentelemetry/otlp-transformer/node_modules/@opentelemetry/sdk-metrics": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-metrics/-/sdk-metrics-1.17.1.tgz", + "integrity": "sha512-eHdpsMCKhKhwznxvEfls8Wv3y4ZBWkkXlD3m7vtHIiWBqsMHspWSfie1s07mM45i/bBCf6YBMgz17FUxIXwmZA==", + "dependencies": { + "@opentelemetry/core": "1.17.1", + "@opentelemetry/resources": "1.17.1", + "lodash.merge": "^4.6.2" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.3.0 <1.7.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/exporter-trace-otlp-grpc/node_modules/@opentelemetry/resources": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/resources/-/resources-1.17.1.tgz", + "integrity": "sha512-M2e5emqg5I7qRKqlzKx0ROkcPyF8PbcSaWEdsm72od9txP7Z/Pl8PDYOyu80xWvbHAWk5mDxOF6v3vNdifzclA==", + "dependencies": { + "@opentelemetry/core": "1.17.1", + "@opentelemetry/semantic-conventions": "1.17.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.7.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/exporter-trace-otlp-grpc/node_modules/@opentelemetry/sdk-trace-base": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-trace-base/-/sdk-trace-base-1.17.1.tgz", + "integrity": "sha512-pfSJJSjZj5jkCJUQZicSpzN8Iz9UKMryPWikZRGObPnJo6cUSoKkjZh6BM3j+D47G4olMBN+YZKYqkFM1L6zNA==", + "dependencies": { + "@opentelemetry/core": "1.17.1", + "@opentelemetry/resources": "1.17.1", + "@opentelemetry/semantic-conventions": "1.17.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.7.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/exporter-trace-otlp-grpc/node_modules/@opentelemetry/semantic-conventions": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/semantic-conventions/-/semantic-conventions-1.17.1.tgz", + "integrity": "sha512-xbR2U+2YjauIuo42qmE8XyJK6dYeRMLJuOlUP5SO4auET4VtOHOzgkRVOq+Ik18N+Xf3YPcqJs9dZMiDddz1eQ==", + "engines": { + "node": ">=14" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/exporter-trace-otlp-proto": { + "version": "0.44.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/exporter-trace-otlp-proto/-/exporter-trace-otlp-proto-0.44.0.tgz", + "integrity": "sha512-yVW0FXxiLaQOyE3MGr6BtK7ml0DaJH4Qx3yvQYUd/hsJUSZBhYYw2TRaMsaW7XMpe1AvU81qt0l8uLYmcmcLJA==", + "dependencies": { + "@opentelemetry/core": "1.17.1", + "@opentelemetry/otlp-exporter-base": "0.44.0", + "@opentelemetry/otlp-proto-exporter-base": "0.44.0", + "@opentelemetry/otlp-transformer": "0.44.0", + "@opentelemetry/resources": "1.17.1", + "@opentelemetry/sdk-trace-base": "1.17.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": "^1.0.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/exporter-trace-otlp-proto/node_modules/@opentelemetry/api-logs": { + "version": "0.44.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/api-logs/-/api-logs-0.44.0.tgz", + "integrity": "sha512-OctojdKGmXHKAJa4/Ml+Nf7MD9jtYXvZyP64xTh0pNTmtgaTdWW3FURri2DdB/+l7YxRy0tYYZS3/tYEM1pj3w==", + "dependencies": { + "@opentelemetry/api": "^1.0.0" + }, + "engines": { + "node": ">=14" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/exporter-trace-otlp-proto/node_modules/@opentelemetry/core": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/core/-/core-1.17.1.tgz", + "integrity": "sha512-I6LrZvl1FF97FQXPR0iieWQmKnGxYtMbWA1GrAXnLUR+B1Hn2m8KqQNEIlZAucyv00GBgpWkpllmULmZfG8P3g==", + "dependencies": { + "@opentelemetry/semantic-conventions": "1.17.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.7.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/exporter-trace-otlp-proto/node_modules/@opentelemetry/otlp-transformer": { + "version": "0.44.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/otlp-transformer/-/otlp-transformer-0.44.0.tgz", + "integrity": "sha512-1/KC+aHM1oGEsXyNy7QoxpvErxGdzt26bg9VHyNb4TDILkUFdwrnywnxPc6lXZ6h/8T8Mt718UWOKjNHC514kQ==", + "dependencies": { + "@opentelemetry/api-logs": "0.44.0", + "@opentelemetry/core": "1.17.1", + "@opentelemetry/resources": "1.17.1", + "@opentelemetry/sdk-logs": "0.44.0", + "@opentelemetry/sdk-metrics": "1.17.1", + "@opentelemetry/sdk-trace-base": "1.17.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.3.0 <1.7.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/exporter-trace-otlp-proto/node_modules/@opentelemetry/otlp-transformer/node_modules/@opentelemetry/sdk-logs": { + "version": "0.44.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-logs/-/sdk-logs-0.44.0.tgz", + "integrity": "sha512-UN3ofh9Jj54gIgrSXNRWAoaH6iPvrrjed5YAtqO9cW65U+5QPzk1Rv95vjAcY9VTrmMWvuqgEK1CYObG6Hu4OQ==", + "dependencies": { + "@opentelemetry/core": "1.17.1", + "@opentelemetry/resources": "1.17.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.4.0 <1.7.0", + "@opentelemetry/api-logs": ">=0.39.1" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/exporter-trace-otlp-proto/node_modules/@opentelemetry/otlp-transformer/node_modules/@opentelemetry/sdk-metrics": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-metrics/-/sdk-metrics-1.17.1.tgz", + "integrity": "sha512-eHdpsMCKhKhwznxvEfls8Wv3y4ZBWkkXlD3m7vtHIiWBqsMHspWSfie1s07mM45i/bBCf6YBMgz17FUxIXwmZA==", + "dependencies": { + "@opentelemetry/core": "1.17.1", + "@opentelemetry/resources": "1.17.1", + "lodash.merge": "^4.6.2" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.3.0 <1.7.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/exporter-trace-otlp-proto/node_modules/@opentelemetry/resources": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/resources/-/resources-1.17.1.tgz", + "integrity": "sha512-M2e5emqg5I7qRKqlzKx0ROkcPyF8PbcSaWEdsm72od9txP7Z/Pl8PDYOyu80xWvbHAWk5mDxOF6v3vNdifzclA==", + "dependencies": { + "@opentelemetry/core": "1.17.1", + "@opentelemetry/semantic-conventions": "1.17.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.7.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/exporter-trace-otlp-proto/node_modules/@opentelemetry/sdk-trace-base": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-trace-base/-/sdk-trace-base-1.17.1.tgz", + "integrity": "sha512-pfSJJSjZj5jkCJUQZicSpzN8Iz9UKMryPWikZRGObPnJo6cUSoKkjZh6BM3j+D47G4olMBN+YZKYqkFM1L6zNA==", + "dependencies": { + "@opentelemetry/core": "1.17.1", + "@opentelemetry/resources": "1.17.1", + "@opentelemetry/semantic-conventions": "1.17.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.7.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/exporter-trace-otlp-proto/node_modules/@opentelemetry/semantic-conventions": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/semantic-conventions/-/semantic-conventions-1.17.1.tgz", + "integrity": "sha512-xbR2U+2YjauIuo42qmE8XyJK6dYeRMLJuOlUP5SO4auET4VtOHOzgkRVOq+Ik18N+Xf3YPcqJs9dZMiDddz1eQ==", + "engines": { + "node": ">=14" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/otlp-exporter-base": { + "version": "0.44.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/otlp-exporter-base/-/otlp-exporter-base-0.44.0.tgz", + "integrity": "sha512-DKQqRrfVMe96aSLZiCgIesLcMLfnWH8d4bTpLB1JbU+SAQJ7nVCAfS9U36mjFCVhvNDD7gwfCNrxqFMCHq6FUw==", + "dependencies": { + "@opentelemetry/core": "1.17.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": "^1.0.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/otlp-exporter-base/node_modules/@opentelemetry/core": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/core/-/core-1.17.1.tgz", + "integrity": "sha512-I6LrZvl1FF97FQXPR0iieWQmKnGxYtMbWA1GrAXnLUR+B1Hn2m8KqQNEIlZAucyv00GBgpWkpllmULmZfG8P3g==", + "dependencies": { + "@opentelemetry/semantic-conventions": "1.17.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.7.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/otlp-exporter-base/node_modules/@opentelemetry/semantic-conventions": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/semantic-conventions/-/semantic-conventions-1.17.1.tgz", + "integrity": "sha512-xbR2U+2YjauIuo42qmE8XyJK6dYeRMLJuOlUP5SO4auET4VtOHOzgkRVOq+Ik18N+Xf3YPcqJs9dZMiDddz1eQ==", + "engines": { + "node": ">=14" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/otlp-grpc-exporter-base": { + "version": "0.44.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/otlp-grpc-exporter-base/-/otlp-grpc-exporter-base-0.44.0.tgz", + "integrity": "sha512-RsYW2+ikNDDXM9rY4gCA3lJOu53o4CzCsUJ9DV6r78k/Y0ckWw2GM7R4I6yOmMe4jilxEaHorI3oTJFLD8KYug==", + "dependencies": { + "@grpc/grpc-js": "^1.7.1", + "@opentelemetry/core": "1.17.1", + "@opentelemetry/otlp-exporter-base": "0.44.0", + "protobufjs": "^7.2.3" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": "^1.0.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/otlp-grpc-exporter-base/node_modules/@opentelemetry/core": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/core/-/core-1.17.1.tgz", + "integrity": "sha512-I6LrZvl1FF97FQXPR0iieWQmKnGxYtMbWA1GrAXnLUR+B1Hn2m8KqQNEIlZAucyv00GBgpWkpllmULmZfG8P3g==", + "dependencies": { + "@opentelemetry/semantic-conventions": "1.17.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.7.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/otlp-grpc-exporter-base/node_modules/@opentelemetry/semantic-conventions": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/semantic-conventions/-/semantic-conventions-1.17.1.tgz", + "integrity": "sha512-xbR2U+2YjauIuo42qmE8XyJK6dYeRMLJuOlUP5SO4auET4VtOHOzgkRVOq+Ik18N+Xf3YPcqJs9dZMiDddz1eQ==", + "engines": { + "node": ">=14" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/otlp-proto-exporter-base": { + "version": "0.44.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/otlp-proto-exporter-base/-/otlp-proto-exporter-base-0.44.0.tgz", + "integrity": "sha512-vgQvWEkXNk8X4BW93+j054TZBVs1ryguXQjeoLeHV/dzopdGuAypI0xC5OtSr+eRftuyPqPl2DVp4tjRq4z4dw==", + "dependencies": { + "@opentelemetry/core": "1.17.1", + "@opentelemetry/otlp-exporter-base": "0.44.0", + "protobufjs": "^7.2.3" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": "^1.0.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/otlp-proto-exporter-base/node_modules/@opentelemetry/core": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/core/-/core-1.17.1.tgz", + "integrity": "sha512-I6LrZvl1FF97FQXPR0iieWQmKnGxYtMbWA1GrAXnLUR+B1Hn2m8KqQNEIlZAucyv00GBgpWkpllmULmZfG8P3g==", + "dependencies": { + "@opentelemetry/semantic-conventions": "1.17.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.7.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/otlp-proto-exporter-base/node_modules/@opentelemetry/semantic-conventions": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/semantic-conventions/-/semantic-conventions-1.17.1.tgz", + "integrity": "sha512-xbR2U+2YjauIuo42qmE8XyJK6dYeRMLJuOlUP5SO4auET4VtOHOzgkRVOq+Ik18N+Xf3YPcqJs9dZMiDddz1eQ==", + "engines": { + "node": ">=14" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/resources": { + "version": "1.18.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/resources/-/resources-1.18.1.tgz", + "integrity": "sha512-JjbcQLYMttXcIabflLRuaw5oof5gToYV9fuXbcsoOeQ0BlbwUn6DAZi++PNsSz2jjPeASfDls10iaO/8BRIPRA==", + "dependencies": { + "@opentelemetry/core": "1.18.1", + "@opentelemetry/semantic-conventions": "1.18.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.8.0" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/@opentelemetry/semantic-conventions": { + "version": "1.18.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/semantic-conventions/-/semantic-conventions-1.18.1.tgz", + "integrity": "sha512-+NLGHr6VZwcgE/2lw8zDIufOCGnzsA5CbQIMleXZTrgkBd0TanCX+MiDYJ1TOS4KL/Tqk0nFRxawnaYr6pkZkA==", + "engines": { + "node": ">=14" + } + }, + "packages/opentelemetry-sdk-setup/node_modules/yargs-parser": { + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", + "engines": { + "node": ">=12" + } + }, "packages/redirect-parser": { "name": "netlify-redirect-parser", "version": "14.2.0", diff --git a/packages/opentelemetry-sdk-setup/README.md b/packages/opentelemetry-sdk-setup/README.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/opentelemetry-sdk-setup/package.json b/packages/opentelemetry-sdk-setup/package.json new file mode 100644 index 0000000000..8c531f07bc --- /dev/null +++ b/packages/opentelemetry-sdk-setup/package.json @@ -0,0 +1,52 @@ +{ + "name": "@netlify/opentelemetry-sdk-setup", + "version": "1.0.0", + "description": "Opentelemetry SDK setup script", + "type": "module", + "bin": { + "otel-sdk-setup": "./lib/bin.js" + }, + "files": [ + "bin.js", + "lib/**/*" + ], + "scripts": { + "build": "tsc", + "build:logos": "vite build", + "test": "vitest run", + "test:dev": "vitest --ui", + "test:ci": "vitest run --reporter=default" + }, + "keywords": [], + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/netlify/build.git", + "directory": "packages/opentelemetry-sdk-setup" + }, + "bugs": { + "url": "https://github.com/netlify/build/issues" + }, + "author": "Netlify Inc.", + "dependencies": { + "@honeycombio/opentelemetry-node": "^0.6.0", + "@opentelemetry/api": "~1.6.0", + "@opentelemetry/core": "^1.17.1", + "@opentelemetry/resources": "^1.18.1", + "@opentelemetry/semantic-conventions": "^1.18.1", + "yargs-parser": "^21.1.1" + }, + "devDependencies": { + "@types/node": "^14.18.53", + "@types/semver": "^7.3.13", + "@vitest/coverage-c8": "^0.30.1", + "@vitest/ui": "^0.30.1", + "typescript": "^5.0.0", + "unionfs": "^4.4.0", + "vite": "^4.0.4", + "vitest": "^0.30.1" + }, + "engines": { + "node": ">=18.0.0" + } +} diff --git a/packages/opentelemetry-sdk-setup/src/bin.ts b/packages/opentelemetry-sdk-setup/src/bin.ts new file mode 100644 index 0000000000..25899e5a1d --- /dev/null +++ b/packages/opentelemetry-sdk-setup/src/bin.ts @@ -0,0 +1,42 @@ +import process from 'node:process' + +import argsParser from 'yargs-parser' + +import { startTracing, TracingOptions } from './sdk-setup.js' +import { findExecutablePackageJSON } from './util.js' + +const DEFAULT_OTEL_TRACING_PORT = 4317 +const DEFAULT_OTEL_ENDPOINT_PROTOCOL = 'http' + +const defaultOptions: TracingOptions = { + preloadingEnabled: false, + httpProtocol: DEFAULT_OTEL_ENDPOINT_PROTOCOL, + host: 'locahost', + port: DEFAULT_OTEL_TRACING_PORT, + sampleRate: 1, + baggageFilePath: '', + apiKey: '-', + parentSpanId: '', + traceId: '', + traceFlags: 0, + debug: false, +} + +const args = argsParser(process.argv) as unknown as { + /** _ holds args0 and args1 respectively, args1 will include the executable we're trying to run */ + _: [string, string] + tracing: TracingOptions +} + +const options = { + ...args.tracing, + ...defaultOptions, + debug: args.tracing.debug === undefined ? defaultOptions.debug : args.tracing.debug, + preloadingEnabled: + args.tracing.preloadingEnabled === undefined ? defaultOptions.preloadingEnabled : args.tracing.preloadingEnabled, +} +const executablePath = args._[1] + +findExecutablePackageJSON(executablePath).then((pkg) => startTracing(options, pkg)) + +//TODO handle `stopTracing` via `process` event emitter diff --git a/packages/opentelemetry-sdk-setup/src/sdk-setup.ts b/packages/opentelemetry-sdk-setup/src/sdk-setup.ts new file mode 100644 index 0000000000..8cc0baa49b --- /dev/null +++ b/packages/opentelemetry-sdk-setup/src/sdk-setup.ts @@ -0,0 +1,86 @@ +import { HoneycombSDK } from '@honeycombio/opentelemetry-node' +import { diag, DiagLogLevel } from '@opentelemetry/api' +import { Resource } from '@opentelemetry/resources' +import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions' +import type { PackageJson } from 'read-pkg-up' + +import { getOtelLogger } from './util.js' + +export type TracingOptions = { + /** This is a temporary property to signal preloading is enabled, can be replaced with `enabled` once we retire build's internal sdk setup */ + preloadingEnabled: boolean + httpProtocol: string + host: string + port: number + /** API Key used for a dedicated trace provider */ + apiKey: string + /** Sample rate being used for this trace, this allows for consistent probability sampling */ + sampleRate: number + /** Properties of the root span and trace id used to stitch context */ + traceId: string + traceFlags: number + parentSpanId: string + baggageFilePath: string + /** Debug mode enabled - logs to stdout */ + debug: boolean + /** System log file descriptor */ + systemLogFile?: number +} + +let sdk: HoneycombSDK | undefined + +/** Starts the tracing SDK, if there's already a tracing service this will be a no-op */ +export const startTracing = async function (options: TracingOptions, packageJson: PackageJson) { + if (!options.preloadingEnabled) return + if (sdk) return + + sdk = new HoneycombSDK({ + resource: new Resource({ + [SemanticResourceAttributes.SERVICE_VERSION]: packageJson.version, + }), + serviceName: packageJson.name, + protocol: 'grpc', + apiKey: options.apiKey, + endpoint: `${options.httpProtocol}://${options.host}:${options.port}`, + sampleRate: options.sampleRate, + // Turn off auto resource detection so that we fully control the attributes we export + autoDetectResources: false, + }) + + // Set the diagnostics logger to our system logger. We also need to suppress the override msg + // in case there's a default console logger already registered (it would log a msg to it) + diag.setLogger(getOtelLogger(options.debug, options.systemLogFile), { + logLevel: options.debug ? DiagLogLevel.DEBUG : DiagLogLevel.INFO, + suppressOverrideMessage: true, + }) + + sdk.start() + + // Loads the contents of the passed baggageFilePath into the baggage + // const baggageCtx = await loadBaggageFromFile(options.baggageFilePath) + + // Sets the current trace ID and span ID based on the options received + // this is used as a way to propagate trace context from Buildbot + // const ctx = trace.setSpanContext(baggageCtx, { + // traceId: options.traceId, + // spanId: options.parentSpanId, + // traceFlags: options.traceFlags, + // isRemote: true, + // }) + + // global['NETLIFY_ROOT_CONTEXT'] = ctx + // return ctx +} + +/** Stops the tracing service if there's one running. This will flush any ongoing events */ +export const stopTracing = async function () { + if (!sdk) return + try { + // The shutdown method might return an error if we fail to flush the traces + // We handle it and use our diagnostics logger + await sdk.shutdown() + sdk = undefined + } catch (e) { + diag.error(e) + } +} diff --git a/packages/opentelemetry-sdk-setup/src/util.ts b/packages/opentelemetry-sdk-setup/src/util.ts new file mode 100644 index 0000000000..c073686a03 --- /dev/null +++ b/packages/opentelemetry-sdk-setup/src/util.ts @@ -0,0 +1,102 @@ +import { createWriteStream } from 'node:fs' +import { realpath, readFile } from 'node:fs/promises' + +import { context, diag, DiagLogger } from '@opentelemetry/api' +import { parseKeyPairsIntoRecord } from '@opentelemetry/core/build/src/baggage/utils.js' +import { readPackageUp, PackageJson } from 'read-pkg-up' + +/** + * Builds a function for logging data to a provided fileDescriptor (i.e. hidden from + * the user-facing build logs) + */ +const getSystemLogger = function ( + debug: boolean, + /** A system log file descriptor, if non is provided it will be a noop logger */ + systemLogFile?: number, +): (...args: any[]) => void { + // If the `debug` flag is used, we return a function that pipes system logs + // to the regular logger, as the intention is for them to end up in stdout. + // For now we just use plain `console.log`, later on we can revise it + if (debug) { + return (...args) => console.log(...args) + } + + // If there's not a file descriptor configured for system logs and `debug` + // is not set, we return a no-op function that will swallow the errors. + if (!systemLogFile) { + return () => { + // no-op + } + } + + // Return a function that writes to the file descriptor configured for system + // logs. + const fileDescriptor = createWriteStream('', { fd: systemLogFile }) + + fileDescriptor.on('error', () => { + console.error('Could not write to system log file') + }) + + return (...args) => fileDescriptor.write(`${console.log(...args)}\n`) +} + +/** Given a simple logging function return a `DiagLogger`. Used to setup our system logger as the diag logger.*/ +export const getOtelLogger = function ( + debug: boolean, + /** A system log file descriptor, if non is provided it will be a noop logger */ + systemLogFile?: number, +): DiagLogger { + const logger = getSystemLogger(debug, systemLogFile) + const otelLogger = (...args: any[]) => { + // Debug log msgs can be an array of 1 or 2 elements with the second element being an array fo multiple elements + const msgs = args.flat(1) + logger('[otel-traces]', ...msgs) + } + return { + debug: otelLogger, + info: otelLogger, + error: otelLogger, + verbose: otelLogger, + warn: otelLogger, + } +} + +//** Loads the baggage attributes from a baggabe file which follows W3C Baggage specification */ +export const loadBaggageFromFile = async function (baggageFilePath: string) { + if (baggageFilePath.length === 0) { + diag.warn('Empty baggage file path provided, no context loaded') + return context.active() + } + let baggageString: string + try { + baggageString = await readFile(baggageFilePath, 'utf-8') + } catch (error) { + diag.error(error) + return context.active() + } + return parseKeyPairsIntoRecord(baggageString) +} + +/** + * Given a path to a node executable (potentially a symlink) get the module packageJson + */ +export const findExecutablePackageJSON = async function (path: string): Promise { + let pathToSearch: string + try { + // resolve symlinks + pathToSearch = await realpath(path) + } catch { + // bail early if we can't resolve the path + return {} + } + + try { + const result = await readPackageUp({ cwd: pathToSearch, normalize: false }) + if (result === undefined) return {} + const { packageJson } = result + return packageJson + } catch { + // packageJson read failed, we ignore the error and return an empty obj + return {} + } +} diff --git a/packages/opentelemetry-sdk-setup/tsconfig.json b/packages/opentelemetry-sdk-setup/tsconfig.json new file mode 100644 index 0000000000..b7bb214dee --- /dev/null +++ b/packages/opentelemetry-sdk-setup/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "target": "es2022", + "outDir": "lib" /* Specify an output folder for all emitted files. */ + }, + "include": ["src/**/*.ts"] +} diff --git a/packages/opentelemetry-sdk-setup/vitest.config.ts b/packages/opentelemetry-sdk-setup/vitest.config.ts new file mode 100644 index 0000000000..84ae76ce4d --- /dev/null +++ b/packages/opentelemetry-sdk-setup/vitest.config.ts @@ -0,0 +1,11 @@ +import { defineConfig } from 'vitest/config' + +export default defineConfig({ + test: { + restoreMocks: true, + environment: 'node', + onConsoleLog: (log, type) => { + process[type].write(log) + }, + }, +}) From b09002d0131a55b904d13969266c77414c6ff67f Mon Sep 17 00:00:00 2001 From: JGAntunes Date: Tue, 14 Nov 2023 20:07:30 +0000 Subject: [PATCH 02/16] chore: move part of the tests --- .../opentelemetry-sdk-setup/src/sdk-setup.ts | 27 +++--- .../tests/main.test.ts | 87 +++++++++++++++++++ 2 files changed, 100 insertions(+), 14 deletions(-) create mode 100644 packages/opentelemetry-sdk-setup/tests/main.test.ts diff --git a/packages/opentelemetry-sdk-setup/src/sdk-setup.ts b/packages/opentelemetry-sdk-setup/src/sdk-setup.ts index 8cc0baa49b..dfcdc56f25 100644 --- a/packages/opentelemetry-sdk-setup/src/sdk-setup.ts +++ b/packages/opentelemetry-sdk-setup/src/sdk-setup.ts @@ -1,5 +1,5 @@ import { HoneycombSDK } from '@honeycombio/opentelemetry-node' -import { diag, DiagLogLevel } from '@opentelemetry/api' +import { trace, diag, context, DiagLogLevel } from '@opentelemetry/api' import { Resource } from '@opentelemetry/resources' import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions' import type { PackageJson } from 'read-pkg-up' @@ -17,12 +17,12 @@ export type TracingOptions = { /** Sample rate being used for this trace, this allows for consistent probability sampling */ sampleRate: number /** Properties of the root span and trace id used to stitch context */ - traceId: string - traceFlags: number - parentSpanId: string - baggageFilePath: string + traceId?: string + traceFlags?: number + parentSpanId?: string + baggageFilePath?: string /** Debug mode enabled - logs to stdout */ - debug: boolean + debug?: boolean /** System log file descriptor */ systemLogFile?: number } @@ -61,15 +61,14 @@ export const startTracing = async function (options: TracingOptions, packageJson // Sets the current trace ID and span ID based on the options received // this is used as a way to propagate trace context from Buildbot - // const ctx = trace.setSpanContext(baggageCtx, { - // traceId: options.traceId, - // spanId: options.parentSpanId, - // traceFlags: options.traceFlags, - // isRemote: true, - // }) + const ctx = trace.setSpanContext(context.active(), { + traceId: options.traceId, + spanId: options.parentSpanId, + traceFlags: options.traceFlags, + isRemote: true, + }) - // global['NETLIFY_ROOT_CONTEXT'] = ctx - // return ctx + return ctx } /** Stops the tracing service if there's one running. This will flush any ongoing events */ diff --git a/packages/opentelemetry-sdk-setup/tests/main.test.ts b/packages/opentelemetry-sdk-setup/tests/main.test.ts new file mode 100644 index 0000000000..6a12326846 --- /dev/null +++ b/packages/opentelemetry-sdk-setup/tests/main.test.ts @@ -0,0 +1,87 @@ +import { trace, TraceFlags } from '@opentelemetry/api' +import { Span } from '@opentelemetry/sdk-trace-base' +import { expect, test, beforeEach } from 'vitest' + +import { startTracing, stopTracing } from '../src/sdk-setup.js' + +beforeEach(async () => { + await stopTracing() +}) + +const spanId = '6e0c63257de34c92' +// The sampler is deterministic, meaning that for a given traceId it will always produce a `SAMPLED` or a `NONE` +// consistently. More info in - https://opentelemetry.io/docs/specs/otel/trace/tracestate-probability-sampling/#consistent-probability-sampling +// As such given a specific traceId we can always expect a sampled or note sampled behaviour +const notSampledTraceId = 'd4cda95b652f4a1592b449d5929fda1b' +const sampledTraceId = 'e1819d7355971fd50456e41dbed71e58' + +const testMatrix = [ + { + description: 'when sampled, only include the SampleRate attribute by default', + input: { + traceId: sampledTraceId, + sampleRate: 4, + }, + expects: { + traceId: sampledTraceId, + traceFlags: TraceFlags.SAMPLED, + attributes: { SampleRate: 4 }, + }, + }, + { + description: 'when not sampled, attributes should be undefined and trace flags should be 0', + input: { + traceId: notSampledTraceId, + sampleRate: 4, + }, + expects: { + traceId: notSampledTraceId, + traceFlags: TraceFlags.NONE, + attributes: undefined, + }, + }, + { + description: 'trace flags are ignored by the deterministic sampler', + input: { + traceId: sampledTraceId, + traceFlags: TraceFlags.NONE, + sampleRate: 4, + }, + expects: { + traceId: sampledTraceId, + traceFlags: TraceFlags.SAMPLED, + attributes: { SampleRate: 4 }, + }, + }, +] + +testMatrix.forEach((testCase) => { + test(`Tracing spans - ${testCase.description}`, async (_) => { + const { input, expects } = testCase + const ctx = await startTracing( + { + preloadingEnabled: true, + httpProtocol: 'http', + host: 'localhost', + port: 4127, + sampleRate: input.sampleRate, + traceId: input.traceId, + traceFlags: input.traceFlags, + parentSpanId: spanId, + baggageFilePath: '', + apiKey: '-', + }, + { + name: 'mock-package', + version: '1.0.0', + }, + ) + + const tracer = trace.getTracer('test') + const span = tracer.startSpan('test', {}, ctx) as Span + + expect(span.spanContext().traceId).toEqual(expects.traceId) + expect(span.spanContext().traceFlags).toEqual(expects.traceFlags) + expect(span.attributes).toStrictEqual(expects.attributes) + }) +}) From a009222608731dfd3072e0953d4b4b092b6ff5db Mon Sep 17 00:00:00 2001 From: JGAntunes Date: Wed, 15 Nov 2023 14:58:49 +0000 Subject: [PATCH 03/16] chore: more tests and fix options handling --- packages/opentelemetry-sdk-setup/src/bin.ts | 24 +++++++---- .../opentelemetry-sdk-setup/src/sdk-setup.ts | 23 ++++++----- .../tests/main.test.ts | 41 +++++++++++++++++++ 3 files changed, 70 insertions(+), 18 deletions(-) diff --git a/packages/opentelemetry-sdk-setup/src/bin.ts b/packages/opentelemetry-sdk-setup/src/bin.ts index 25899e5a1d..8f3bc65f30 100644 --- a/packages/opentelemetry-sdk-setup/src/bin.ts +++ b/packages/opentelemetry-sdk-setup/src/bin.ts @@ -18,7 +18,6 @@ const defaultOptions: TracingOptions = { apiKey: '-', parentSpanId: '', traceId: '', - traceFlags: 0, debug: false, } @@ -28,15 +27,24 @@ const args = argsParser(process.argv) as unknown as { tracing: TracingOptions } -const options = { - ...args.tracing, - ...defaultOptions, - debug: args.tracing.debug === undefined ? defaultOptions.debug : args.tracing.debug, - preloadingEnabled: - args.tracing.preloadingEnabled === undefined ? defaultOptions.preloadingEnabled : args.tracing.preloadingEnabled, -} +// Apply the defaults making sure we're not tripped by falsy values +const options = Object.entries(defaultOptions) + .map(([key, value]) => { + if (args.tracing[key] !== undefined) return { [key]: args.tracing[key] } + return { [key]: value } + }) + .reduce((acc, prop) => ({ ...acc, ...prop }), {}) as TracingOptions + +// const options = { +// ...args.tracing, +// ...defaultOptions, +// debug: args.tracing.debug === undefined ? defaultOptions.debug : args.tracing.debug, +// preloadingEnabled: +// args.tracing.preloadingEnabled === undefined ? defaultOptions.preloadingEnabled : args.tracing.preloadingEnabled, +// } const executablePath = args._[1] findExecutablePackageJSON(executablePath).then((pkg) => startTracing(options, pkg)) //TODO handle `stopTracing` via `process` event emitter +process.on('beforeExit', () => console.log('on before exit')) diff --git a/packages/opentelemetry-sdk-setup/src/sdk-setup.ts b/packages/opentelemetry-sdk-setup/src/sdk-setup.ts index dfcdc56f25..db68144495 100644 --- a/packages/opentelemetry-sdk-setup/src/sdk-setup.ts +++ b/packages/opentelemetry-sdk-setup/src/sdk-setup.ts @@ -1,5 +1,5 @@ import { HoneycombSDK } from '@honeycombio/opentelemetry-node' -import { trace, diag, context, DiagLogLevel } from '@opentelemetry/api' +import { trace, diag, context, DiagLogLevel, TraceFlags } from '@opentelemetry/api' import { Resource } from '@opentelemetry/resources' import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions' import type { PackageJson } from 'read-pkg-up' @@ -22,7 +22,7 @@ export type TracingOptions = { parentSpanId?: string baggageFilePath?: string /** Debug mode enabled - logs to stdout */ - debug?: boolean + debug: boolean /** System log file descriptor */ systemLogFile?: number } @@ -59,16 +59,19 @@ export const startTracing = async function (options: TracingOptions, packageJson // Loads the contents of the passed baggageFilePath into the baggage // const baggageCtx = await loadBaggageFromFile(options.baggageFilePath) + const traceFlags = options.traceFlags !== undefined ? options.traceFlags : TraceFlags.NONE // Sets the current trace ID and span ID based on the options received - // this is used as a way to propagate trace context from Buildbot - const ctx = trace.setSpanContext(context.active(), { - traceId: options.traceId, - spanId: options.parentSpanId, - traceFlags: options.traceFlags, - isRemote: true, - }) + // this is used as a way to propagate trace context from other processes such as Buildbot + if (options.traceId !== undefined && options.parentSpanId !== undefined) { + return trace.setSpanContext(context.active(), { + traceId: options.traceId, + spanId: options.parentSpanId, + traceFlags: traceFlags, + isRemote: true, + }) + } - return ctx + return context.active() } /** Stops the tracing service if there's one running. This will flush any ongoing events */ diff --git a/packages/opentelemetry-sdk-setup/tests/main.test.ts b/packages/opentelemetry-sdk-setup/tests/main.test.ts index 6a12326846..825035d60c 100644 --- a/packages/opentelemetry-sdk-setup/tests/main.test.ts +++ b/packages/opentelemetry-sdk-setup/tests/main.test.ts @@ -23,9 +23,11 @@ const testMatrix = [ sampleRate: 4, }, expects: { + parentSpanId: spanId, traceId: sampledTraceId, traceFlags: TraceFlags.SAMPLED, attributes: { SampleRate: 4 }, + checkResource: true, }, }, { @@ -35,9 +37,13 @@ const testMatrix = [ sampleRate: 4, }, expects: { + // When trace isn't sampled, parent span id is undefined + parentSpanId: undefined, traceId: notSampledTraceId, traceFlags: TraceFlags.NONE, attributes: undefined, + // When trace isn't sampled, resource is undefined + checkResource: false, }, }, { @@ -48,9 +54,11 @@ const testMatrix = [ sampleRate: 4, }, expects: { + parentSpanId: spanId, traceId: sampledTraceId, traceFlags: TraceFlags.SAMPLED, attributes: { SampleRate: 4 }, + checkResource: true, }, }, ] @@ -70,6 +78,7 @@ testMatrix.forEach((testCase) => { parentSpanId: spanId, baggageFilePath: '', apiKey: '-', + debug: false, }, { name: 'mock-package', @@ -82,6 +91,38 @@ testMatrix.forEach((testCase) => { expect(span.spanContext().traceId).toEqual(expects.traceId) expect(span.spanContext().traceFlags).toEqual(expects.traceFlags) + expect(span.parentSpanId).toEqual(expects.parentSpanId) expect(span.attributes).toStrictEqual(expects.attributes) + if (expects.checkResource) { + expect(span.resource.attributes).toContain({ + 'service.name': 'mock-package', + 'service.version': '1.0.0', + }) + } }) }) + +test('Tracing - trace id and resource definition', async (_) => { + const ctx = await startTracing( + { + preloadingEnabled: true, + httpProtocol: 'http', + host: 'localhost', + port: 4127, + sampleRate: 1, + baggageFilePath: '', + apiKey: '-', + debug: false, + }, + { + name: 'mock-package', + version: '1.0.0', + }, + ) + + const tracer = trace.getTracer('test') + const span = tracer.startSpan('test', {}, ctx) as Span + + expect(span.spanContext().traceId).not.empty + expect(span.parentSpanId).toBeUndefined() +}) From b317d533175ef28459e95df1a9de5ab4232e74c4 Mon Sep 17 00:00:00 2001 From: JGAntunes Date: Wed, 15 Nov 2023 15:20:51 +0000 Subject: [PATCH 04/16] chore: tests for package.json resolution --- .../tests/fixtures/monorepo/package.json | 4 ++++ .../monorepo/packages/some-package/js-exec.js | 1 + .../packages/some-package/package.json | 4 ++++ .../package-with-symlink/.bin/js-exec.js | 1 + .../package-with-symlink/package/js-exec.js | 0 .../package-with-symlink/package/package.json | 4 ++++ .../tests/main.test.ts | 19 +++++++++++++++++++ .../opentelemetry-sdk-setup/tsconfig.json | 1 - 8 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 packages/opentelemetry-sdk-setup/tests/fixtures/monorepo/package.json create mode 100755 packages/opentelemetry-sdk-setup/tests/fixtures/monorepo/packages/some-package/js-exec.js create mode 100644 packages/opentelemetry-sdk-setup/tests/fixtures/monorepo/packages/some-package/package.json create mode 120000 packages/opentelemetry-sdk-setup/tests/fixtures/package-with-symlink/.bin/js-exec.js create mode 100755 packages/opentelemetry-sdk-setup/tests/fixtures/package-with-symlink/package/js-exec.js create mode 100644 packages/opentelemetry-sdk-setup/tests/fixtures/package-with-symlink/package/package.json diff --git a/packages/opentelemetry-sdk-setup/tests/fixtures/monorepo/package.json b/packages/opentelemetry-sdk-setup/tests/fixtures/monorepo/package.json new file mode 100644 index 0000000000..7ce724eeef --- /dev/null +++ b/packages/opentelemetry-sdk-setup/tests/fixtures/monorepo/package.json @@ -0,0 +1,4 @@ +{ + "name": "root-package", + "version": "1.0.0" +} diff --git a/packages/opentelemetry-sdk-setup/tests/fixtures/monorepo/packages/some-package/js-exec.js b/packages/opentelemetry-sdk-setup/tests/fixtures/monorepo/packages/some-package/js-exec.js new file mode 100755 index 0000000000..857428357b --- /dev/null +++ b/packages/opentelemetry-sdk-setup/tests/fixtures/monorepo/packages/some-package/js-exec.js @@ -0,0 +1 @@ +console.log("some-package here") diff --git a/packages/opentelemetry-sdk-setup/tests/fixtures/monorepo/packages/some-package/package.json b/packages/opentelemetry-sdk-setup/tests/fixtures/monorepo/packages/some-package/package.json new file mode 100644 index 0000000000..a15047cd96 --- /dev/null +++ b/packages/opentelemetry-sdk-setup/tests/fixtures/monorepo/packages/some-package/package.json @@ -0,0 +1,4 @@ +{ + "name": "some-package", + "version": "2.0.0" +} diff --git a/packages/opentelemetry-sdk-setup/tests/fixtures/package-with-symlink/.bin/js-exec.js b/packages/opentelemetry-sdk-setup/tests/fixtures/package-with-symlink/.bin/js-exec.js new file mode 120000 index 0000000000..d157a0363f --- /dev/null +++ b/packages/opentelemetry-sdk-setup/tests/fixtures/package-with-symlink/.bin/js-exec.js @@ -0,0 +1 @@ +../package/js-exec.js \ No newline at end of file diff --git a/packages/opentelemetry-sdk-setup/tests/fixtures/package-with-symlink/package/js-exec.js b/packages/opentelemetry-sdk-setup/tests/fixtures/package-with-symlink/package/js-exec.js new file mode 100755 index 0000000000..e69de29bb2 diff --git a/packages/opentelemetry-sdk-setup/tests/fixtures/package-with-symlink/package/package.json b/packages/opentelemetry-sdk-setup/tests/fixtures/package-with-symlink/package/package.json new file mode 100644 index 0000000000..dda2a832cf --- /dev/null +++ b/packages/opentelemetry-sdk-setup/tests/fixtures/package-with-symlink/package/package.json @@ -0,0 +1,4 @@ +{ + "name": "package-with-symlink", + "version": "1.0.0" +} diff --git a/packages/opentelemetry-sdk-setup/tests/main.test.ts b/packages/opentelemetry-sdk-setup/tests/main.test.ts index 825035d60c..401a948405 100644 --- a/packages/opentelemetry-sdk-setup/tests/main.test.ts +++ b/packages/opentelemetry-sdk-setup/tests/main.test.ts @@ -3,6 +3,7 @@ import { Span } from '@opentelemetry/sdk-trace-base' import { expect, test, beforeEach } from 'vitest' import { startTracing, stopTracing } from '../src/sdk-setup.js' +import { findExecutablePackageJSON } from '../src/util.js' beforeEach(async () => { await stopTracing() @@ -126,3 +127,21 @@ test('Tracing - trace id and resource definition', async (_) => { expect(span.spanContext().traceId).not.empty expect(span.parentSpanId).toBeUndefined() }) + +test('Tracing - package.json extraction for executable', async (_) => { + const pkgJson = await findExecutablePackageJSON( + new URL('./fixtures/monorepo/packages/some-package/js-exec.js', import.meta.url).pathname, + ) + + expect(pkgJson.name).toEqual('some-package') + expect(pkgJson.version).toEqual('2.0.0') +}) + +test('Tracing - package.json extraction for symlinked executable', async (_) => { + const pkgJson = await findExecutablePackageJSON( + new URL('./fixtures/package-with-symlink/package/js-exec.js', import.meta.url).pathname, + ) + + expect(pkgJson.name).toEqual('package-with-symlink') + expect(pkgJson.version).toEqual('1.0.0') +}) diff --git a/packages/opentelemetry-sdk-setup/tsconfig.json b/packages/opentelemetry-sdk-setup/tsconfig.json index b7bb214dee..d309b97e2c 100644 --- a/packages/opentelemetry-sdk-setup/tsconfig.json +++ b/packages/opentelemetry-sdk-setup/tsconfig.json @@ -1,7 +1,6 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "target": "es2022", "outDir": "lib" /* Specify an output folder for all emitted files. */ }, "include": ["src/**/*.ts"] From 449ecab410c938d8bae6b51ae0a543144e64af9f Mon Sep 17 00:00:00 2001 From: JGAntunes Date: Fri, 17 Nov 2023 10:10:04 +0000 Subject: [PATCH 05/16] chore: call stopTracing onBeforeExit --- packages/opentelemetry-sdk-setup/src/bin.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/packages/opentelemetry-sdk-setup/src/bin.ts b/packages/opentelemetry-sdk-setup/src/bin.ts index 8f3bc65f30..8a4fe9f791 100644 --- a/packages/opentelemetry-sdk-setup/src/bin.ts +++ b/packages/opentelemetry-sdk-setup/src/bin.ts @@ -2,7 +2,7 @@ import process from 'node:process' import argsParser from 'yargs-parser' -import { startTracing, TracingOptions } from './sdk-setup.js' +import { startTracing, stopTracing, TracingOptions } from './sdk-setup.js' import { findExecutablePackageJSON } from './util.js' const DEFAULT_OTEL_TRACING_PORT = 4317 @@ -29,9 +29,11 @@ const args = argsParser(process.argv) as unknown as { // Apply the defaults making sure we're not tripped by falsy values const options = Object.entries(defaultOptions) - .map(([key, value]) => { - if (args.tracing[key] !== undefined) return { [key]: args.tracing[key] } - return { [key]: value } + .map(([key, defaultValue]) => { + if (args.tracing !== undefined && args.tracing[key] !== undefined) { + return { [key]: args.tracing[key] } + } + return { [key]: defaultValue } }) .reduce((acc, prop) => ({ ...acc, ...prop }), {}) as TracingOptions @@ -46,5 +48,6 @@ const executablePath = args._[1] findExecutablePackageJSON(executablePath).then((pkg) => startTracing(options, pkg)) -//TODO handle `stopTracing` via `process` event emitter -process.on('beforeExit', () => console.log('on before exit')) +//TODO handle `stopTracing` via `process` event emitter for all the other cases such as +//SIGINT and SIGTERM signals and potential uncaught exceptions +process.on('beforeExit', async () => await stopTracing()) From ee10777179130a9a9ab94c3daed9c71066573d7f Mon Sep 17 00:00:00 2001 From: JGAntunes Date: Fri, 17 Nov 2023 15:35:42 +0000 Subject: [PATCH 06/16] chore: add baggage file loading logic --- packages/opentelemetry-sdk-setup/src/bin.ts | 7 - .../opentelemetry-sdk-setup/src/sdk-setup.ts | 24 ++- packages/opentelemetry-sdk-setup/src/util.ts | 12 +- .../tests/main.test.ts | 153 +++++++++++++----- 4 files changed, 139 insertions(+), 57 deletions(-) diff --git a/packages/opentelemetry-sdk-setup/src/bin.ts b/packages/opentelemetry-sdk-setup/src/bin.ts index 8a4fe9f791..4c36ef4619 100644 --- a/packages/opentelemetry-sdk-setup/src/bin.ts +++ b/packages/opentelemetry-sdk-setup/src/bin.ts @@ -37,13 +37,6 @@ const options = Object.entries(defaultOptions) }) .reduce((acc, prop) => ({ ...acc, ...prop }), {}) as TracingOptions -// const options = { -// ...args.tracing, -// ...defaultOptions, -// debug: args.tracing.debug === undefined ? defaultOptions.debug : args.tracing.debug, -// preloadingEnabled: -// args.tracing.preloadingEnabled === undefined ? defaultOptions.preloadingEnabled : args.tracing.preloadingEnabled, -// } const executablePath = args._[1] findExecutablePackageJSON(executablePath).then((pkg) => startTracing(options, pkg)) diff --git a/packages/opentelemetry-sdk-setup/src/sdk-setup.ts b/packages/opentelemetry-sdk-setup/src/sdk-setup.ts index db68144495..1827d744af 100644 --- a/packages/opentelemetry-sdk-setup/src/sdk-setup.ts +++ b/packages/opentelemetry-sdk-setup/src/sdk-setup.ts @@ -1,10 +1,10 @@ import { HoneycombSDK } from '@honeycombio/opentelemetry-node' -import { trace, diag, context, DiagLogLevel, TraceFlags } from '@opentelemetry/api' +import { trace, diag, context, propagation, DiagLogLevel, TraceFlags } from '@opentelemetry/api' import { Resource } from '@opentelemetry/resources' import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions' import type { PackageJson } from 'read-pkg-up' -import { getOtelLogger } from './util.js' +import { getOtelLogger, loadBaggageFromFile } from './util.js' export type TracingOptions = { /** This is a temporary property to signal preloading is enabled, can be replaced with `enabled` once we retire build's internal sdk setup */ @@ -57,13 +57,14 @@ export const startTracing = async function (options: TracingOptions, packageJson sdk.start() // Loads the contents of the passed baggageFilePath into the baggage - // const baggageCtx = await loadBaggageFromFile(options.baggageFilePath) + const baggageAttributes = await loadBaggageFromFile(options.baggageFilePath) + const baggageCtx = setMultiSpanAttributes(baggageAttributes) const traceFlags = options.traceFlags !== undefined ? options.traceFlags : TraceFlags.NONE // Sets the current trace ID and span ID based on the options received // this is used as a way to propagate trace context from other processes such as Buildbot if (options.traceId !== undefined && options.parentSpanId !== undefined) { - return trace.setSpanContext(context.active(), { + return trace.setSpanContext(baggageCtx, { traceId: options.traceId, spanId: options.parentSpanId, traceFlags: traceFlags, @@ -86,3 +87,18 @@ export const stopTracing = async function () { diag.error(e) } } + +/** Sets attributes to be propagated across child spans under the current active context + * TODO this method will be removed from this package once we move it to a dedicated one to be shared between build, + * this setup and any other node module which might use our open telemetry setup + * */ +export const setMultiSpanAttributes = function (attributes: { [key: string]: string }) { + const currentBaggage = propagation.getBaggage(context.active()) + // Create a baggage if there's none + let baggage = currentBaggage === undefined ? propagation.createBaggage() : currentBaggage + Object.entries(attributes).forEach(([key, value]) => { + baggage = baggage.setEntry(key, { value }) + }) + + return propagation.setBaggage(context.active(), baggage) +} diff --git a/packages/opentelemetry-sdk-setup/src/util.ts b/packages/opentelemetry-sdk-setup/src/util.ts index c073686a03..510acd1a67 100644 --- a/packages/opentelemetry-sdk-setup/src/util.ts +++ b/packages/opentelemetry-sdk-setup/src/util.ts @@ -1,7 +1,7 @@ import { createWriteStream } from 'node:fs' import { realpath, readFile } from 'node:fs/promises' -import { context, diag, DiagLogger } from '@opentelemetry/api' +import { diag, DiagLogger } from '@opentelemetry/api' import { parseKeyPairsIntoRecord } from '@opentelemetry/core/build/src/baggage/utils.js' import { readPackageUp, PackageJson } from 'read-pkg-up' @@ -62,17 +62,17 @@ export const getOtelLogger = function ( } //** Loads the baggage attributes from a baggabe file which follows W3C Baggage specification */ -export const loadBaggageFromFile = async function (baggageFilePath: string) { - if (baggageFilePath.length === 0) { - diag.warn('Empty baggage file path provided, no context loaded') - return context.active() +export const loadBaggageFromFile = async function (baggageFilePath?: string) { + if (baggageFilePath === undefined || baggageFilePath.length === 0) { + diag.warn('No baggage file path provided, no context loaded') + return {} } let baggageString: string try { baggageString = await readFile(baggageFilePath, 'utf-8') } catch (error) { diag.error(error) - return context.active() + return {} } return parseKeyPairsIntoRecord(baggageString) } diff --git a/packages/opentelemetry-sdk-setup/tests/main.test.ts b/packages/opentelemetry-sdk-setup/tests/main.test.ts index 401a948405..e5703d3dca 100644 --- a/packages/opentelemetry-sdk-setup/tests/main.test.ts +++ b/packages/opentelemetry-sdk-setup/tests/main.test.ts @@ -1,9 +1,13 @@ +import { writeFile, rm, mkdtemp } from 'fs/promises' +import { tmpdir } from 'os' +import { join } from 'path' + import { trace, TraceFlags } from '@opentelemetry/api' import { Span } from '@opentelemetry/sdk-trace-base' -import { expect, test, beforeEach } from 'vitest' +import { expect, test, beforeEach, beforeAll, afterAll } from 'vitest' import { startTracing, stopTracing } from '../src/sdk-setup.js' -import { findExecutablePackageJSON } from '../src/util.js' +import { findExecutablePackageJSON, loadBaggageFromFile } from '../src/util.js' beforeEach(async () => { await stopTracing() @@ -16,7 +20,7 @@ const spanId = '6e0c63257de34c92' const notSampledTraceId = 'd4cda95b652f4a1592b449d5929fda1b' const sampledTraceId = 'e1819d7355971fd50456e41dbed71e58' -const testMatrix = [ +const testSpanMatrix = [ { description: 'when sampled, only include the SampleRate attribute by default', input: { @@ -64,43 +68,40 @@ const testMatrix = [ }, ] -testMatrix.forEach((testCase) => { - test(`Tracing spans - ${testCase.description}`, async (_) => { - const { input, expects } = testCase - const ctx = await startTracing( - { - preloadingEnabled: true, - httpProtocol: 'http', - host: 'localhost', - port: 4127, - sampleRate: input.sampleRate, - traceId: input.traceId, - traceFlags: input.traceFlags, - parentSpanId: spanId, - baggageFilePath: '', - apiKey: '-', - debug: false, - }, - { - name: 'mock-package', - version: '1.0.0', - }, - ) - - const tracer = trace.getTracer('test') - const span = tracer.startSpan('test', {}, ctx) as Span - - expect(span.spanContext().traceId).toEqual(expects.traceId) - expect(span.spanContext().traceFlags).toEqual(expects.traceFlags) - expect(span.parentSpanId).toEqual(expects.parentSpanId) - expect(span.attributes).toStrictEqual(expects.attributes) - if (expects.checkResource) { - expect(span.resource.attributes).toContain({ - 'service.name': 'mock-package', - 'service.version': '1.0.0', - }) - } - }) +test.each(testSpanMatrix)('Tracing spans - $testCase.description', async ({ input, expects }) => { + const ctx = await startTracing( + { + preloadingEnabled: true, + httpProtocol: 'http', + host: 'localhost', + port: 4127, + sampleRate: input.sampleRate, + traceId: input.traceId, + traceFlags: input.traceFlags, + parentSpanId: spanId, + baggageFilePath: '', + apiKey: '-', + debug: false, + }, + { + name: 'mock-package', + version: '1.0.0', + }, + ) + + const tracer = trace.getTracer('test') + const span = tracer.startSpan('test', {}, ctx) as Span + + expect(span.spanContext().traceId).toEqual(expects.traceId) + expect(span.spanContext().traceFlags).toEqual(expects.traceFlags) + expect(span.parentSpanId).toEqual(expects.parentSpanId) + expect(span.attributes).toStrictEqual(expects.attributes) + if (expects.checkResource) { + expect(span.resource.attributes).toContain({ + 'service.name': 'mock-package', + 'service.version': '1.0.0', + }) + } }) test('Tracing - trace id and resource definition', async (_) => { @@ -145,3 +146,75 @@ test('Tracing - package.json extraction for symlinked executable', async (_) => expect(pkgJson.name).toEqual('package-with-symlink') expect(pkgJson.version).toEqual('1.0.0') }) + +const testMatrixBaggageFile = [ + { + description: 'when baggageFilePath is undefined', + input: { + baggageFilePath: undefined, + baggageFileContent: null, + }, + expects: { + somefield: undefined, + foo: undefined, + }, + }, + { + description: 'when baggageFilePath is blank', + input: { + baggageFilePath: '', + baggageFileContent: null, + }, + expects: { + somefield: undefined, + foo: undefined, + }, + }, + { + description: 'when baggageFilePath is set but file is empty', + input: { + baggageFilePath: 'baggage.dump', + baggageFileContent: '', + }, + expects: {}, + }, + { + description: 'when baggageFilePath is set and has content', + input: { + baggageFilePath: 'baggage.dump', + baggageFileContent: 'somefield=value,foo=bar', + }, + expects: { + somefield: 'value', + foo: 'bar', + }, + }, +] + +let baggagePath: string +beforeAll(async () => { + baggagePath = await mkdtemp(join(tmpdir(), 'baggage-path-')) +}) + +afterAll(async () => { + await rm(baggagePath, { recursive: true }) +}) + +test.each(testMatrixBaggageFile)('Tracing baggage loading - $description', async ({ input, expects }) => { + // We only want to write the file if it's a non-empty string '', while we still want to test scenario + let filePath = input.baggageFilePath + if (typeof input.baggageFilePath === 'string' && input.baggageFilePath.length > 0) { + filePath = `${baggagePath}/${input.baggageFilePath}` + await writeFile(filePath, input.baggageFileContent) + } + + const attributes = await loadBaggageFromFile(filePath) + + // When there's no file we test that baggage is not set + if (input.baggageFilePath === '' || input.baggageFilePath === undefined) { + expect(attributes).toStrictEqual({}) + return + } + + expect(attributes).toStrictEqual(expects) +}) From 6dd925fa2505d70de9bb640508fc6e3f9e22c383 Mon Sep 17 00:00:00 2001 From: JGAntunes Date: Fri, 17 Nov 2023 19:00:56 +0000 Subject: [PATCH 07/16] chore: add global context set utility --- packages/opentelemetry-sdk-setup/src/bin.ts | 16 ++++++++++++-- packages/opentelemetry-sdk-setup/src/util.ts | 22 ++++++++++++++++++- .../tests/main.test.ts | 18 +++++++++++++-- 3 files changed, 51 insertions(+), 5 deletions(-) diff --git a/packages/opentelemetry-sdk-setup/src/bin.ts b/packages/opentelemetry-sdk-setup/src/bin.ts index 4c36ef4619..bf29e919c5 100644 --- a/packages/opentelemetry-sdk-setup/src/bin.ts +++ b/packages/opentelemetry-sdk-setup/src/bin.ts @@ -1,9 +1,10 @@ import process from 'node:process' +import { diag } from '@opentelemetry/api' import argsParser from 'yargs-parser' import { startTracing, stopTracing, TracingOptions } from './sdk-setup.js' -import { findExecutablePackageJSON } from './util.js' +import { findExecutablePackageJSON, setGlobalContext } from './util.js' const DEFAULT_OTEL_TRACING_PORT = 4317 const DEFAULT_OTEL_ENDPOINT_PROTOCOL = 'http' @@ -39,7 +40,18 @@ const options = Object.entries(defaultOptions) const executablePath = args._[1] -findExecutablePackageJSON(executablePath).then((pkg) => startTracing(options, pkg)) +try { + const pkg = await findExecutablePackageJSON(executablePath) + const rootCtx = await startTracing(options, pkg) + if (rootCtx !== undefined) { + diag.debug('Setting global root context imported from bagage file') + setGlobalContext(rootCtx) + } else { + diag.debug('Root context undefined, skip setting global root context') + } +} catch { + // don't blow up the execution in case something fails +} //TODO handle `stopTracing` via `process` event emitter for all the other cases such as //SIGINT and SIGTERM signals and potential uncaught exceptions diff --git a/packages/opentelemetry-sdk-setup/src/util.ts b/packages/opentelemetry-sdk-setup/src/util.ts index 510acd1a67..4a4b65f992 100644 --- a/packages/opentelemetry-sdk-setup/src/util.ts +++ b/packages/opentelemetry-sdk-setup/src/util.ts @@ -1,13 +1,14 @@ import { createWriteStream } from 'node:fs' import { realpath, readFile } from 'node:fs/promises' -import { diag, DiagLogger } from '@opentelemetry/api' +import { diag, context, DiagLogger, Context } from '@opentelemetry/api' import { parseKeyPairsIntoRecord } from '@opentelemetry/core/build/src/baggage/utils.js' import { readPackageUp, PackageJson } from 'read-pkg-up' /** * Builds a function for logging data to a provided fileDescriptor (i.e. hidden from * the user-facing build logs) + * This has been pulled from @netlify/build as a quick way to hook into the system logger */ const getSystemLogger = function ( debug: boolean, @@ -100,3 +101,22 @@ export const findExecutablePackageJSON = async function (path: string): Promise< return {} } } + +/** + * Sets global context to be used when initialising our root span + * TODO this will move to a shared package (opentelemetry-utils) to scope the usage of this global property there + */ +export const setGlobalContext = function (ctx: Context) { + global['NETLIFY_GLOBAL_CONTEXT'] = ctx +} + +/** + * Gets the global context to be used when initialising our root span + * TODO this will move to a shared package (opentelemetry-utils) to scope the usage of this global property there + */ +export const getGlobalContext = function (): Context { + if (global['NETLIFY_GLOBAL_CONTEXT'] === undefined) { + return context.active() + } + return global['NETLIFY_GLOBAL_CONTEXT'] +} diff --git a/packages/opentelemetry-sdk-setup/tests/main.test.ts b/packages/opentelemetry-sdk-setup/tests/main.test.ts index e5703d3dca..22bc9ad3c4 100644 --- a/packages/opentelemetry-sdk-setup/tests/main.test.ts +++ b/packages/opentelemetry-sdk-setup/tests/main.test.ts @@ -2,12 +2,12 @@ import { writeFile, rm, mkdtemp } from 'fs/promises' import { tmpdir } from 'os' import { join } from 'path' -import { trace, TraceFlags } from '@opentelemetry/api' +import { trace, TraceFlags, context } from '@opentelemetry/api' import { Span } from '@opentelemetry/sdk-trace-base' import { expect, test, beforeEach, beforeAll, afterAll } from 'vitest' import { startTracing, stopTracing } from '../src/sdk-setup.js' -import { findExecutablePackageJSON, loadBaggageFromFile } from '../src/util.js' +import { findExecutablePackageJSON, loadBaggageFromFile, getGlobalContext, setGlobalContext } from '../src/util.js' beforeEach(async () => { await stopTracing() @@ -218,3 +218,17 @@ test.each(testMatrixBaggageFile)('Tracing baggage loading - $description', async expect(attributes).toStrictEqual(expects) }) + +test('Sets the global context', async () => { + const rootCtx = context.active() + const key = Symbol('some-key') + const newCtx = rootCtx.setValue(key, 'my-custom-value') + expect(getGlobalContext()).toBe(rootCtx) + expect(getGlobalContext()).not.toBe(newCtx) + setGlobalContext(newCtx) + + const globalCtx = getGlobalContext() + expect(globalCtx).not.toBe(rootCtx) + expect(globalCtx).toBe(newCtx) + expect(globalCtx.getValue(key)).toEqual('my-custom-value') +}) From df7178c69a2fdee8ad247435dfad74b9a193f314 Mon Sep 17 00:00:00 2001 From: JGAntunes Date: Fri, 17 Nov 2023 19:26:19 +0000 Subject: [PATCH 08/16] chore: add README.md --- packages/opentelemetry-sdk-setup/README.md | 70 ++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/packages/opentelemetry-sdk-setup/README.md b/packages/opentelemetry-sdk-setup/README.md index e69de29bb2..b18afa89f1 100644 --- a/packages/opentelemetry-sdk-setup/README.md +++ b/packages/opentelemetry-sdk-setup/README.md @@ -0,0 +1,70 @@ +# Opentelemetry SDK Setup + +This package extracts the logic necessary to initialise the Opentelemetry JS SDK using our tracing exporter. This not +only allows us to reuse the initialisation logic across different node process executions but also means **our modules +don't need to depend on any @opentelemetry module other than the @opentelemetry/api** + +## How to use it? + +This module is designed to be preloaded via [--import](https://nodejs.org/docs/latest-v18.x/api/cli.html#--importmodule) +on any node execution. For example: + +``` +$> node --import=./lib/bin.js ../build/lib/core/bin.js --debug --tracing.enabled=false --tracing.httpProtocol=https --tracing.host=api.honeycomb.io --tracing.port=443 --tracing.debug=true --tracing.preloadingEnabled=true . +``` + +On the script we're instrumenting we can just rely on `@opentelemetry/api` to create spans and interact with the SDK: + +```ts + import { trace } from '@opentelemetry/api' + const tracer = trace.getTracer('secrets-scanning') + + const myInstrumentedFunction = async function() { + await tracer.startActiveSpan( + 'scanning-files', + { attributes: { keysToSearchFor, totalFiles: filePaths.length } }, + async (span) => { + doSomeWork() + span.end() + } + } + +``` + +## Sharing and receiving context from outside of the process + +Our SDK initialisation is prepared to receive [trace](https://opentelemetry.io/docs/concepts/signals/traces/) and +[baggage](https://opentelemetry.io/docs/concepts/signals/baggage/) context from outside of the process. This allow us +to, for example, hook this node process execution to an ongoing trace which is already taking place or share the baggage +attributes for that execution with the spans created in this process. The list of tracing options show the options +available to the executable and what they mean. + +Unfortunately, to our knowledge, the current `@opentelemetry` setup does not allow us to define an initial global +context that the root span can inherit from. As a consequence we had to get creative in order to pass the ingested +attributes to our main script execution, so that the root span can get the newly ingested attributes. We're relying on a +global property which can be accessed via `@netlify/opentelemetry-utils`. If your process receives any outside +attributes you can do the following: + +``` +$> node --import=./lib/bin.js my-instrumented-script --tracing.httpProtocol=https --tracing.host=api.honeycomb.io --tracing.port=443 --tracing.debug=true --tracing.preloadingEnabled=true --tracing.baggageFilePath='./my-baggage-filepath' --tracing.traceId= --tracing.parentSpanId= +``` + +And on the instrumented script: + +```ts + import { trace } from '@opentelemetry/api' + import { getGlobalContext } from '@netlify/opentelemetry-utils' + const tracer = trace.getTracer('secrets-scanning') + + const myInstrumentedFunction = async function() { + await tracer.startActiveSpan( + 'scanning-files', + { attributes: { keysToSearchFor, totalFiles: filePaths.length } }, + getGlobalContext(), + async (span) => { + doSomeWork() + span.end() + } + } + +``` From 013b8558b8fbaf5ecb9c50a710addb3c8e7de8b0 Mon Sep 17 00:00:00 2001 From: JGAntunes Date: Fri, 17 Nov 2023 19:33:50 +0000 Subject: [PATCH 09/16] chore: mpr README.md --- packages/opentelemetry-sdk-setup/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/opentelemetry-sdk-setup/README.md b/packages/opentelemetry-sdk-setup/README.md index b18afa89f1..6856274088 100644 --- a/packages/opentelemetry-sdk-setup/README.md +++ b/packages/opentelemetry-sdk-setup/README.md @@ -22,7 +22,7 @@ On the script we're instrumenting we can just rely on `@opentelemetry/api` to cr const myInstrumentedFunction = async function() { await tracer.startActiveSpan( 'scanning-files', - { attributes: { keysToSearchFor, totalFiles: filePaths.length } }, + { attributes: { myAttribute: 'foobar' } }, async (span) => { doSomeWork() span.end() @@ -59,7 +59,7 @@ And on the instrumented script: const myInstrumentedFunction = async function() { await tracer.startActiveSpan( 'scanning-files', - { attributes: { keysToSearchFor, totalFiles: filePaths.length } }, + { attributes: { myAttribute: 'foobar' } }, getGlobalContext(), async (span) => { doSomeWork() From 11d06eb7010806ae2e523de5f042422a5b13dc0c Mon Sep 17 00:00:00 2001 From: JGAntunes Date: Fri, 17 Nov 2023 19:36:22 +0000 Subject: [PATCH 10/16] chore: cleanup package.json --- package-lock.json | 2 -- packages/opentelemetry-sdk-setup/package.json | 2 -- 2 files changed, 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2cadbb8b27..74ecfacac0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -27148,11 +27148,9 @@ }, "devDependencies": { "@types/node": "^14.18.53", - "@types/semver": "^7.3.13", "@vitest/coverage-c8": "^0.30.1", "@vitest/ui": "^0.30.1", "typescript": "^5.0.0", - "unionfs": "^4.4.0", "vite": "^4.0.4", "vitest": "^0.30.1" }, diff --git a/packages/opentelemetry-sdk-setup/package.json b/packages/opentelemetry-sdk-setup/package.json index 8c531f07bc..6aecb00e37 100644 --- a/packages/opentelemetry-sdk-setup/package.json +++ b/packages/opentelemetry-sdk-setup/package.json @@ -38,11 +38,9 @@ }, "devDependencies": { "@types/node": "^14.18.53", - "@types/semver": "^7.3.13", "@vitest/coverage-c8": "^0.30.1", "@vitest/ui": "^0.30.1", "typescript": "^5.0.0", - "unionfs": "^4.4.0", "vite": "^4.0.4", "vitest": "^0.30.1" }, From 125ee97e95e1ecbb1d3a6ccff8b8935838b93163 Mon Sep 17 00:00:00 2001 From: JGAntunes Date: Fri, 17 Nov 2023 19:42:04 +0000 Subject: [PATCH 11/16] fix: bin setup --- packages/opentelemetry-sdk-setup/bin.js | 5 +++++ packages/opentelemetry-sdk-setup/package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100755 packages/opentelemetry-sdk-setup/bin.js diff --git a/packages/opentelemetry-sdk-setup/bin.js b/packages/opentelemetry-sdk-setup/bin.js new file mode 100755 index 0000000000..1a24988888 --- /dev/null +++ b/packages/opentelemetry-sdk-setup/bin.js @@ -0,0 +1,5 @@ +#!/usr/bin/env node + +// This is a workaround for npm issue: https://github.com/npm/cli/issues/2632 + +import './lib/bin.js' diff --git a/packages/opentelemetry-sdk-setup/package.json b/packages/opentelemetry-sdk-setup/package.json index 6aecb00e37..840f42ce5e 100644 --- a/packages/opentelemetry-sdk-setup/package.json +++ b/packages/opentelemetry-sdk-setup/package.json @@ -4,7 +4,7 @@ "description": "Opentelemetry SDK setup script", "type": "module", "bin": { - "otel-sdk-setup": "./lib/bin.js" + "otel-sdk-setup": "./bin.js" }, "files": [ "bin.js", From 9e5a060e9e2c050686217e16ce0a0f80adf3a211 Mon Sep 17 00:00:00 2001 From: JGAntunes Date: Fri, 17 Nov 2023 19:47:47 +0000 Subject: [PATCH 12/16] chore: linting --- packages/opentelemetry-sdk-setup/tests/main.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/opentelemetry-sdk-setup/tests/main.test.ts b/packages/opentelemetry-sdk-setup/tests/main.test.ts index 22bc9ad3c4..41fdbcbe28 100644 --- a/packages/opentelemetry-sdk-setup/tests/main.test.ts +++ b/packages/opentelemetry-sdk-setup/tests/main.test.ts @@ -104,7 +104,7 @@ test.each(testSpanMatrix)('Tracing spans - $testCase.description', async ({ inpu } }) -test('Tracing - trace id and resource definition', async (_) => { +test('Tracing - trace id and resource definition', async () => { const ctx = await startTracing( { preloadingEnabled: true, @@ -129,7 +129,7 @@ test('Tracing - trace id and resource definition', async (_) => { expect(span.parentSpanId).toBeUndefined() }) -test('Tracing - package.json extraction for executable', async (_) => { +test('Tracing - package.json extraction for executable', async () => { const pkgJson = await findExecutablePackageJSON( new URL('./fixtures/monorepo/packages/some-package/js-exec.js', import.meta.url).pathname, ) @@ -138,7 +138,7 @@ test('Tracing - package.json extraction for executable', async (_) => { expect(pkgJson.version).toEqual('2.0.0') }) -test('Tracing - package.json extraction for symlinked executable', async (_) => { +test('Tracing - package.json extraction for symlinked executable', async () => { const pkgJson = await findExecutablePackageJSON( new URL('./fixtures/package-with-symlink/package/js-exec.js', import.meta.url).pathname, ) From 870f01fb6090e65349f10bf21dc16f28b8bdf506 Mon Sep 17 00:00:00 2001 From: JGAntunes Date: Fri, 17 Nov 2023 20:14:50 +0000 Subject: [PATCH 13/16] chore: update lockfile --- package-lock.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index 07b978c6eb..c8f5f183b3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -27144,7 +27144,7 @@ "yargs-parser": "^21.1.1" }, "bin": { - "otel-sdk-setup": "lib/bin.js" + "otel-sdk-setup": "bin.js" }, "devDependencies": { "@types/node": "^14.18.53", From ea59699af00b2f6ec762f2d9d311bc6e9d22f82b Mon Sep 17 00:00:00 2001 From: JGAntunes Date: Fri, 17 Nov 2023 20:41:57 +0000 Subject: [PATCH 14/16] chore: try to make windows happy? --- packages/opentelemetry-sdk-setup/tests/main.test.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/opentelemetry-sdk-setup/tests/main.test.ts b/packages/opentelemetry-sdk-setup/tests/main.test.ts index 41fdbcbe28..571bd53b2c 100644 --- a/packages/opentelemetry-sdk-setup/tests/main.test.ts +++ b/packages/opentelemetry-sdk-setup/tests/main.test.ts @@ -1,4 +1,5 @@ -import { writeFile, rm, mkdtemp } from 'fs/promises' +import { writeFile, rm, mkdtemp } from 'node:fs/promises' +import { resolve } from 'node:path' import { tmpdir } from 'os' import { join } from 'path' @@ -131,7 +132,7 @@ test('Tracing - trace id and resource definition', async () => { test('Tracing - package.json extraction for executable', async () => { const pkgJson = await findExecutablePackageJSON( - new URL('./fixtures/monorepo/packages/some-package/js-exec.js', import.meta.url).pathname, + resolve('tests', 'fixtures', 'monorepo', 'packages', 'some-package', 'js-exec.js'), ) expect(pkgJson.name).toEqual('some-package') @@ -140,7 +141,7 @@ test('Tracing - package.json extraction for executable', async () => { test('Tracing - package.json extraction for symlinked executable', async () => { const pkgJson = await findExecutablePackageJSON( - new URL('./fixtures/package-with-symlink/package/js-exec.js', import.meta.url).pathname, + resolve('tests', 'fixtures', 'package-with-symlink', 'package', 'js-exec.js'), ) expect(pkgJson.name).toEqual('package-with-symlink') From 7e1398205ebfd5d0cd4a56e0eb2e8a7c341293f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Antunes?= Date: Mon, 20 Nov 2023 16:28:55 +0000 Subject: [PATCH 15/16] Update packages/opentelemetry-sdk-setup/src/util.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Eduardo Bouças --- packages/opentelemetry-sdk-setup/src/util.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/opentelemetry-sdk-setup/src/util.ts b/packages/opentelemetry-sdk-setup/src/util.ts index 4a4b65f992..3ca66b67e7 100644 --- a/packages/opentelemetry-sdk-setup/src/util.ts +++ b/packages/opentelemetry-sdk-setup/src/util.ts @@ -62,7 +62,7 @@ export const getOtelLogger = function ( } } -//** Loads the baggage attributes from a baggabe file which follows W3C Baggage specification */ +//** Loads the baggage attributes from a baggage file which follows W3C Baggage specification */ export const loadBaggageFromFile = async function (baggageFilePath?: string) { if (baggageFilePath === undefined || baggageFilePath.length === 0) { diag.warn('No baggage file path provided, no context loaded') From 1e5e44eedd8510b78b1be5c9ef6367569b445b3c Mon Sep 17 00:00:00 2001 From: JGAntunes Date: Mon, 20 Nov 2023 16:34:15 +0000 Subject: [PATCH 16/16] chore: s/getOtelLogger/getDiagLogger/ --- packages/opentelemetry-sdk-setup/src/sdk-setup.ts | 4 ++-- packages/opentelemetry-sdk-setup/src/util.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/opentelemetry-sdk-setup/src/sdk-setup.ts b/packages/opentelemetry-sdk-setup/src/sdk-setup.ts index 1827d744af..cd04eb68be 100644 --- a/packages/opentelemetry-sdk-setup/src/sdk-setup.ts +++ b/packages/opentelemetry-sdk-setup/src/sdk-setup.ts @@ -4,7 +4,7 @@ import { Resource } from '@opentelemetry/resources' import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions' import type { PackageJson } from 'read-pkg-up' -import { getOtelLogger, loadBaggageFromFile } from './util.js' +import { getDiagLogger, loadBaggageFromFile } from './util.js' export type TracingOptions = { /** This is a temporary property to signal preloading is enabled, can be replaced with `enabled` once we retire build's internal sdk setup */ @@ -49,7 +49,7 @@ export const startTracing = async function (options: TracingOptions, packageJson // Set the diagnostics logger to our system logger. We also need to suppress the override msg // in case there's a default console logger already registered (it would log a msg to it) - diag.setLogger(getOtelLogger(options.debug, options.systemLogFile), { + diag.setLogger(getDiagLogger(options.debug, options.systemLogFile), { logLevel: options.debug ? DiagLogLevel.DEBUG : DiagLogLevel.INFO, suppressOverrideMessage: true, }) diff --git a/packages/opentelemetry-sdk-setup/src/util.ts b/packages/opentelemetry-sdk-setup/src/util.ts index 3ca66b67e7..6c74ba6db3 100644 --- a/packages/opentelemetry-sdk-setup/src/util.ts +++ b/packages/opentelemetry-sdk-setup/src/util.ts @@ -42,7 +42,7 @@ const getSystemLogger = function ( } /** Given a simple logging function return a `DiagLogger`. Used to setup our system logger as the diag logger.*/ -export const getOtelLogger = function ( +export const getDiagLogger = function ( debug: boolean, /** A system log file descriptor, if non is provided it will be a noop logger */ systemLogFile?: number,