diff --git a/.github/component-label-map.yml b/.github/component-label-map.yml index de2ff8c3ef..5a9fc3af56 100644 --- a/.github/component-label-map.yml +++ b/.github/component-label-map.yml @@ -61,7 +61,6 @@ pkg:instrumentation-aws-lambda: - changed-files: - any-glob-to-any-file: - plugins/node/opentelemetry-instrumentation-aws-lambda/** - - propagators/opentelemetry-propagator-aws-xray/** pkg:instrumentation-aws-sdk: - changed-files: - any-glob-to-any-file: @@ -225,6 +224,10 @@ pkg:instrumentation-tedious: - any-glob-to-any-file: - plugins/node/instrumentation-tedious/** - packages/opentelemetry-test-utils/** +pkg:instrumentation-undici: + - changed-files: + - any-glob-to-any-file: + - plugins/node/instrumentation-undici/** pkg:instrumentation-user-interaction: - changed-files: - any-glob-to-any-file: @@ -242,10 +245,6 @@ pkg:propagation-utils: - any-glob-to-any-file: - packages/opentelemetry-propagation-utils/** - packages/opentelemetry-test-utils/** -pkg:propagator-aws-xray: - - changed-files: - - any-glob-to-any-file: - - propagators/opentelemetry-propagator-aws-xray/** pkg:propagator-grpc-census-binary: - changed-files: - any-glob-to-any-file: diff --git a/.github/component_owners.yml b/.github/component_owners.yml index fdc9c0fc10..cafc2a7065 100644 --- a/.github/component_owners.yml +++ b/.github/component_owners.yml @@ -138,8 +138,6 @@ components: - obecny plugins/web/opentelemetry-plugin-react-load: - martinkuba - propagators/opentelemetry-propagator-aws-xray: - - carolabadeer propagators/opentelemetry-propagator-grpc-census-binary: [] # Unmaintained? propagators/opentelemetry-propagator-instana: diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 1c58cefc06..6bf4f04da7 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -54,11 +54,15 @@ jobs: # get main again - name: Checkout Repository + # only checkout if a release has been created + if: ${{ steps.release.outputs.release_created }} uses: actions/checkout@v4 with: fetch-depth: 0 - name: Rebuild Packages + # only rebuild if a release has been created + if: ${{ steps.release.outputs.release_created }} run: | npm ci npm run compile @@ -67,6 +71,8 @@ jobs: # need to publish all unpublished versions to npm here # See: https://github.com/lerna/lerna/tree/main/commands/publish#bump-from-package - name: Publish to npm + # only publish if a release has been created + if: ${{ steps.release.outputs.release_created }} env: NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} run: npx lerna publish from-package --no-push --no-private --no-git-tag-version --no-verify-access --yes diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 8d981b1c76..21d8994326 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -57,7 +57,6 @@ "plugins/web/opentelemetry-instrumentation-long-task": "0.37.0", "plugins/web/opentelemetry-instrumentation-user-interaction": "0.37.0", "plugins/web/opentelemetry-plugin-react-load": "0.30.0", - "propagators/opentelemetry-propagator-aws-xray": "1.3.1", "propagators/opentelemetry-propagator-grpc-census-binary": "0.27.1", "propagators/opentelemetry-propagator-instana": "0.3.1", "propagators/opentelemetry-propagator-ot-trace": "0.27.1" diff --git a/LICENSE b/LICENSE index e50e8c80f9..261eeb9e9f 100644 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/archive/opentelemetry-browser-extension-autoinjection/LICENSE b/archive/opentelemetry-browser-extension-autoinjection/LICENSE index 26104aae5b..f49a4e16e6 100644 --- a/archive/opentelemetry-browser-extension-autoinjection/LICENSE +++ b/archive/opentelemetry-browser-extension-autoinjection/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/detectors/node/opentelemetry-resource-detector-alibaba-cloud/LICENSE b/detectors/node/opentelemetry-resource-detector-alibaba-cloud/LICENSE index a42588e10f..261eeb9e9f 100644 --- a/detectors/node/opentelemetry-resource-detector-alibaba-cloud/LICENSE +++ b/detectors/node/opentelemetry-resource-detector-alibaba-cloud/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2021] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/detectors/node/opentelemetry-resource-detector-aws/LICENSE b/detectors/node/opentelemetry-resource-detector-aws/LICENSE index 6b91a297c8..261eeb9e9f 100644 --- a/detectors/node/opentelemetry-resource-detector-aws/LICENSE +++ b/detectors/node/opentelemetry-resource-detector-aws/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2020] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/detectors/node/opentelemetry-resource-detector-azure/LICENSE b/detectors/node/opentelemetry-resource-detector-azure/LICENSE index 6f13cd2fe6..a36ec4ab7e 100644 --- a/detectors/node/opentelemetry-resource-detector-azure/LICENSE +++ b/detectors/node/opentelemetry-resource-detector-azure/LICENSE @@ -186,7 +186,7 @@ APPENDIX: How to apply the Apache License to your work. same "printed page" as the copyright notice for easier identification within third-party archives. -Copyright [2020] OpenTelemetry Authors +Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/detectors/node/opentelemetry-resource-detector-container/LICENSE b/detectors/node/opentelemetry-resource-detector-container/LICENSE index a42588e10f..261eeb9e9f 100644 --- a/detectors/node/opentelemetry-resource-detector-container/LICENSE +++ b/detectors/node/opentelemetry-resource-detector-container/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2021] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/detectors/node/opentelemetry-resource-detector-gcp/LICENSE b/detectors/node/opentelemetry-resource-detector-gcp/LICENSE index 6b91a297c8..261eeb9e9f 100644 --- a/detectors/node/opentelemetry-resource-detector-gcp/LICENSE +++ b/detectors/node/opentelemetry-resource-detector-gcp/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2020] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/detectors/node/opentelemetry-resource-detector-github/LICENSE b/detectors/node/opentelemetry-resource-detector-github/LICENSE index e50e8c80f9..261eeb9e9f 100644 --- a/detectors/node/opentelemetry-resource-detector-github/LICENSE +++ b/detectors/node/opentelemetry-resource-detector-github/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/detectors/node/opentelemetry-resource-detector-instana/LICENSE b/detectors/node/opentelemetry-resource-detector-instana/LICENSE index 6b91a297c8..261eeb9e9f 100644 --- a/detectors/node/opentelemetry-resource-detector-instana/LICENSE +++ b/detectors/node/opentelemetry-resource-detector-instana/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2020] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/incubator/opentelemetry-sampler-aws-xray/LICENSE b/incubator/opentelemetry-sampler-aws-xray/LICENSE index e50e8c80f9..261eeb9e9f 100644 --- a/incubator/opentelemetry-sampler-aws-xray/LICENSE +++ b/incubator/opentelemetry-sampler-aws-xray/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/metapackages/auto-instrumentations-node/LICENSE b/metapackages/auto-instrumentations-node/LICENSE index e50e8c80f9..261eeb9e9f 100644 --- a/metapackages/auto-instrumentations-node/LICENSE +++ b/metapackages/auto-instrumentations-node/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/metapackages/auto-instrumentations-web/LICENSE b/metapackages/auto-instrumentations-web/LICENSE index e50e8c80f9..261eeb9e9f 100644 --- a/metapackages/auto-instrumentations-web/LICENSE +++ b/metapackages/auto-instrumentations-web/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/package-lock.json b/package-lock.json index 2f59bf0444..1b32aba25f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8690,8 +8690,18 @@ "link": true }, "node_modules/@opentelemetry/propagator-aws-xray": { - "resolved": "propagators/opentelemetry-propagator-aws-xray", - "link": true + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/propagator-aws-xray/-/propagator-aws-xray-1.3.1.tgz", + "integrity": "sha512-6fDMzFlt5r6VWv7MUd0eOpglXPFqykW8CnOuUxJ1VZyLy6mV1bzBlzpsqEmhx1bjvZYvH93vhGkQZqrm95mlrQ==", + "dependencies": { + "@opentelemetry/core": "^1.0.0" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": "^1.0.0" + } }, "node_modules/@opentelemetry/propagator-b3": { "version": "1.23.0", @@ -10578,6 +10588,7 @@ "version": "4.28.10", "resolved": "https://registry.npmjs.org/@types/ioredis/-/ioredis-4.28.10.tgz", "integrity": "sha512-69LyhUgrXdgcNDv7ogs1qXZomnfOEnSmrmMFqKgt1XMJxmoOSG/u3wYy13yACIfKuMJ8IhKgHafDO3sx19zVQQ==", + "dev": true, "dependencies": { "@types/node": "*" } @@ -34442,9 +34453,9 @@ } }, "node_modules/undici": { - "version": "6.10.1", - "resolved": "https://registry.npmjs.org/undici/-/undici-6.10.1.tgz", - "integrity": "sha512-kSzmWrOx3XBKTgPm4Tal8Hyl3yf+hzlA00SAf4goxv8LZYafKmS6gJD/7Fe5HH/DMNiFTRXvkwhLo7mUn5fuQQ==", + "version": "6.11.1", + "resolved": "https://registry.npmjs.org/undici/-/undici-6.11.1.tgz", + "integrity": "sha512-KyhzaLJnV1qa3BSHdj4AZ2ndqI0QWPxYzaIOio0WzcEJB9gvuysprJSLtpvc2D9mhR9jPDUk7xlJlZbH2KR5iw==", "dev": true, "engines": { "node": ">=18.0" @@ -36836,7 +36847,7 @@ "dependencies": { "@opentelemetry/core": "^1.8.0", "@opentelemetry/instrumentation": "^0.50.0", - "@opentelemetry/semantic-conventions": "^1.0.0" + "@opentelemetry/semantic-conventions": "^1.22.0" }, "devDependencies": { "@opentelemetry/api": "^1.3.0", @@ -37446,7 +37457,7 @@ "dependencies": { "@opentelemetry/core": "^1.8.0", "@opentelemetry/instrumentation": "^0.50.0", - "@opentelemetry/semantic-conventions": "^1.0.0" + "@opentelemetry/semantic-conventions": "^1.22.0" }, "devDependencies": { "@opentelemetry/api": "^1.3.0", @@ -37802,7 +37813,7 @@ "license": "Apache-2.0", "dependencies": { "@opentelemetry/core": "^1.8.0", - "@opentelemetry/instrumentation": "^0.49.1" + "@opentelemetry/instrumentation": "^0.50.0" }, "devDependencies": { "@opentelemetry/api": "^1.7.0", @@ -37816,10 +37827,10 @@ "rimraf": "5.0.5", "semver": "^7.6.0", "superagent": "8.0.9", - "test-all-versions": "6.0.0", + "test-all-versions": "6.1.0", "ts-mocha": "10.0.0", "typescript": "4.4.4", - "undici": "6.10.1" + "undici": "6.11.1" }, "engines": { "node": ">=14" @@ -37828,137 +37839,6 @@ "@opentelemetry/api": "^1.7.0" } }, - "plugins/node/instrumentation-undici/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "plugins/node/instrumentation-undici/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "plugins/node/instrumentation-undici/node_modules/cli-spinners": { - "version": "2.9.2", - "resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.9.2.tgz", - "integrity": "sha512-ywqV+5MmyL4E7ybXgKys4DugZbX0FC6LnwrhjuykIjnK9k8OQacQ7axGKnjDXWNhns0xot3bZI5h55H8yo9cJg==", - "dev": true, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "plugins/node/instrumentation-undici/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "plugins/node/instrumentation-undici/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "plugins/node/instrumentation-undici/node_modules/is-ci": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/is-ci/-/is-ci-3.0.1.tgz", - "integrity": "sha512-ZYvCgrefwqoQ6yTyYUbQu64HsITZ3NfKX1lzaEYdkTDcfKzzCI/wthRRYKkdjHKFVgNiXKAKm65Zo1pk2as/QQ==", - "dev": true, - "dependencies": { - "ci-info": "^3.2.0" - }, - "bin": { - "is-ci": "bin.js" - } - }, - "plugins/node/instrumentation-undici/node_modules/log-symbols": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", - "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", - "dev": true, - "dependencies": { - "chalk": "^4.1.0", - "is-unicode-supported": "^0.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "plugins/node/instrumentation-undici/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "plugins/node/instrumentation-undici/node_modules/test-all-versions": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/test-all-versions/-/test-all-versions-6.0.0.tgz", - "integrity": "sha512-/9wVTBRa7+arvItGinCYy/8+z7sHTsrs9cwEY/xAnzrkSEM7Tp2Cz49ewYZYuO1YYMLqxEaQp2g7Dnns7n7BGA==", - "dev": true, - "dependencies": { - "after-all-results": "^2.0.0", - "ansi-diff-stream": "^1.2.1", - "cli-spinners": "^2.9.2", - "deepmerge": "^4.3.1", - "import-fresh": "^3.3.0", - "is-ci": "^3.0.1", - "js-yaml": "^4.1.0", - "log-symbols": "^4.1.0", - "minimist": "^1.2.8", - "npm-package-versions": "^1.0.1", - "once": "^1.4.0", - "parse-env-string": "^1.0.1", - "resolve": "^1.22.8", - "semver": "^7.5.4", - "spawn-npm-install": "^1.2.0", - "which": "^2.0.2" - }, - "bin": { - "tav": "index.js" - }, - "engines": { - "node": ">=14" - } - }, "plugins/node/opentelemetry-instrumentation-aws-lambda": { "name": "@opentelemetry/instrumentation-aws-lambda", "version": "0.40.0", @@ -38409,8 +38289,7 @@ "dependencies": { "@opentelemetry/instrumentation": "^0.50.0", "@opentelemetry/redis-common": "^0.36.1", - "@opentelemetry/semantic-conventions": "^1.0.0", - "@types/ioredis4": "npm:@types/ioredis@^4.28.10" + "@opentelemetry/semantic-conventions": "^1.0.0" }, "devDependencies": { "@opentelemetry/api": "^1.3.0", @@ -38418,6 +38297,7 @@ "@opentelemetry/contrib-test-utils": "^0.38.0", "@opentelemetry/sdk-trace-base": "^1.8.0", "@opentelemetry/sdk-trace-node": "^1.8.0", + "@types/ioredis4": "npm:@types/ioredis@4.28.10", "@types/mocha": "7.0.2", "@types/node": "18.6.5", "@types/sinon": "10.0.18", @@ -38444,7 +38324,7 @@ "license": "Apache-2.0", "dependencies": { "@opentelemetry/instrumentation": "^0.50.0", - "@opentelemetry/semantic-conventions": "^1.0.0" + "@opentelemetry/semantic-conventions": "^1.22.0" }, "devDependencies": { "@opentelemetry/api": "^1.3.0", @@ -38545,7 +38425,7 @@ "dependencies": { "@opentelemetry/instrumentation": "^0.50.0", "@opentelemetry/sdk-metrics": "^1.9.1", - "@opentelemetry/semantic-conventions": "^1.0.0" + "@opentelemetry/semantic-conventions": "^1.22.0" }, "devDependencies": { "@opentelemetry/api": "^1.3.0", @@ -38738,7 +38618,7 @@ "license": "Apache-2.0", "dependencies": { "@opentelemetry/instrumentation": "^0.50.0", - "@opentelemetry/semantic-conventions": "^1.0.0", + "@opentelemetry/semantic-conventions": "^1.22.0", "@types/mysql": "2.15.22" }, "devDependencies": { @@ -38771,7 +38651,7 @@ "license": "Apache-2.0", "dependencies": { "@opentelemetry/instrumentation": "^0.50.0", - "@opentelemetry/semantic-conventions": "^1.0.0", + "@opentelemetry/semantic-conventions": "^1.22.0", "@opentelemetry/sql-common": "^0.40.0" }, "devDependencies": { @@ -39047,7 +38927,7 @@ "dependencies": { "@opentelemetry/instrumentation": "^0.50.0", "@opentelemetry/redis-common": "^0.36.1", - "@opentelemetry/semantic-conventions": "^1.0.0" + "@opentelemetry/semantic-conventions": "^1.22.0" }, "devDependencies": { "@opentelemetry/api": "^1.3.0", @@ -39081,7 +38961,7 @@ "dependencies": { "@opentelemetry/instrumentation": "^0.50.0", "@opentelemetry/redis-common": "^0.36.1", - "@opentelemetry/semantic-conventions": "^1.0.0" + "@opentelemetry/semantic-conventions": "^1.22.0" }, "devDependencies": { "@opentelemetry/api": "^1.3.0", @@ -39129,7 +39009,7 @@ "dependencies": { "@opentelemetry/core": "^1.8.0", "@opentelemetry/instrumentation": "^0.50.0", - "@opentelemetry/semantic-conventions": "^1.0.0" + "@opentelemetry/semantic-conventions": "^1.22.0" }, "devDependencies": { "@opentelemetry/api": "^1.3.0", @@ -39195,7 +39075,7 @@ "license": "Apache-2.0", "dependencies": { "@opentelemetry/instrumentation": "^0.50.0", - "@opentelemetry/semantic-conventions": "^1.0.0" + "@opentelemetry/semantic-conventions": "^1.22.0" }, "devDependencies": { "@opentelemetry/api": "^1.3.0", @@ -39218,44 +39098,12 @@ "@opentelemetry/api": "^1.3.0" } }, - "plugins/node/opentelemetry-instrumentation-undici": { - "name": "@opentelemetry/instrumentation-undici", - "version": "0.33.0", - "extraneous": true, - "license": "Apache-2.0", - "dependencies": { - "@opentelemetry/core": "^1.8.0", - "@opentelemetry/instrumentation": "^0.49.1" - }, - "devDependencies": { - "@opentelemetry/api": "^1.3.0", - "@opentelemetry/sdk-metrics": "^1.8.0", - "@opentelemetry/sdk-trace-base": "^1.8.0", - "@opentelemetry/sdk-trace-node": "^1.8.0", - "@types/mocha": "7.0.2", - "@types/node": "18.6.5", - "mocha": "7.2.0", - "nyc": "15.1.0", - "rimraf": "5.0.5", - "semver": "^7.6.0", - "superagent": "8.0.9", - "test-all-versions": "6.0.0", - "ts-mocha": "10.0.0", - "typescript": "4.4.4", - "undici": "^6.7.0" - }, - "engines": { - "node": ">=14" - }, - "peerDependencies": { - "@opentelemetry/api": "^1.3.0" - } - }, "plugins/node/opentelemetry-instrumentation-winston": { "name": "@opentelemetry/instrumentation-winston", "version": "0.36.0", "license": "Apache-2.0", "dependencies": { + "@opentelemetry/api-logs": "^0.50.0", "@opentelemetry/instrumentation": "^0.50.0" }, "devDependencies": { @@ -39474,46 +39322,6 @@ "react": "^16.13.1 || ^17.0.0" } }, - "propagators/opentelemetry-propagator-aws-xray": { - "name": "@opentelemetry/propagator-aws-xray", - "version": "1.3.1", - "license": "Apache-2.0", - "dependencies": { - "@opentelemetry/core": "^1.0.0" - }, - "devDependencies": { - "@jsdevtools/coverage-istanbul-loader": "3.0.5", - "@opentelemetry/api": "^1.0.0", - "@types/mocha": "8.2.3", - "@types/node": "18.6.5", - "@types/webpack-env": "1.16.2", - "karma": "6.3.16", - "karma-chrome-launcher": "^3.1.1", - "karma-coverage-istanbul-reporter": "3.0.3", - "karma-mocha": "2.0.1", - "karma-spec-reporter": "0.0.36", - "karma-webpack": "4.0.2", - "mocha": "7.2.0", - "nyc": "15.1.0", - "rimraf": "5.0.5", - "ts-loader": "8.3.0", - "ts-mocha": "10.0.0", - "typescript": "4.4.4", - "webpack": "4.46.0" - }, - "engines": { - "node": ">=14" - }, - "peerDependencies": { - "@opentelemetry/api": "^1.0.0" - } - }, - "propagators/opentelemetry-propagator-aws-xray/node_modules/@types/mocha": { - "version": "8.2.3", - "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-8.2.3.tgz", - "integrity": "sha512-ekGvFhFgrc2zYQoX4JeZPmVzZxw6Dtllga7iGHzfbYIYkAMUx/sAFP2GdFpLff+vdHXu5fl7WX9AT+TtqYcsyw==", - "dev": true - }, "propagators/opentelemetry-propagator-grpc-census-binary": { "name": "@opentelemetry/propagator-grpc-census-binary", "version": "0.27.1", @@ -46368,7 +46176,7 @@ "@opentelemetry/contrib-test-utils": "^0.38.0", "@opentelemetry/core": "^1.8.0", "@opentelemetry/instrumentation": "^0.50.0", - "@opentelemetry/semantic-conventions": "^1.0.0", + "@opentelemetry/semantic-conventions": "^1.22.0", "@types/amqplib": "^0.5.17", "@types/lodash": "4.14.199", "@types/mocha": "8.2.3", @@ -46895,7 +46703,7 @@ "@opentelemetry/sdk-trace-base": "^1.8.0", "@opentelemetry/sdk-trace-node": "^1.8.0", "@opentelemetry/semantic-conventions": "^1.0.0", - "@types/ioredis4": "npm:@types/ioredis@^4.28.10", + "@types/ioredis4": "npm:@types/ioredis@4.28.10", "@types/mocha": "7.0.2", "@types/node": "18.6.5", "@types/sinon": "10.0.18", @@ -47192,7 +47000,7 @@ "@opentelemetry/instrumentation": "^0.50.0", "@opentelemetry/sdk-trace-base": "^1.8.0", "@opentelemetry/sdk-trace-node": "^1.8.0", - "@opentelemetry/semantic-conventions": "^1.0.0", + "@opentelemetry/semantic-conventions": "^1.22.0", "@types/mocha": "7.0.2", "@types/node": "18.6.5", "knex": "0.95.9", @@ -47327,7 +47135,7 @@ "@opentelemetry/sdk-metrics": "^1.9.1", "@opentelemetry/sdk-trace-base": "^1.8.0", "@opentelemetry/sdk-trace-node": "^1.8.0", - "@opentelemetry/semantic-conventions": "^1.0.0", + "@opentelemetry/semantic-conventions": "^1.22.0", "@types/bson": "4.0.5", "@types/mocha": "7.0.2", "@types/mongodb": "3.6.20", @@ -47455,7 +47263,7 @@ "@opentelemetry/core": "^1.8.0", "@opentelemetry/instrumentation": "^0.50.0", "@opentelemetry/sdk-trace-base": "^1.8.0", - "@opentelemetry/semantic-conventions": "^1.0.0", + "@opentelemetry/semantic-conventions": "^1.22.0", "@types/mocha": "8.2.3", "@types/node": "18.6.5", "expect": "29.2.0", @@ -47485,7 +47293,7 @@ "@opentelemetry/instrumentation": "^0.50.0", "@opentelemetry/sdk-metrics": "^1.8.0", "@opentelemetry/sdk-trace-base": "^1.8.0", - "@opentelemetry/semantic-conventions": "^1.0.0", + "@opentelemetry/semantic-conventions": "^1.22.0", "@types/mocha": "7.0.2", "@types/mysql": "2.15.22", "@types/node": "18.6.5", @@ -47507,7 +47315,7 @@ "@opentelemetry/contrib-test-utils": "^0.38.0", "@opentelemetry/instrumentation": "^0.50.0", "@opentelemetry/sdk-trace-base": "^1.8.0", - "@opentelemetry/semantic-conventions": "^1.0.0", + "@opentelemetry/semantic-conventions": "^1.22.0", "@opentelemetry/sql-common": "^0.40.0", "@types/mocha": "7.0.2", "@types/node": "18.6.5", @@ -47713,7 +47521,7 @@ "@opentelemetry/redis-common": "^0.36.1", "@opentelemetry/sdk-trace-base": "^1.8.0", "@opentelemetry/sdk-trace-node": "^1.8.0", - "@opentelemetry/semantic-conventions": "^1.0.0", + "@opentelemetry/semantic-conventions": "^1.22.0", "@types/mocha": "7.0.2", "@types/node": "18.6.5", "@types/redis": "2.8.32", @@ -47738,7 +47546,7 @@ "@opentelemetry/redis-common": "^0.36.1", "@opentelemetry/sdk-trace-base": "^1.8.0", "@opentelemetry/sdk-trace-node": "^1.8.0", - "@opentelemetry/semantic-conventions": "^1.0.0", + "@opentelemetry/semantic-conventions": "^1.22.0", "@types/mocha": "7.0.2", "@types/node": "18.6.5", "cross-env": "7.0.3", @@ -47776,7 +47584,7 @@ "@opentelemetry/instrumentation": "^0.50.0", "@opentelemetry/sdk-trace-base": "^1.8.0", "@opentelemetry/sdk-trace-node": "^1.8.0", - "@opentelemetry/semantic-conventions": "^1.0.0", + "@opentelemetry/semantic-conventions": "^1.22.0", "@types/mocha": "7.0.2", "@types/node": "18.6.5", "@types/restify": "4.3.10", @@ -47825,7 +47633,7 @@ "@opentelemetry/instrumentation": "^0.50.0", "@opentelemetry/sdk-trace-base": "^1.8.0", "@opentelemetry/sdk-trace-node": "^1.8.0", - "@opentelemetry/semantic-conventions": "^1.0.0", + "@opentelemetry/semantic-conventions": "^1.22.0", "@types/mocha": "7.0.2", "@types/node": "18.6.5", "mocha": "7.2.0", @@ -48086,7 +47894,7 @@ "requires": { "@opentelemetry/api": "^1.7.0", "@opentelemetry/core": "^1.8.0", - "@opentelemetry/instrumentation": "^0.49.1", + "@opentelemetry/instrumentation": "^0.50.0", "@opentelemetry/sdk-metrics": "^1.8.0", "@opentelemetry/sdk-trace-base": "^1.8.0", "@opentelemetry/sdk-trace-node": "^1.8.0", @@ -48097,104 +47905,10 @@ "rimraf": "5.0.5", "semver": "^7.6.0", "superagent": "8.0.9", - "test-all-versions": "6.0.0", + "test-all-versions": "6.1.0", "ts-mocha": "10.0.0", "typescript": "4.4.4", - "undici": "6.10.1" - }, - "dependencies": { - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "cli-spinners": { - "version": "2.9.2", - "resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.9.2.tgz", - "integrity": "sha512-ywqV+5MmyL4E7ybXgKys4DugZbX0FC6LnwrhjuykIjnK9k8OQacQ7axGKnjDXWNhns0xot3bZI5h55H8yo9cJg==", - "dev": true - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "is-ci": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/is-ci/-/is-ci-3.0.1.tgz", - "integrity": "sha512-ZYvCgrefwqoQ6yTyYUbQu64HsITZ3NfKX1lzaEYdkTDcfKzzCI/wthRRYKkdjHKFVgNiXKAKm65Zo1pk2as/QQ==", - "dev": true, - "requires": { - "ci-info": "^3.2.0" - } - }, - "log-symbols": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", - "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", - "dev": true, - "requires": { - "chalk": "^4.1.0", - "is-unicode-supported": "^0.1.0" - } - }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - }, - "test-all-versions": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/test-all-versions/-/test-all-versions-6.0.0.tgz", - "integrity": "sha512-/9wVTBRa7+arvItGinCYy/8+z7sHTsrs9cwEY/xAnzrkSEM7Tp2Cz49ewYZYuO1YYMLqxEaQp2g7Dnns7n7BGA==", - "dev": true, - "requires": { - "after-all-results": "^2.0.0", - "ansi-diff-stream": "^1.2.1", - "cli-spinners": "^2.9.2", - "deepmerge": "^4.3.1", - "import-fresh": "^3.3.0", - "is-ci": "^3.0.1", - "js-yaml": "^4.1.0", - "log-symbols": "^4.1.0", - "minimist": "^1.2.8", - "npm-package-versions": "^1.0.1", - "once": "^1.4.0", - "parse-env-string": "^1.0.1", - "resolve": "^1.22.8", - "semver": "^7.5.4", - "spawn-npm-install": "^1.2.0", - "which": "^2.0.2" - } - } + "undici": "6.11.1" } }, "@opentelemetry/instrumentation-user-interaction": { @@ -48239,6 +47953,7 @@ "version": "file:plugins/node/opentelemetry-instrumentation-winston", "requires": { "@opentelemetry/api": "^1.3.0", + "@opentelemetry/api-logs": "^0.50.0", "@opentelemetry/context-async-hooks": "^1.21.0", "@opentelemetry/instrumentation": "^0.50.0", "@opentelemetry/sdk-trace-base": "^1.21.0", @@ -48379,35 +48094,11 @@ } }, "@opentelemetry/propagator-aws-xray": { - "version": "file:propagators/opentelemetry-propagator-aws-xray", + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/propagator-aws-xray/-/propagator-aws-xray-1.3.1.tgz", + "integrity": "sha512-6fDMzFlt5r6VWv7MUd0eOpglXPFqykW8CnOuUxJ1VZyLy6mV1bzBlzpsqEmhx1bjvZYvH93vhGkQZqrm95mlrQ==", "requires": { - "@jsdevtools/coverage-istanbul-loader": "3.0.5", - "@opentelemetry/api": "^1.0.0", - "@opentelemetry/core": "^1.0.0", - "@types/mocha": "8.2.3", - "@types/node": "18.6.5", - "@types/webpack-env": "1.16.2", - "karma": "6.3.16", - "karma-chrome-launcher": "^3.1.1", - "karma-coverage-istanbul-reporter": "3.0.3", - "karma-mocha": "2.0.1", - "karma-spec-reporter": "0.0.36", - "karma-webpack": "4.0.2", - "mocha": "7.2.0", - "nyc": "15.1.0", - "rimraf": "5.0.5", - "ts-loader": "8.3.0", - "ts-mocha": "10.0.0", - "typescript": "4.4.4", - "webpack": "4.46.0" - }, - "dependencies": { - "@types/mocha": { - "version": "8.2.3", - "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-8.2.3.tgz", - "integrity": "sha512-ekGvFhFgrc2zYQoX4JeZPmVzZxw6Dtllga7iGHzfbYIYkAMUx/sAFP2GdFpLff+vdHXu5fl7WX9AT+TtqYcsyw==", - "dev": true - } + "@opentelemetry/core": "^1.0.0" } }, "@opentelemetry/propagator-b3": { @@ -50341,6 +50032,7 @@ "version": "npm:@types/ioredis@4.28.10", "resolved": "https://registry.npmjs.org/@types/ioredis/-/ioredis-4.28.10.tgz", "integrity": "sha512-69LyhUgrXdgcNDv7ogs1qXZomnfOEnSmrmMFqKgt1XMJxmoOSG/u3wYy13yACIfKuMJ8IhKgHafDO3sx19zVQQ==", + "dev": true, "requires": { "@types/node": "*" } @@ -69201,9 +68893,9 @@ } }, "undici": { - "version": "6.10.1", - "resolved": "https://registry.npmjs.org/undici/-/undici-6.10.1.tgz", - "integrity": "sha512-kSzmWrOx3XBKTgPm4Tal8Hyl3yf+hzlA00SAf4goxv8LZYafKmS6gJD/7Fe5HH/DMNiFTRXvkwhLo7mUn5fuQQ==", + "version": "6.11.1", + "resolved": "https://registry.npmjs.org/undici/-/undici-6.11.1.tgz", + "integrity": "sha512-KyhzaLJnV1qa3BSHdj4AZ2ndqI0QWPxYzaIOio0WzcEJB9gvuysprJSLtpvc2D9mhR9jPDUk7xlJlZbH2KR5iw==", "dev": true }, "undici-types": { diff --git a/packages/opentelemetry-host-metrics/LICENSE b/packages/opentelemetry-host-metrics/LICENSE index e50e8c80f9..261eeb9e9f 100644 --- a/packages/opentelemetry-host-metrics/LICENSE +++ b/packages/opentelemetry-host-metrics/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/packages/opentelemetry-id-generator-aws-xray/LICENSE b/packages/opentelemetry-id-generator-aws-xray/LICENSE index e50e8c80f9..261eeb9e9f 100644 --- a/packages/opentelemetry-id-generator-aws-xray/LICENSE +++ b/packages/opentelemetry-id-generator-aws-xray/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/packages/opentelemetry-propagation-utils/LICENSE b/packages/opentelemetry-propagation-utils/LICENSE index e50e8c80f9..261eeb9e9f 100644 --- a/packages/opentelemetry-propagation-utils/LICENSE +++ b/packages/opentelemetry-propagation-utils/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/packages/opentelemetry-redis-common/LICENSE b/packages/opentelemetry-redis-common/LICENSE index e50e8c80f9..261eeb9e9f 100644 --- a/packages/opentelemetry-redis-common/LICENSE +++ b/packages/opentelemetry-redis-common/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/packages/opentelemetry-sql-common/LICENSE b/packages/opentelemetry-sql-common/LICENSE index e50e8c80f9..261eeb9e9f 100644 --- a/packages/opentelemetry-sql-common/LICENSE +++ b/packages/opentelemetry-sql-common/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/packages/opentelemetry-test-utils/LICENSE b/packages/opentelemetry-test-utils/LICENSE index e50e8c80f9..261eeb9e9f 100644 --- a/packages/opentelemetry-test-utils/LICENSE +++ b/packages/opentelemetry-test-utils/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/packages/winston-transport/LICENSE b/packages/winston-transport/LICENSE index e50e8c80f9..261eeb9e9f 100644 --- a/packages/winston-transport/LICENSE +++ b/packages/winston-transport/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/packages/winston-transport/src/OpenTelemetryTransportV3.ts b/packages/winston-transport/src/OpenTelemetryTransportV3.ts index fe759676e9..a7e164adce 100644 --- a/packages/winston-transport/src/OpenTelemetryTransportV3.ts +++ b/packages/winston-transport/src/OpenTelemetryTransportV3.ts @@ -27,17 +27,15 @@ export class OpenTelemetryTransportV3 extends TransportStream { this._logger = logs.getLogger('@opentelemetry/winston-transport', VERSION); } - public override log(info: any, next: () => void) { + public override log(info: any, callback: () => void) { try { emitLogRecord(info, this._logger); } catch (error) { this.emit('warn', error); } - setImmediate(() => { - this.emit('logged', info); - }); - if (next) { - setImmediate(next); + this.emit('logged', info); + if (callback) { + callback(); } } } diff --git a/plugins/node/instrumentation-amqplib/LICENSE b/plugins/node/instrumentation-amqplib/LICENSE index e50e8c80f9..261eeb9e9f 100644 --- a/plugins/node/instrumentation-amqplib/LICENSE +++ b/plugins/node/instrumentation-amqplib/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/plugins/node/instrumentation-amqplib/README.md b/plugins/node/instrumentation-amqplib/README.md index 3e931474ef..5d4933db7e 100644 --- a/plugins/node/instrumentation-amqplib/README.md +++ b/plugins/node/instrumentation-amqplib/README.md @@ -81,6 +81,27 @@ The instrumentation's config `publishHook`, `publishConfirmHook`, `consumeHook` The `moduleVersionAttributeName` config option is removed. To add the amqplib package version to spans, use the `moduleVersion` attribute in hook info for `publishHook` and `consumeHook` functions. +## Semantic Conventions + +This package uses `@opentelemetry/semantic-conventions` version `1.22+`, which implements Semantic Convention [Version 1.7.0](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.7.0/semantic_conventions/README.md) + +Attributes collected: + +| Attribute | Short Description | +| -------------------------------- | ---------------------------------------------------------------------- | +| `messaging.destination` | The message destination name. | +| `messaging.destination_kind` | The kind of message destination. | +| `messaging.rabbitmq.routing_key` | RabbitMQ message routing key. | +| `messaging.operation` | A string identifying the kind of message consumption. | +| `messaging.message_id` | A value used by the messaging system as an identifier for the message. | +| `messaging.conversation_id` | The ID identifying the conversation to which the message belongs. | +| `messaging.protocol` | The name of the transport protocol. | +| `messaging.protocol_version` | The version of the transport protocol. | +| `messaging.system` | A string identifying the messaging system. | +| `messaging.url` | The connection string. | +| `net.peer.name` | Remote hostname or similar. | +| `net.peer.port` | Remote port number. | + ## Useful links - For more information on OpenTelemetry, visit: diff --git a/plugins/node/instrumentation-amqplib/package.json b/plugins/node/instrumentation-amqplib/package.json index 00d8c4fc34..5b7202cf4a 100644 --- a/plugins/node/instrumentation-amqplib/package.json +++ b/plugins/node/instrumentation-amqplib/package.json @@ -46,7 +46,7 @@ "dependencies": { "@opentelemetry/core": "^1.8.0", "@opentelemetry/instrumentation": "^0.50.0", - "@opentelemetry/semantic-conventions": "^1.0.0" + "@opentelemetry/semantic-conventions": "^1.22.0" }, "devDependencies": { "@opentelemetry/api": "^1.3.0", diff --git a/plugins/node/instrumentation-amqplib/src/amqplib.ts b/plugins/node/instrumentation-amqplib/src/amqplib.ts index 17fd6e20b6..16224096fc 100644 --- a/plugins/node/instrumentation-amqplib/src/amqplib.ts +++ b/plugins/node/instrumentation-amqplib/src/amqplib.ts @@ -36,9 +36,14 @@ import { safeExecuteInTheMiddle, } from '@opentelemetry/instrumentation'; import { - SemanticAttributes, - MessagingOperationValues, - MessagingDestinationKindValues, + SEMATTRS_MESSAGING_DESTINATION, + SEMATTRS_MESSAGING_DESTINATION_KIND, + MESSAGINGDESTINATIONKINDVALUES_TOPIC, + SEMATTRS_MESSAGING_RABBITMQ_ROUTING_KEY, + SEMATTRS_MESSAGING_OPERATION, + MESSAGINGOPERATIONVALUES_PROCESS, + SEMATTRS_MESSAGING_MESSAGE_ID, + SEMATTRS_MESSAGING_CONVERSATION_ID, } from '@opentelemetry/semantic-conventions'; import type { Connection, @@ -415,16 +420,13 @@ export class AmqplibInstrumentation extends InstrumentationBase { kind: SpanKind.CONSUMER, attributes: { ...channel?.connection?.[CONNECTION_ATTRIBUTES], - [SemanticAttributes.MESSAGING_DESTINATION]: exchange, - [SemanticAttributes.MESSAGING_DESTINATION_KIND]: - MessagingDestinationKindValues.TOPIC, - [SemanticAttributes.MESSAGING_RABBITMQ_ROUTING_KEY]: - msg.fields?.routingKey, - [SemanticAttributes.MESSAGING_OPERATION]: - MessagingOperationValues.PROCESS, - [SemanticAttributes.MESSAGING_MESSAGE_ID]: - msg?.properties.messageId, - [SemanticAttributes.MESSAGING_CONVERSATION_ID]: + [SEMATTRS_MESSAGING_DESTINATION]: exchange, + [SEMATTRS_MESSAGING_DESTINATION_KIND]: + MESSAGINGDESTINATIONKINDVALUES_TOPIC, + [SEMATTRS_MESSAGING_RABBITMQ_ROUTING_KEY]: msg.fields?.routingKey, + [SEMATTRS_MESSAGING_OPERATION]: MESSAGINGOPERATIONVALUES_PROCESS, + [SEMATTRS_MESSAGING_MESSAGE_ID]: msg?.properties.messageId, + [SEMATTRS_MESSAGING_CONVERSATION_ID]: msg?.properties.correlationId, }, }, @@ -636,13 +638,12 @@ export class AmqplibInstrumentation extends InstrumentationBase { kind: SpanKind.PRODUCER, attributes: { ...channel.connection[CONNECTION_ATTRIBUTES], - [SemanticAttributes.MESSAGING_DESTINATION]: exchange, - [SemanticAttributes.MESSAGING_DESTINATION_KIND]: - MessagingDestinationKindValues.TOPIC, - [SemanticAttributes.MESSAGING_RABBITMQ_ROUTING_KEY]: routingKey, - [SemanticAttributes.MESSAGING_MESSAGE_ID]: options?.messageId, - [SemanticAttributes.MESSAGING_CONVERSATION_ID]: - options?.correlationId, + [SEMATTRS_MESSAGING_DESTINATION]: exchange, + [SEMATTRS_MESSAGING_DESTINATION_KIND]: + MESSAGINGDESTINATIONKINDVALUES_TOPIC, + [SEMATTRS_MESSAGING_RABBITMQ_ROUTING_KEY]: routingKey, + [SEMATTRS_MESSAGING_MESSAGE_ID]: options?.messageId, + [SEMATTRS_MESSAGING_CONVERSATION_ID]: options?.correlationId, }, } ); diff --git a/plugins/node/instrumentation-amqplib/src/utils.ts b/plugins/node/instrumentation-amqplib/src/utils.ts index d690e75bd7..2f0db1ad62 100644 --- a/plugins/node/instrumentation-amqplib/src/utils.ts +++ b/plugins/node/instrumentation-amqplib/src/utils.ts @@ -19,10 +19,17 @@ import { diag, HrTime, Span, - SpanAttributes, - SpanAttributeValue, + Attributes, + AttributeValue, } from '@opentelemetry/api'; -import { SemanticAttributes } from '@opentelemetry/semantic-conventions'; +import { + SEMATTRS_MESSAGING_PROTOCOL, + SEMATTRS_MESSAGING_PROTOCOL_VERSION, + SEMATTRS_MESSAGING_SYSTEM, + SEMATTRS_MESSAGING_URL, + SEMATTRS_NET_PEER_NAME, + SEMATTRS_NET_PEER_PORT, +} from '@opentelemetry/semantic-conventions'; import type * as amqp from 'amqplib'; export const MESSAGE_STORED_SPAN: unique symbol = Symbol( @@ -41,9 +48,9 @@ export const CONNECTION_ATTRIBUTES: unique symbol = Symbol( export type InstrumentationPublishChannel = ( | amqp.Channel | amqp.ConfirmChannel -) & { connection: { [CONNECTION_ATTRIBUTES]: SpanAttributes } }; +) & { connection: { [CONNECTION_ATTRIBUTES]: Attributes } }; export type InstrumentationConsumeChannel = amqp.Channel & { - connection: { [CONNECTION_ATTRIBUTES]: SpanAttributes }; + connection: { [CONNECTION_ATTRIBUTES]: Attributes }; [CHANNEL_SPANS_NOT_ENDED]?: { msg: amqp.ConsumeMessage; timeOfConsume: HrTime; @@ -93,9 +100,9 @@ const getHostname = (hostnameFromUrl: string | undefined): string => { const extractConnectionAttributeOrLog = ( url: string | amqp.Options.Connect, attributeKey: string, - attributeValue: SpanAttributeValue, + attributeValue: AttributeValue, nameForLog: string -): SpanAttributes => { +): Attributes => { if (attributeValue) { return { [attributeKey]: attributeValue }; } else { @@ -111,11 +118,11 @@ const extractConnectionAttributeOrLog = ( export const getConnectionAttributesFromServer = ( conn: amqp.Connection['connection'] -): SpanAttributes => { +): Attributes => { const product = conn.serverProperties.product?.toLowerCase?.(); if (product) { return { - [SemanticAttributes.MESSAGING_SYSTEM]: product, + [SEMATTRS_MESSAGING_SYSTEM]: product, }; } else { return {}; @@ -124,9 +131,9 @@ export const getConnectionAttributesFromServer = ( export const getConnectionAttributesFromUrl = ( url: string | amqp.Options.Connect -): SpanAttributes => { - const attributes: SpanAttributes = { - [SemanticAttributes.MESSAGING_PROTOCOL_VERSION]: '0.9.1', // this is the only protocol supported by the instrumented library +): Attributes => { + const attributes: Attributes = { + [SEMATTRS_MESSAGING_PROTOCOL_VERSION]: '0.9.1', // this is the only protocol supported by the instrumented library }; url = url || 'amqp://localhost'; @@ -137,7 +144,7 @@ export const getConnectionAttributesFromUrl = ( Object.assign(attributes, { ...extractConnectionAttributeOrLog( url, - SemanticAttributes.MESSAGING_PROTOCOL, + SEMATTRS_MESSAGING_PROTOCOL, protocol, 'protocol' ), @@ -147,7 +154,7 @@ export const getConnectionAttributesFromUrl = ( Object.assign(attributes, { ...extractConnectionAttributeOrLog( url, - SemanticAttributes.NET_PEER_NAME, + SEMATTRS_NET_PEER_NAME, hostname, 'hostname' ), @@ -157,14 +164,14 @@ export const getConnectionAttributesFromUrl = ( Object.assign(attributes, { ...extractConnectionAttributeOrLog( url, - SemanticAttributes.NET_PEER_PORT, + SEMATTRS_NET_PEER_PORT, port, 'port' ), }); } else { const censoredUrl = censorPassword(url); - attributes[SemanticAttributes.MESSAGING_URL] = censoredUrl; + attributes[SEMATTRS_MESSAGING_URL] = censoredUrl; try { const urlParts = new URL(censoredUrl); @@ -172,7 +179,7 @@ export const getConnectionAttributesFromUrl = ( Object.assign(attributes, { ...extractConnectionAttributeOrLog( censoredUrl, - SemanticAttributes.MESSAGING_PROTOCOL, + SEMATTRS_MESSAGING_PROTOCOL, protocol, 'protocol' ), @@ -182,7 +189,7 @@ export const getConnectionAttributesFromUrl = ( Object.assign(attributes, { ...extractConnectionAttributeOrLog( censoredUrl, - SemanticAttributes.NET_PEER_NAME, + SEMATTRS_NET_PEER_NAME, hostname, 'hostname' ), @@ -195,7 +202,7 @@ export const getConnectionAttributesFromUrl = ( Object.assign(attributes, { ...extractConnectionAttributeOrLog( censoredUrl, - SemanticAttributes.NET_PEER_PORT, + SEMATTRS_NET_PEER_PORT, port, 'port' ), diff --git a/plugins/node/instrumentation-amqplib/test/amqplib-callbacks.test.ts b/plugins/node/instrumentation-amqplib/test/amqplib-callbacks.test.ts index 9f2ab1d81e..533b5d9942 100644 --- a/plugins/node/instrumentation-amqplib/test/amqplib-callbacks.test.ts +++ b/plugins/node/instrumentation-amqplib/test/amqplib-callbacks.test.ts @@ -25,8 +25,16 @@ registerInstrumentationTesting(new AmqplibInstrumentation()); import * as amqpCallback from 'amqplib/callback_api'; import { - MessagingDestinationKindValues, - SemanticAttributes, + MESSAGINGDESTINATIONKINDVALUES_TOPIC, + SEMATTRS_MESSAGING_DESTINATION, + SEMATTRS_MESSAGING_DESTINATION_KIND, + SEMATTRS_MESSAGING_PROTOCOL, + SEMATTRS_MESSAGING_PROTOCOL_VERSION, + SEMATTRS_MESSAGING_RABBITMQ_ROUTING_KEY, + SEMATTRS_MESSAGING_SYSTEM, + SEMATTRS_MESSAGING_URL, + SEMATTRS_NET_PEER_NAME, + SEMATTRS_NET_PEER_PORT, } from '@opentelemetry/semantic-conventions'; import { Baggage, context, propagation, SpanKind } from '@opentelemetry/api'; import { asyncConfirmSend, asyncConsume, shouldTest } from './utils'; @@ -127,67 +135,63 @@ describe('amqplib instrumentation callback model', () => { // assert publish span expect(publishSpan.kind).toEqual(SpanKind.PRODUCER); + expect(publishSpan.attributes[SEMATTRS_MESSAGING_SYSTEM]).toEqual( + 'rabbitmq' + ); + expect(publishSpan.attributes[SEMATTRS_MESSAGING_DESTINATION]).toEqual( + '' + ); // according to spec: "This will be an empty string if the default exchange is used" expect( - publishSpan.attributes[SemanticAttributes.MESSAGING_SYSTEM] - ).toEqual('rabbitmq'); - expect( - publishSpan.attributes[SemanticAttributes.MESSAGING_DESTINATION] - ).toEqual(''); // according to spec: "This will be an empty string if the default exchange is used" - expect( - publishSpan.attributes[SemanticAttributes.MESSAGING_DESTINATION_KIND] - ).toEqual(MessagingDestinationKindValues.TOPIC); + publishSpan.attributes[SEMATTRS_MESSAGING_DESTINATION_KIND] + ).toEqual(MESSAGINGDESTINATIONKINDVALUES_TOPIC); expect( - publishSpan.attributes[ - SemanticAttributes.MESSAGING_RABBITMQ_ROUTING_KEY - ] + publishSpan.attributes[SEMATTRS_MESSAGING_RABBITMQ_ROUTING_KEY] ).toEqual(queueName); + expect(publishSpan.attributes[SEMATTRS_MESSAGING_PROTOCOL]).toEqual( + 'AMQP' + ); expect( - publishSpan.attributes[SemanticAttributes.MESSAGING_PROTOCOL] - ).toEqual('AMQP'); - expect( - publishSpan.attributes[SemanticAttributes.MESSAGING_PROTOCOL_VERSION] + publishSpan.attributes[SEMATTRS_MESSAGING_PROTOCOL_VERSION] ).toEqual('0.9.1'); - expect( - publishSpan.attributes[SemanticAttributes.MESSAGING_URL] - ).toEqual(censoredUrl); - expect( - publishSpan.attributes[SemanticAttributes.NET_PEER_NAME] - ).toEqual(TEST_RABBITMQ_HOST); - expect( - publishSpan.attributes[SemanticAttributes.NET_PEER_PORT] - ).toEqual(TEST_RABBITMQ_PORT); + expect(publishSpan.attributes[SEMATTRS_MESSAGING_URL]).toEqual( + censoredUrl + ); + expect(publishSpan.attributes[SEMATTRS_NET_PEER_NAME]).toEqual( + TEST_RABBITMQ_HOST + ); + expect(publishSpan.attributes[SEMATTRS_NET_PEER_PORT]).toEqual( + TEST_RABBITMQ_PORT + ); // assert consume span expect(consumeSpan.kind).toEqual(SpanKind.CONSUMER); + expect(consumeSpan.attributes[SEMATTRS_MESSAGING_SYSTEM]).toEqual( + 'rabbitmq' + ); + expect(consumeSpan.attributes[SEMATTRS_MESSAGING_DESTINATION]).toEqual( + '' + ); // according to spec: "This will be an empty string if the default exchange is used" expect( - consumeSpan.attributes[SemanticAttributes.MESSAGING_SYSTEM] - ).toEqual('rabbitmq'); - expect( - consumeSpan.attributes[SemanticAttributes.MESSAGING_DESTINATION] - ).toEqual(''); // according to spec: "This will be an empty string if the default exchange is used" - expect( - consumeSpan.attributes[SemanticAttributes.MESSAGING_DESTINATION_KIND] - ).toEqual(MessagingDestinationKindValues.TOPIC); + consumeSpan.attributes[SEMATTRS_MESSAGING_DESTINATION_KIND] + ).toEqual(MESSAGINGDESTINATIONKINDVALUES_TOPIC); expect( - consumeSpan.attributes[ - SemanticAttributes.MESSAGING_RABBITMQ_ROUTING_KEY - ] + consumeSpan.attributes[SEMATTRS_MESSAGING_RABBITMQ_ROUTING_KEY] ).toEqual(queueName); + expect(consumeSpan.attributes[SEMATTRS_MESSAGING_PROTOCOL]).toEqual( + 'AMQP' + ); expect( - consumeSpan.attributes[SemanticAttributes.MESSAGING_PROTOCOL] - ).toEqual('AMQP'); - expect( - consumeSpan.attributes[SemanticAttributes.MESSAGING_PROTOCOL_VERSION] + consumeSpan.attributes[SEMATTRS_MESSAGING_PROTOCOL_VERSION] ).toEqual('0.9.1'); - expect( - consumeSpan.attributes[SemanticAttributes.MESSAGING_URL] - ).toEqual(censoredUrl); - expect( - consumeSpan.attributes[SemanticAttributes.NET_PEER_NAME] - ).toEqual(TEST_RABBITMQ_HOST); - expect( - consumeSpan.attributes[SemanticAttributes.NET_PEER_PORT] - ).toEqual(TEST_RABBITMQ_PORT); + expect(consumeSpan.attributes[SEMATTRS_MESSAGING_URL]).toEqual( + censoredUrl + ); + expect(consumeSpan.attributes[SEMATTRS_NET_PEER_NAME]).toEqual( + TEST_RABBITMQ_HOST + ); + expect(consumeSpan.attributes[SEMATTRS_NET_PEER_PORT]).toEqual( + TEST_RABBITMQ_PORT + ); // assert context propagation expect(consumeSpan.spanContext().traceId).toEqual( @@ -301,75 +305,63 @@ describe('amqplib instrumentation callback model', () => { // assert publish span expect(publishSpan.kind).toEqual(SpanKind.PRODUCER); + expect(publishSpan.attributes[SEMATTRS_MESSAGING_SYSTEM]).toEqual( + 'rabbitmq' + ); expect( - publishSpan.attributes[SemanticAttributes.MESSAGING_SYSTEM] - ).toEqual('rabbitmq'); - expect( - publishSpan.attributes[SemanticAttributes.MESSAGING_DESTINATION] + publishSpan.attributes[SEMATTRS_MESSAGING_DESTINATION] ).toEqual(''); // according to spec: "This will be an empty string if the default exchange is used" expect( - publishSpan.attributes[ - SemanticAttributes.MESSAGING_DESTINATION_KIND - ] - ).toEqual(MessagingDestinationKindValues.TOPIC); + publishSpan.attributes[SEMATTRS_MESSAGING_DESTINATION_KIND] + ).toEqual(MESSAGINGDESTINATIONKINDVALUES_TOPIC); expect( - publishSpan.attributes[ - SemanticAttributes.MESSAGING_RABBITMQ_ROUTING_KEY - ] + publishSpan.attributes[SEMATTRS_MESSAGING_RABBITMQ_ROUTING_KEY] ).toEqual(queueName); + expect(publishSpan.attributes[SEMATTRS_MESSAGING_PROTOCOL]).toEqual( + 'AMQP' + ); expect( - publishSpan.attributes[SemanticAttributes.MESSAGING_PROTOCOL] - ).toEqual('AMQP'); - expect( - publishSpan.attributes[ - SemanticAttributes.MESSAGING_PROTOCOL_VERSION - ] + publishSpan.attributes[SEMATTRS_MESSAGING_PROTOCOL_VERSION] ).toEqual('0.9.1'); - expect( - publishSpan.attributes[SemanticAttributes.MESSAGING_URL] - ).toEqual(censoredUrl); - expect( - publishSpan.attributes[SemanticAttributes.NET_PEER_NAME] - ).toEqual(TEST_RABBITMQ_HOST); - expect( - publishSpan.attributes[SemanticAttributes.NET_PEER_PORT] - ).toEqual(TEST_RABBITMQ_PORT); + expect(publishSpan.attributes[SEMATTRS_MESSAGING_URL]).toEqual( + censoredUrl + ); + expect(publishSpan.attributes[SEMATTRS_NET_PEER_NAME]).toEqual( + TEST_RABBITMQ_HOST + ); + expect(publishSpan.attributes[SEMATTRS_NET_PEER_PORT]).toEqual( + TEST_RABBITMQ_PORT + ); // assert consume span expect(consumeSpan.kind).toEqual(SpanKind.CONSUMER); + expect(consumeSpan.attributes[SEMATTRS_MESSAGING_SYSTEM]).toEqual( + 'rabbitmq' + ); expect( - consumeSpan.attributes[SemanticAttributes.MESSAGING_SYSTEM] - ).toEqual('rabbitmq'); - expect( - consumeSpan.attributes[SemanticAttributes.MESSAGING_DESTINATION] + consumeSpan.attributes[SEMATTRS_MESSAGING_DESTINATION] ).toEqual(''); // according to spec: "This will be an empty string if the default exchange is used" expect( - consumeSpan.attributes[ - SemanticAttributes.MESSAGING_DESTINATION_KIND - ] - ).toEqual(MessagingDestinationKindValues.TOPIC); + consumeSpan.attributes[SEMATTRS_MESSAGING_DESTINATION_KIND] + ).toEqual(MESSAGINGDESTINATIONKINDVALUES_TOPIC); expect( - consumeSpan.attributes[ - SemanticAttributes.MESSAGING_RABBITMQ_ROUTING_KEY - ] + consumeSpan.attributes[SEMATTRS_MESSAGING_RABBITMQ_ROUTING_KEY] ).toEqual(queueName); + expect(consumeSpan.attributes[SEMATTRS_MESSAGING_PROTOCOL]).toEqual( + 'AMQP' + ); expect( - consumeSpan.attributes[SemanticAttributes.MESSAGING_PROTOCOL] - ).toEqual('AMQP'); - expect( - consumeSpan.attributes[ - SemanticAttributes.MESSAGING_PROTOCOL_VERSION - ] + consumeSpan.attributes[SEMATTRS_MESSAGING_PROTOCOL_VERSION] ).toEqual('0.9.1'); - expect( - consumeSpan.attributes[SemanticAttributes.MESSAGING_URL] - ).toEqual(censoredUrl); - expect( - consumeSpan.attributes[SemanticAttributes.NET_PEER_NAME] - ).toEqual(TEST_RABBITMQ_HOST); - expect( - consumeSpan.attributes[SemanticAttributes.NET_PEER_PORT] - ).toEqual(TEST_RABBITMQ_PORT); + expect(consumeSpan.attributes[SEMATTRS_MESSAGING_URL]).toEqual( + censoredUrl + ); + expect(consumeSpan.attributes[SEMATTRS_NET_PEER_NAME]).toEqual( + TEST_RABBITMQ_HOST + ); + expect(consumeSpan.attributes[SEMATTRS_NET_PEER_PORT]).toEqual( + TEST_RABBITMQ_PORT + ); // assert context propagation expect(consumeSpan.spanContext().traceId).toEqual( diff --git a/plugins/node/instrumentation-amqplib/test/amqplib-connection.test.ts b/plugins/node/instrumentation-amqplib/test/amqplib-connection.test.ts index 7ac3e686e5..a9f6c5526d 100644 --- a/plugins/node/instrumentation-amqplib/test/amqplib-connection.test.ts +++ b/plugins/node/instrumentation-amqplib/test/amqplib-connection.test.ts @@ -32,7 +32,14 @@ import { registerInstrumentationTesting(new AmqplibInstrumentation()); import * as amqp from 'amqplib'; -import { SemanticAttributes } from '@opentelemetry/semantic-conventions'; +import { + SEMATTRS_MESSAGING_PROTOCOL, + SEMATTRS_MESSAGING_PROTOCOL_VERSION, + SEMATTRS_MESSAGING_SYSTEM, + SEMATTRS_MESSAGING_URL, + SEMATTRS_NET_PEER_NAME, + SEMATTRS_NET_PEER_PORT, +} from '@opentelemetry/semantic-conventions'; describe('amqplib instrumentation connection', () => { before(function () { @@ -60,24 +67,22 @@ describe('amqplib instrumentation connection', () => { ); const [publishSpan] = getTestSpans(); + expect(publishSpan.attributes[SEMATTRS_MESSAGING_SYSTEM]).toEqual( + 'rabbitmq' + ); + expect(publishSpan.attributes[SEMATTRS_MESSAGING_PROTOCOL]).toEqual( + 'AMQP' + ); expect( - publishSpan.attributes[SemanticAttributes.MESSAGING_SYSTEM] - ).toEqual('rabbitmq'); - expect( - publishSpan.attributes[SemanticAttributes.MESSAGING_PROTOCOL] - ).toEqual('AMQP'); - expect( - publishSpan.attributes[SemanticAttributes.MESSAGING_PROTOCOL_VERSION] + publishSpan.attributes[SEMATTRS_MESSAGING_PROTOCOL_VERSION] ).toEqual('0.9.1'); - expect( - publishSpan.attributes[SemanticAttributes.MESSAGING_URL] - ).toBeUndefined(); // no url string if value supplied as object - expect( - publishSpan.attributes[SemanticAttributes.NET_PEER_NAME] - ).toEqual(TEST_RABBITMQ_HOST); - expect( - publishSpan.attributes[SemanticAttributes.NET_PEER_PORT] - ).toEqual(TEST_RABBITMQ_PORT); + expect(publishSpan.attributes[SEMATTRS_MESSAGING_URL]).toBeUndefined(); // no url string if value supplied as object + expect(publishSpan.attributes[SEMATTRS_NET_PEER_NAME]).toEqual( + TEST_RABBITMQ_HOST + ); + expect(publishSpan.attributes[SEMATTRS_NET_PEER_PORT]).toEqual( + TEST_RABBITMQ_PORT + ); } finally { await conn.close(); } @@ -99,9 +104,9 @@ describe('amqplib instrumentation connection', () => { Buffer.from('message created only to test connection attributes') ); const [publishSpan] = getTestSpans(); - expect( - publishSpan.attributes[SemanticAttributes.MESSAGING_PROTOCOL] - ).toEqual('AMQP'); + expect(publishSpan.attributes[SEMATTRS_MESSAGING_PROTOCOL]).toEqual( + 'AMQP' + ); } finally { await conn.close(); } @@ -127,9 +132,9 @@ describe('amqplib instrumentation connection', () => { Buffer.from('message created only to test connection attributes') ); const [publishSpan] = getTestSpans(); - expect( - publishSpan.attributes[SemanticAttributes.NET_PEER_NAME] - ).toEqual(TEST_RABBITMQ_HOST); + expect(publishSpan.attributes[SEMATTRS_NET_PEER_NAME]).toEqual( + TEST_RABBITMQ_HOST + ); } finally { await conn.close(); } @@ -149,24 +154,24 @@ describe('amqplib instrumentation connection', () => { ); const [publishSpan] = getTestSpans(); + expect(publishSpan.attributes[SEMATTRS_MESSAGING_SYSTEM]).toEqual( + 'rabbitmq' + ); + expect(publishSpan.attributes[SEMATTRS_MESSAGING_PROTOCOL]).toEqual( + 'AMQP' + ); expect( - publishSpan.attributes[SemanticAttributes.MESSAGING_SYSTEM] - ).toEqual('rabbitmq'); - expect( - publishSpan.attributes[SemanticAttributes.MESSAGING_PROTOCOL] - ).toEqual('AMQP'); - expect( - publishSpan.attributes[SemanticAttributes.MESSAGING_PROTOCOL_VERSION] + publishSpan.attributes[SEMATTRS_MESSAGING_PROTOCOL_VERSION] ).toEqual('0.9.1'); - expect( - publishSpan.attributes[SemanticAttributes.MESSAGING_URL] - ).toEqual(censoredUrl); - expect( - publishSpan.attributes[SemanticAttributes.NET_PEER_NAME] - ).toEqual(TEST_RABBITMQ_HOST); - expect( - publishSpan.attributes[SemanticAttributes.NET_PEER_PORT] - ).toEqual(TEST_RABBITMQ_PORT); + expect(publishSpan.attributes[SEMATTRS_MESSAGING_URL]).toEqual( + censoredUrl + ); + expect(publishSpan.attributes[SEMATTRS_NET_PEER_NAME]).toEqual( + TEST_RABBITMQ_HOST + ); + expect(publishSpan.attributes[SEMATTRS_NET_PEER_PORT]).toEqual( + TEST_RABBITMQ_PORT + ); } finally { await conn.close(); } diff --git a/plugins/node/instrumentation-amqplib/test/amqplib-promise.test.ts b/plugins/node/instrumentation-amqplib/test/amqplib-promise.test.ts index e130f5e942..2205d76a5a 100644 --- a/plugins/node/instrumentation-amqplib/test/amqplib-promise.test.ts +++ b/plugins/node/instrumentation-amqplib/test/amqplib-promise.test.ts @@ -36,8 +36,16 @@ const instrumentation = registerInstrumentationTesting( import * as amqp from 'amqplib'; import { ConsumeMessage } from 'amqplib'; import { - MessagingDestinationKindValues, - SemanticAttributes, + MESSAGINGDESTINATIONKINDVALUES_TOPIC, + SEMATTRS_MESSAGING_DESTINATION, + SEMATTRS_MESSAGING_DESTINATION_KIND, + SEMATTRS_MESSAGING_PROTOCOL, + SEMATTRS_MESSAGING_PROTOCOL_VERSION, + SEMATTRS_MESSAGING_RABBITMQ_ROUTING_KEY, + SEMATTRS_MESSAGING_SYSTEM, + SEMATTRS_MESSAGING_URL, + SEMATTRS_NET_PEER_NAME, + SEMATTRS_NET_PEER_PORT, } from '@opentelemetry/semantic-conventions'; import { Span, SpanKind, SpanStatusCode } from '@opentelemetry/api'; import { asyncConfirmPublish, asyncConfirmSend, asyncConsume } from './utils'; @@ -146,65 +154,61 @@ describe('amqplib instrumentation promise model', () => { // assert publish span expect(publishSpan.kind).toEqual(SpanKind.PRODUCER); + expect(publishSpan.attributes[SEMATTRS_MESSAGING_SYSTEM]).toEqual( + 'rabbitmq' + ); + expect(publishSpan.attributes[SEMATTRS_MESSAGING_DESTINATION]).toEqual( + '' + ); // according to spec: "This will be an empty string if the default exchange is used" expect( - publishSpan.attributes[SemanticAttributes.MESSAGING_SYSTEM] - ).toEqual('rabbitmq'); - expect( - publishSpan.attributes[SemanticAttributes.MESSAGING_DESTINATION] - ).toEqual(''); // according to spec: "This will be an empty string if the default exchange is used" - expect( - publishSpan.attributes[SemanticAttributes.MESSAGING_DESTINATION_KIND] - ).toEqual(MessagingDestinationKindValues.TOPIC); + publishSpan.attributes[SEMATTRS_MESSAGING_DESTINATION_KIND] + ).toEqual(MESSAGINGDESTINATIONKINDVALUES_TOPIC); expect( - publishSpan.attributes[ - SemanticAttributes.MESSAGING_RABBITMQ_ROUTING_KEY - ] + publishSpan.attributes[SEMATTRS_MESSAGING_RABBITMQ_ROUTING_KEY] ).toEqual(queueName); + expect(publishSpan.attributes[SEMATTRS_MESSAGING_PROTOCOL]).toEqual( + 'AMQP' + ); expect( - publishSpan.attributes[SemanticAttributes.MESSAGING_PROTOCOL] - ).toEqual('AMQP'); - expect( - publishSpan.attributes[SemanticAttributes.MESSAGING_PROTOCOL_VERSION] + publishSpan.attributes[SEMATTRS_MESSAGING_PROTOCOL_VERSION] ).toEqual('0.9.1'); - expect(publishSpan.attributes[SemanticAttributes.MESSAGING_URL]).toEqual( + expect(publishSpan.attributes[SEMATTRS_MESSAGING_URL]).toEqual( censoredUrl ); - expect(publishSpan.attributes[SemanticAttributes.NET_PEER_NAME]).toEqual( + expect(publishSpan.attributes[SEMATTRS_NET_PEER_NAME]).toEqual( TEST_RABBITMQ_HOST ); - expect(publishSpan.attributes[SemanticAttributes.NET_PEER_PORT]).toEqual( + expect(publishSpan.attributes[SEMATTRS_NET_PEER_PORT]).toEqual( TEST_RABBITMQ_PORT ); // assert consume span expect(consumeSpan.kind).toEqual(SpanKind.CONSUMER); + expect(consumeSpan.attributes[SEMATTRS_MESSAGING_SYSTEM]).toEqual( + 'rabbitmq' + ); + expect(consumeSpan.attributes[SEMATTRS_MESSAGING_DESTINATION]).toEqual( + '' + ); // according to spec: "This will be an empty string if the default exchange is used" expect( - consumeSpan.attributes[SemanticAttributes.MESSAGING_SYSTEM] - ).toEqual('rabbitmq'); - expect( - consumeSpan.attributes[SemanticAttributes.MESSAGING_DESTINATION] - ).toEqual(''); // according to spec: "This will be an empty string if the default exchange is used" - expect( - consumeSpan.attributes[SemanticAttributes.MESSAGING_DESTINATION_KIND] - ).toEqual(MessagingDestinationKindValues.TOPIC); + consumeSpan.attributes[SEMATTRS_MESSAGING_DESTINATION_KIND] + ).toEqual(MESSAGINGDESTINATIONKINDVALUES_TOPIC); expect( - consumeSpan.attributes[ - SemanticAttributes.MESSAGING_RABBITMQ_ROUTING_KEY - ] + consumeSpan.attributes[SEMATTRS_MESSAGING_RABBITMQ_ROUTING_KEY] ).toEqual(queueName); + expect(consumeSpan.attributes[SEMATTRS_MESSAGING_PROTOCOL]).toEqual( + 'AMQP' + ); expect( - consumeSpan.attributes[SemanticAttributes.MESSAGING_PROTOCOL] - ).toEqual('AMQP'); - expect( - consumeSpan.attributes[SemanticAttributes.MESSAGING_PROTOCOL_VERSION] + consumeSpan.attributes[SEMATTRS_MESSAGING_PROTOCOL_VERSION] ).toEqual('0.9.1'); - expect(consumeSpan.attributes[SemanticAttributes.MESSAGING_URL]).toEqual( + expect(consumeSpan.attributes[SEMATTRS_MESSAGING_URL]).toEqual( censoredUrl ); - expect(consumeSpan.attributes[SemanticAttributes.NET_PEER_NAME]).toEqual( + expect(consumeSpan.attributes[SEMATTRS_NET_PEER_NAME]).toEqual( TEST_RABBITMQ_HOST ); - expect(consumeSpan.attributes[SemanticAttributes.NET_PEER_PORT]).toEqual( + expect(consumeSpan.attributes[SEMATTRS_NET_PEER_PORT]).toEqual( TEST_RABBITMQ_PORT ); @@ -505,48 +509,44 @@ describe('amqplib instrumentation promise model', () => { // assert publish span expect(publishSpan.kind).toEqual(SpanKind.PRODUCER); + expect(publishSpan.attributes[SEMATTRS_MESSAGING_SYSTEM]).toEqual( + 'rabbitmq' + ); + expect(publishSpan.attributes[SEMATTRS_MESSAGING_DESTINATION]).toEqual( + exchangeName + ); expect( - publishSpan.attributes[SemanticAttributes.MESSAGING_SYSTEM] - ).toEqual('rabbitmq'); - expect( - publishSpan.attributes[SemanticAttributes.MESSAGING_DESTINATION] - ).toEqual(exchangeName); - expect( - publishSpan.attributes[SemanticAttributes.MESSAGING_DESTINATION_KIND] - ).toEqual(MessagingDestinationKindValues.TOPIC); + publishSpan.attributes[SEMATTRS_MESSAGING_DESTINATION_KIND] + ).toEqual(MESSAGINGDESTINATIONKINDVALUES_TOPIC); expect( - publishSpan.attributes[ - SemanticAttributes.MESSAGING_RABBITMQ_ROUTING_KEY - ] + publishSpan.attributes[SEMATTRS_MESSAGING_RABBITMQ_ROUTING_KEY] ).toEqual(routingKey); + expect(publishSpan.attributes[SEMATTRS_MESSAGING_PROTOCOL]).toEqual( + 'AMQP' + ); expect( - publishSpan.attributes[SemanticAttributes.MESSAGING_PROTOCOL] - ).toEqual('AMQP'); - expect( - publishSpan.attributes[SemanticAttributes.MESSAGING_PROTOCOL_VERSION] + publishSpan.attributes[SEMATTRS_MESSAGING_PROTOCOL_VERSION] ).toEqual('0.9.1'); // assert consume span expect(consumeSpan.kind).toEqual(SpanKind.CONSUMER); + expect(consumeSpan.attributes[SEMATTRS_MESSAGING_SYSTEM]).toEqual( + 'rabbitmq' + ); + expect(consumeSpan.attributes[SEMATTRS_MESSAGING_DESTINATION]).toEqual( + exchangeName + ); expect( - consumeSpan.attributes[SemanticAttributes.MESSAGING_SYSTEM] - ).toEqual('rabbitmq'); - expect( - consumeSpan.attributes[SemanticAttributes.MESSAGING_DESTINATION] - ).toEqual(exchangeName); - expect( - consumeSpan.attributes[SemanticAttributes.MESSAGING_DESTINATION_KIND] - ).toEqual(MessagingDestinationKindValues.TOPIC); + consumeSpan.attributes[SEMATTRS_MESSAGING_DESTINATION_KIND] + ).toEqual(MESSAGINGDESTINATIONKINDVALUES_TOPIC); expect( - consumeSpan.attributes[ - SemanticAttributes.MESSAGING_RABBITMQ_ROUTING_KEY - ] + consumeSpan.attributes[SEMATTRS_MESSAGING_RABBITMQ_ROUTING_KEY] ).toEqual(routingKey); + expect(consumeSpan.attributes[SEMATTRS_MESSAGING_PROTOCOL]).toEqual( + 'AMQP' + ); expect( - consumeSpan.attributes[SemanticAttributes.MESSAGING_PROTOCOL] - ).toEqual('AMQP'); - expect( - consumeSpan.attributes[SemanticAttributes.MESSAGING_PROTOCOL_VERSION] + consumeSpan.attributes[SEMATTRS_MESSAGING_PROTOCOL_VERSION] ).toEqual('0.9.1'); // assert context propagation @@ -689,65 +689,61 @@ describe('amqplib instrumentation promise model', () => { // assert publish span expect(publishSpan.kind).toEqual(SpanKind.PRODUCER); + expect(publishSpan.attributes[SEMATTRS_MESSAGING_SYSTEM]).toEqual( + 'rabbitmq' + ); + expect(publishSpan.attributes[SEMATTRS_MESSAGING_DESTINATION]).toEqual( + '' + ); // according to spec: "This will be an empty string if the default exchange is used" expect( - publishSpan.attributes[SemanticAttributes.MESSAGING_SYSTEM] - ).toEqual('rabbitmq'); - expect( - publishSpan.attributes[SemanticAttributes.MESSAGING_DESTINATION] - ).toEqual(''); // according to spec: "This will be an empty string if the default exchange is used" - expect( - publishSpan.attributes[SemanticAttributes.MESSAGING_DESTINATION_KIND] - ).toEqual(MessagingDestinationKindValues.TOPIC); + publishSpan.attributes[SEMATTRS_MESSAGING_DESTINATION_KIND] + ).toEqual(MESSAGINGDESTINATIONKINDVALUES_TOPIC); expect( - publishSpan.attributes[ - SemanticAttributes.MESSAGING_RABBITMQ_ROUTING_KEY - ] + publishSpan.attributes[SEMATTRS_MESSAGING_RABBITMQ_ROUTING_KEY] ).toEqual(queueName); + expect(publishSpan.attributes[SEMATTRS_MESSAGING_PROTOCOL]).toEqual( + 'AMQP' + ); expect( - publishSpan.attributes[SemanticAttributes.MESSAGING_PROTOCOL] - ).toEqual('AMQP'); - expect( - publishSpan.attributes[SemanticAttributes.MESSAGING_PROTOCOL_VERSION] + publishSpan.attributes[SEMATTRS_MESSAGING_PROTOCOL_VERSION] ).toEqual('0.9.1'); - expect(publishSpan.attributes[SemanticAttributes.MESSAGING_URL]).toEqual( + expect(publishSpan.attributes[SEMATTRS_MESSAGING_URL]).toEqual( censoredUrl ); - expect(publishSpan.attributes[SemanticAttributes.NET_PEER_NAME]).toEqual( + expect(publishSpan.attributes[SEMATTRS_NET_PEER_NAME]).toEqual( TEST_RABBITMQ_HOST ); - expect(publishSpan.attributes[SemanticAttributes.NET_PEER_PORT]).toEqual( + expect(publishSpan.attributes[SEMATTRS_NET_PEER_PORT]).toEqual( TEST_RABBITMQ_PORT ); // assert consume span expect(consumeSpan.kind).toEqual(SpanKind.CONSUMER); + expect(consumeSpan.attributes[SEMATTRS_MESSAGING_SYSTEM]).toEqual( + 'rabbitmq' + ); + expect(consumeSpan.attributes[SEMATTRS_MESSAGING_DESTINATION]).toEqual( + '' + ); // according to spec: "This will be an empty string if the default exchange is used" expect( - consumeSpan.attributes[SemanticAttributes.MESSAGING_SYSTEM] - ).toEqual('rabbitmq'); - expect( - consumeSpan.attributes[SemanticAttributes.MESSAGING_DESTINATION] - ).toEqual(''); // according to spec: "This will be an empty string if the default exchange is used" - expect( - consumeSpan.attributes[SemanticAttributes.MESSAGING_DESTINATION_KIND] - ).toEqual(MessagingDestinationKindValues.TOPIC); + consumeSpan.attributes[SEMATTRS_MESSAGING_DESTINATION_KIND] + ).toEqual(MESSAGINGDESTINATIONKINDVALUES_TOPIC); expect( - consumeSpan.attributes[ - SemanticAttributes.MESSAGING_RABBITMQ_ROUTING_KEY - ] + consumeSpan.attributes[SEMATTRS_MESSAGING_RABBITMQ_ROUTING_KEY] ).toEqual(queueName); + expect(consumeSpan.attributes[SEMATTRS_MESSAGING_PROTOCOL]).toEqual( + 'AMQP' + ); expect( - consumeSpan.attributes[SemanticAttributes.MESSAGING_PROTOCOL] - ).toEqual('AMQP'); - expect( - consumeSpan.attributes[SemanticAttributes.MESSAGING_PROTOCOL_VERSION] + consumeSpan.attributes[SEMATTRS_MESSAGING_PROTOCOL_VERSION] ).toEqual('0.9.1'); - expect(consumeSpan.attributes[SemanticAttributes.MESSAGING_URL]).toEqual( + expect(consumeSpan.attributes[SEMATTRS_MESSAGING_URL]).toEqual( censoredUrl ); - expect(consumeSpan.attributes[SemanticAttributes.NET_PEER_NAME]).toEqual( + expect(consumeSpan.attributes[SEMATTRS_NET_PEER_NAME]).toEqual( TEST_RABBITMQ_HOST ); - expect(consumeSpan.attributes[SemanticAttributes.NET_PEER_PORT]).toEqual( + expect(consumeSpan.attributes[SEMATTRS_NET_PEER_PORT]).toEqual( TEST_RABBITMQ_PORT ); @@ -1100,48 +1096,44 @@ describe('amqplib instrumentation promise model', () => { // assert publish span expect(publishSpan.kind).toEqual(SpanKind.PRODUCER); + expect(publishSpan.attributes[SEMATTRS_MESSAGING_SYSTEM]).toEqual( + 'rabbitmq' + ); + expect(publishSpan.attributes[SEMATTRS_MESSAGING_DESTINATION]).toEqual( + exchangeName + ); expect( - publishSpan.attributes[SemanticAttributes.MESSAGING_SYSTEM] - ).toEqual('rabbitmq'); - expect( - publishSpan.attributes[SemanticAttributes.MESSAGING_DESTINATION] - ).toEqual(exchangeName); - expect( - publishSpan.attributes[SemanticAttributes.MESSAGING_DESTINATION_KIND] - ).toEqual(MessagingDestinationKindValues.TOPIC); + publishSpan.attributes[SEMATTRS_MESSAGING_DESTINATION_KIND] + ).toEqual(MESSAGINGDESTINATIONKINDVALUES_TOPIC); expect( - publishSpan.attributes[ - SemanticAttributes.MESSAGING_RABBITMQ_ROUTING_KEY - ] + publishSpan.attributes[SEMATTRS_MESSAGING_RABBITMQ_ROUTING_KEY] ).toEqual(routingKey); + expect(publishSpan.attributes[SEMATTRS_MESSAGING_PROTOCOL]).toEqual( + 'AMQP' + ); expect( - publishSpan.attributes[SemanticAttributes.MESSAGING_PROTOCOL] - ).toEqual('AMQP'); - expect( - publishSpan.attributes[SemanticAttributes.MESSAGING_PROTOCOL_VERSION] + publishSpan.attributes[SEMATTRS_MESSAGING_PROTOCOL_VERSION] ).toEqual('0.9.1'); // assert consume span expect(consumeSpan.kind).toEqual(SpanKind.CONSUMER); + expect(consumeSpan.attributes[SEMATTRS_MESSAGING_SYSTEM]).toEqual( + 'rabbitmq' + ); + expect(consumeSpan.attributes[SEMATTRS_MESSAGING_DESTINATION]).toEqual( + exchangeName + ); expect( - consumeSpan.attributes[SemanticAttributes.MESSAGING_SYSTEM] - ).toEqual('rabbitmq'); - expect( - consumeSpan.attributes[SemanticAttributes.MESSAGING_DESTINATION] - ).toEqual(exchangeName); - expect( - consumeSpan.attributes[SemanticAttributes.MESSAGING_DESTINATION_KIND] - ).toEqual(MessagingDestinationKindValues.TOPIC); + consumeSpan.attributes[SEMATTRS_MESSAGING_DESTINATION_KIND] + ).toEqual(MESSAGINGDESTINATIONKINDVALUES_TOPIC); expect( - consumeSpan.attributes[ - SemanticAttributes.MESSAGING_RABBITMQ_ROUTING_KEY - ] + consumeSpan.attributes[SEMATTRS_MESSAGING_RABBITMQ_ROUTING_KEY] ).toEqual(routingKey); + expect(consumeSpan.attributes[SEMATTRS_MESSAGING_PROTOCOL]).toEqual( + 'AMQP' + ); expect( - consumeSpan.attributes[SemanticAttributes.MESSAGING_PROTOCOL] - ).toEqual('AMQP'); - expect( - consumeSpan.attributes[SemanticAttributes.MESSAGING_PROTOCOL_VERSION] + consumeSpan.attributes[SEMATTRS_MESSAGING_PROTOCOL_VERSION] ).toEqual('0.9.1'); // assert context propagation diff --git a/plugins/node/instrumentation-amqplib/test/utils.test.ts b/plugins/node/instrumentation-amqplib/test/utils.test.ts index 34e6fb7aa9..6369398969 100644 --- a/plugins/node/instrumentation-amqplib/test/utils.test.ts +++ b/plugins/node/instrumentation-amqplib/test/utils.test.ts @@ -19,7 +19,14 @@ import { getConnectionAttributesFromServer, getConnectionAttributesFromUrl, } from '../src/utils'; -import { SemanticAttributes } from '@opentelemetry/semantic-conventions'; +import { + SEMATTRS_MESSAGING_PROTOCOL, + SEMATTRS_MESSAGING_PROTOCOL_VERSION, + SEMATTRS_MESSAGING_SYSTEM, + SEMATTRS_MESSAGING_URL, + SEMATTRS_NET_PEER_NAME, + SEMATTRS_NET_PEER_PORT, +} from '@opentelemetry/semantic-conventions'; import * as amqp from 'amqplib'; import { shouldTest } from './utils'; import { rabbitMqUrl } from './config'; @@ -43,7 +50,7 @@ describe('utils', () => { it('messaging system attribute', () => { const attributes = getConnectionAttributesFromServer(conn.connection); expect(attributes).toStrictEqual({ - [SemanticAttributes.MESSAGING_SYSTEM]: 'rabbitmq', + [SEMATTRS_MESSAGING_SYSTEM]: 'rabbitmq', }); }); }); @@ -54,11 +61,11 @@ describe('utils', () => { 'amqp://user:pass@host:10000/vhost' ); expect(attributes).toStrictEqual({ - [SemanticAttributes.MESSAGING_PROTOCOL]: 'AMQP', - [SemanticAttributes.MESSAGING_PROTOCOL_VERSION]: '0.9.1', - [SemanticAttributes.NET_PEER_NAME]: 'host', - [SemanticAttributes.NET_PEER_PORT]: 10000, - [SemanticAttributes.MESSAGING_URL]: 'amqp://user:***@host:10000/vhost', + [SEMATTRS_MESSAGING_PROTOCOL]: 'AMQP', + [SEMATTRS_MESSAGING_PROTOCOL_VERSION]: '0.9.1', + [SEMATTRS_NET_PEER_NAME]: 'host', + [SEMATTRS_NET_PEER_PORT]: 10000, + [SEMATTRS_MESSAGING_URL]: 'amqp://user:***@host:10000/vhost', }); }); @@ -67,102 +74,101 @@ describe('utils', () => { 'amqp://user%61:%61pass@ho%61st:10000/v%2fhost' ); expect(attributes).toStrictEqual({ - [SemanticAttributes.MESSAGING_PROTOCOL]: 'AMQP', - [SemanticAttributes.MESSAGING_PROTOCOL_VERSION]: '0.9.1', - [SemanticAttributes.NET_PEER_NAME]: 'ho%61st', - [SemanticAttributes.NET_PEER_PORT]: 10000, - [SemanticAttributes.MESSAGING_URL]: - 'amqp://user%61:***@ho%61st:10000/v%2fhost', + [SEMATTRS_MESSAGING_PROTOCOL]: 'AMQP', + [SEMATTRS_MESSAGING_PROTOCOL_VERSION]: '0.9.1', + [SEMATTRS_NET_PEER_NAME]: 'ho%61st', + [SEMATTRS_NET_PEER_PORT]: 10000, + [SEMATTRS_MESSAGING_URL]: 'amqp://user%61:***@ho%61st:10000/v%2fhost', }); }); it('only protocol', () => { const attributes = getConnectionAttributesFromUrl('amqp://'); expect(attributes).toStrictEqual({ - [SemanticAttributes.MESSAGING_PROTOCOL]: 'AMQP', - [SemanticAttributes.MESSAGING_PROTOCOL_VERSION]: '0.9.1', - [SemanticAttributes.NET_PEER_NAME]: 'localhost', - [SemanticAttributes.NET_PEER_PORT]: 5672, - [SemanticAttributes.MESSAGING_URL]: 'amqp://', + [SEMATTRS_MESSAGING_PROTOCOL]: 'AMQP', + [SEMATTRS_MESSAGING_PROTOCOL_VERSION]: '0.9.1', + [SEMATTRS_NET_PEER_NAME]: 'localhost', + [SEMATTRS_NET_PEER_PORT]: 5672, + [SEMATTRS_MESSAGING_URL]: 'amqp://', }); }); it('empty username and password', () => { const attributes = getConnectionAttributesFromUrl('amqp://:@/'); expect(attributes).toStrictEqual({ - [SemanticAttributes.MESSAGING_PROTOCOL_VERSION]: '0.9.1', - [SemanticAttributes.MESSAGING_URL]: 'amqp://:***@/', + [SEMATTRS_MESSAGING_PROTOCOL_VERSION]: '0.9.1', + [SEMATTRS_MESSAGING_URL]: 'amqp://:***@/', }); }); it('username and no password', () => { const attributes = getConnectionAttributesFromUrl('amqp://user@'); expect(attributes).toStrictEqual({ - [SemanticAttributes.MESSAGING_PROTOCOL_VERSION]: '0.9.1', - [SemanticAttributes.MESSAGING_URL]: 'amqp://user@', + [SEMATTRS_MESSAGING_PROTOCOL_VERSION]: '0.9.1', + [SEMATTRS_MESSAGING_URL]: 'amqp://user@', }); }); it('username and password, no host', () => { const attributes = getConnectionAttributesFromUrl('amqp://user:pass@'); expect(attributes).toStrictEqual({ - [SemanticAttributes.MESSAGING_PROTOCOL_VERSION]: '0.9.1', - [SemanticAttributes.MESSAGING_URL]: 'amqp://user:***@', + [SEMATTRS_MESSAGING_PROTOCOL_VERSION]: '0.9.1', + [SEMATTRS_MESSAGING_URL]: 'amqp://user:***@', }); }); it('host only', () => { const attributes = getConnectionAttributesFromUrl('amqp://host'); expect(attributes).toStrictEqual({ - [SemanticAttributes.MESSAGING_PROTOCOL]: 'AMQP', - [SemanticAttributes.MESSAGING_PROTOCOL_VERSION]: '0.9.1', - [SemanticAttributes.NET_PEER_NAME]: 'host', - [SemanticAttributes.NET_PEER_PORT]: 5672, - [SemanticAttributes.MESSAGING_URL]: 'amqp://host', + [SEMATTRS_MESSAGING_PROTOCOL]: 'AMQP', + [SEMATTRS_MESSAGING_PROTOCOL_VERSION]: '0.9.1', + [SEMATTRS_NET_PEER_NAME]: 'host', + [SEMATTRS_NET_PEER_PORT]: 5672, + [SEMATTRS_MESSAGING_URL]: 'amqp://host', }); }); it('vhost only', () => { const attributes = getConnectionAttributesFromUrl('amqp:///vhost'); expect(attributes).toStrictEqual({ - [SemanticAttributes.MESSAGING_PROTOCOL]: 'AMQP', - [SemanticAttributes.MESSAGING_PROTOCOL_VERSION]: '0.9.1', - [SemanticAttributes.NET_PEER_NAME]: 'localhost', - [SemanticAttributes.NET_PEER_PORT]: 5672, - [SemanticAttributes.MESSAGING_URL]: 'amqp:///vhost', + [SEMATTRS_MESSAGING_PROTOCOL]: 'AMQP', + [SEMATTRS_MESSAGING_PROTOCOL_VERSION]: '0.9.1', + [SEMATTRS_NET_PEER_NAME]: 'localhost', + [SEMATTRS_NET_PEER_PORT]: 5672, + [SEMATTRS_MESSAGING_URL]: 'amqp:///vhost', }); }); it('host only, trailing slash', () => { const attributes = getConnectionAttributesFromUrl('amqp://host/'); expect(attributes).toStrictEqual({ - [SemanticAttributes.MESSAGING_PROTOCOL]: 'AMQP', - [SemanticAttributes.MESSAGING_PROTOCOL_VERSION]: '0.9.1', - [SemanticAttributes.NET_PEER_NAME]: 'host', - [SemanticAttributes.NET_PEER_PORT]: 5672, - [SemanticAttributes.MESSAGING_URL]: 'amqp://host/', + [SEMATTRS_MESSAGING_PROTOCOL]: 'AMQP', + [SEMATTRS_MESSAGING_PROTOCOL_VERSION]: '0.9.1', + [SEMATTRS_NET_PEER_NAME]: 'host', + [SEMATTRS_NET_PEER_PORT]: 5672, + [SEMATTRS_MESSAGING_URL]: 'amqp://host/', }); }); it('vhost encoded', () => { const attributes = getConnectionAttributesFromUrl('amqp://host/%2f'); expect(attributes).toStrictEqual({ - [SemanticAttributes.MESSAGING_PROTOCOL]: 'AMQP', - [SemanticAttributes.MESSAGING_PROTOCOL_VERSION]: '0.9.1', - [SemanticAttributes.NET_PEER_NAME]: 'host', - [SemanticAttributes.NET_PEER_PORT]: 5672, - [SemanticAttributes.MESSAGING_URL]: 'amqp://host/%2f', + [SEMATTRS_MESSAGING_PROTOCOL]: 'AMQP', + [SEMATTRS_MESSAGING_PROTOCOL_VERSION]: '0.9.1', + [SEMATTRS_NET_PEER_NAME]: 'host', + [SEMATTRS_NET_PEER_PORT]: 5672, + [SEMATTRS_MESSAGING_URL]: 'amqp://host/%2f', }); }); it('IPv6 host', () => { const attributes = getConnectionAttributesFromUrl('amqp://[::1]'); expect(attributes).toStrictEqual({ - [SemanticAttributes.MESSAGING_PROTOCOL]: 'AMQP', - [SemanticAttributes.MESSAGING_PROTOCOL_VERSION]: '0.9.1', - [SemanticAttributes.NET_PEER_NAME]: '[::1]', - [SemanticAttributes.NET_PEER_PORT]: 5672, - [SemanticAttributes.MESSAGING_URL]: 'amqp://[::1]', + [SEMATTRS_MESSAGING_PROTOCOL]: 'AMQP', + [SEMATTRS_MESSAGING_PROTOCOL_VERSION]: '0.9.1', + [SEMATTRS_NET_PEER_NAME]: '[::1]', + [SEMATTRS_NET_PEER_PORT]: 5672, + [SEMATTRS_MESSAGING_URL]: 'amqp://[::1]', }); }); }); diff --git a/plugins/node/instrumentation-cucumber/LICENSE b/plugins/node/instrumentation-cucumber/LICENSE index e50e8c80f9..261eeb9e9f 100644 --- a/plugins/node/instrumentation-cucumber/LICENSE +++ b/plugins/node/instrumentation-cucumber/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/plugins/node/instrumentation-dataloader/LICENSE b/plugins/node/instrumentation-dataloader/LICENSE index e50e8c80f9..261eeb9e9f 100644 --- a/plugins/node/instrumentation-dataloader/LICENSE +++ b/plugins/node/instrumentation-dataloader/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/plugins/node/instrumentation-lru-memoizer/LICENSE b/plugins/node/instrumentation-lru-memoizer/LICENSE index e50e8c80f9..261eeb9e9f 100644 --- a/plugins/node/instrumentation-lru-memoizer/LICENSE +++ b/plugins/node/instrumentation-lru-memoizer/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/plugins/node/instrumentation-mongoose/LICENSE b/plugins/node/instrumentation-mongoose/LICENSE index e50e8c80f9..261eeb9e9f 100644 --- a/plugins/node/instrumentation-mongoose/LICENSE +++ b/plugins/node/instrumentation-mongoose/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/plugins/node/instrumentation-mongoose/README.md b/plugins/node/instrumentation-mongoose/README.md index 22a600e07e..159e01568b 100644 --- a/plugins/node/instrumentation-mongoose/README.md +++ b/plugins/node/instrumentation-mongoose/README.md @@ -52,6 +52,23 @@ The instrumentation's config `responseHook` functions signature changed, so the The `moduleVersionAttributeName` config option is removed. To add the mongoose package version to spans, use the `moduleVersion` attribute in hook info for `responseHook` function. +## Semantic Conventions + +This package uses `@opentelemetry/semantic-conventions` version `1.22+`, which implements Semantic Convention [Version 1.7.0](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.7.0/semantic_conventions/README.md) + +Attributes collected: + +| Attribute | Short Description | +| ----------------------- | --------------------------------------------------------------------------- | +| `db.mongodb.collection` | The collection being accessed within the database stated in `db.name`. | +| `db.name` | This attribute is used to report the name of the database being accessed. | +| `db.operation` | The name of the operation being executed, or the SQL keyword. | +| `db.statement` | The database statement being executed. | +| `db.system` | An identifier for the database management system (DBMS) product being used. | +| `db.user` | Username for accessing the database. | +| `net.peer.name` | Remote hostname or similar. | +| `net.peer.port` | Remote port number. | + ## Useful links - For more information on OpenTelemetry, visit: diff --git a/plugins/node/instrumentation-mongoose/package.json b/plugins/node/instrumentation-mongoose/package.json index 1a3d149543..dbafc9af61 100644 --- a/plugins/node/instrumentation-mongoose/package.json +++ b/plugins/node/instrumentation-mongoose/package.json @@ -62,7 +62,7 @@ "dependencies": { "@opentelemetry/core": "^1.8.0", "@opentelemetry/instrumentation": "^0.50.0", - "@opentelemetry/semantic-conventions": "^1.0.0" + "@opentelemetry/semantic-conventions": "^1.22.0" }, "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/instrumentation-mongoose#readme" } diff --git a/plugins/node/instrumentation-mongoose/src/mongoose.ts b/plugins/node/instrumentation-mongoose/src/mongoose.ts index 77c8dbee0d..96bf8f3734 100644 --- a/plugins/node/instrumentation-mongoose/src/mongoose.ts +++ b/plugins/node/instrumentation-mongoose/src/mongoose.ts @@ -13,13 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { - context, - Span, - trace, - SpanAttributes, - SpanKind, -} from '@opentelemetry/api'; +import { context, Span, trace, Attributes, SpanKind } from '@opentelemetry/api'; import { suppressTracing } from '@opentelemetry/core'; import type * as mongoose from 'mongoose'; import { MongooseInstrumentationConfig, SerializerPayload } from './types'; @@ -34,7 +28,11 @@ import { InstrumentationNodeModuleDefinition, } from '@opentelemetry/instrumentation'; import { VERSION } from './version'; -import { SemanticAttributes } from '@opentelemetry/semantic-conventions'; +import { + SEMATTRS_DB_OPERATION, + SEMATTRS_DB_STATEMENT, + SEMATTRS_DB_SYSTEM, +} from '@opentelemetry/semantic-conventions'; const contextCaptureFunctions = [ 'remove', @@ -155,9 +153,9 @@ export class MongooseInstrumentation extends InstrumentationBase { } const parentSpan = this[_STORED_PARENT_SPAN]; - const attributes: SpanAttributes = {}; + const attributes: Attributes = {}; if (self._config.dbStatementSerializer) { - attributes[SemanticAttributes.DB_STATEMENT] = + attributes[SEMATTRS_DB_STATEMENT] = self._config.dbStatementSerializer('aggregate', { options: this.options, aggregatePipeline: this._pipeline, @@ -197,9 +195,9 @@ export class MongooseInstrumentation extends InstrumentationBase { } const parentSpan = this[_STORED_PARENT_SPAN]; - const attributes: SpanAttributes = {}; + const attributes: Attributes = {}; if (self._config.dbStatementSerializer) { - attributes[SemanticAttributes.DB_STATEMENT] = + attributes[SEMATTRS_DB_STATEMENT] = self._config.dbStatementSerializer(this.op, { condition: this._conditions, updates: this._update, @@ -243,9 +241,9 @@ export class MongooseInstrumentation extends InstrumentationBase { if (options && !(options instanceof Function)) { serializePayload.options = options; } - const attributes: SpanAttributes = {}; + const attributes: Attributes = {}; if (self._config.dbStatementSerializer) { - attributes[SemanticAttributes.DB_STATEMENT] = + attributes[SEMATTRS_DB_STATEMENT] = self._config.dbStatementSerializer(op, serializePayload); } const span = self._startSpan( @@ -308,7 +306,7 @@ export class MongooseInstrumentation extends InstrumentationBase { collection: mongoose.Collection, modelName: string, operation: string, - attributes: SpanAttributes, + attributes: Attributes, parentSpan?: Span ): Span { return this.tracer.startSpan( @@ -318,8 +316,8 @@ export class MongooseInstrumentation extends InstrumentationBase { attributes: { ...attributes, ...getAttributesFromCollection(collection), - [SemanticAttributes.DB_OPERATION]: operation, - [SemanticAttributes.DB_SYSTEM]: 'mongoose', + [SEMATTRS_DB_OPERATION]: operation, + [SEMATTRS_DB_SYSTEM]: 'mongoose', }, }, parentSpan ? trace.setSpan(context.active(), parentSpan) : undefined diff --git a/plugins/node/instrumentation-mongoose/src/utils.ts b/plugins/node/instrumentation-mongoose/src/utils.ts index 2c44c87dae..f556218c87 100644 --- a/plugins/node/instrumentation-mongoose/src/utils.ts +++ b/plugins/node/instrumentation-mongoose/src/utils.ts @@ -13,21 +13,27 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { SpanAttributes, SpanStatusCode, diag, Span } from '@opentelemetry/api'; +import { Attributes, SpanStatusCode, diag, Span } from '@opentelemetry/api'; import type { Collection } from 'mongoose'; import { MongooseResponseCustomAttributesFunction } from './types'; import { safeExecuteInTheMiddle } from '@opentelemetry/instrumentation'; -import { SemanticAttributes } from '@opentelemetry/semantic-conventions'; +import { + SEMATTRS_DB_MONGODB_COLLECTION, + SEMATTRS_DB_NAME, + SEMATTRS_DB_USER, + SEMATTRS_NET_PEER_NAME, + SEMATTRS_NET_PEER_PORT, +} from '@opentelemetry/semantic-conventions'; export function getAttributesFromCollection( collection: Collection -): SpanAttributes { +): Attributes { return { - [SemanticAttributes.DB_MONGODB_COLLECTION]: collection.name, - [SemanticAttributes.DB_NAME]: collection.conn.name, - [SemanticAttributes.DB_USER]: collection.conn.user, - [SemanticAttributes.NET_PEER_NAME]: collection.conn.host, - [SemanticAttributes.NET_PEER_PORT]: collection.conn.port, + [SEMATTRS_DB_MONGODB_COLLECTION]: collection.name, + [SEMATTRS_DB_NAME]: collection.conn.name, + [SEMATTRS_DB_USER]: collection.conn.user, + [SEMATTRS_NET_PEER_NAME]: collection.conn.host, + [SEMATTRS_NET_PEER_PORT]: collection.conn.port, }; } diff --git a/plugins/node/instrumentation-mongoose/test/asserts.ts b/plugins/node/instrumentation-mongoose/test/asserts.ts index ad21f9a716..0cf109c80e 100644 --- a/plugins/node/instrumentation-mongoose/test/asserts.ts +++ b/plugins/node/instrumentation-mongoose/test/asserts.ts @@ -15,21 +15,26 @@ */ import { expect } from 'expect'; import { ReadableSpan } from '@opentelemetry/sdk-trace-base'; -import { SemanticAttributes } from '@opentelemetry/semantic-conventions'; +import { + SEMATTRS_DB_MONGODB_COLLECTION, + SEMATTRS_DB_NAME, + SEMATTRS_DB_STATEMENT, + SEMATTRS_DB_SYSTEM, + SEMATTRS_NET_PEER_NAME, + SEMATTRS_NET_PEER_PORT, +} from '@opentelemetry/semantic-conventions'; import { SpanStatusCode } from '@opentelemetry/api'; import { SerializerPayload } from '../src'; import { DB_NAME, MONGO_HOST, MONGO_PORT } from './config'; export const assertSpan = (span: ReadableSpan) => { expect(span.status.code).toBe(SpanStatusCode.UNSET); - expect(span.attributes[SemanticAttributes.DB_SYSTEM]).toEqual('mongoose'); - expect(span.attributes[SemanticAttributes.DB_MONGODB_COLLECTION]).toEqual( - 'users' - ); - expect(span.attributes[SemanticAttributes.DB_NAME]).toEqual(DB_NAME); - expect(span.attributes[SemanticAttributes.NET_PEER_NAME]).toEqual(MONGO_HOST); - expect(span.attributes[SemanticAttributes.NET_PEER_PORT]).toEqual(MONGO_PORT); + expect(span.attributes[SEMATTRS_DB_SYSTEM]).toEqual('mongoose'); + expect(span.attributes[SEMATTRS_DB_MONGODB_COLLECTION]).toEqual('users'); + expect(span.attributes[SEMATTRS_DB_NAME]).toEqual(DB_NAME); + expect(span.attributes[SEMATTRS_NET_PEER_NAME]).toEqual(MONGO_HOST); + expect(span.attributes[SEMATTRS_NET_PEER_PORT]).toEqual(MONGO_PORT); }; export const getStatement = (span: ReadableSpan): SerializerPayload => - JSON.parse(span.attributes[SemanticAttributes.DB_STATEMENT] as string); + JSON.parse(span.attributes[SEMATTRS_DB_STATEMENT] as string); diff --git a/plugins/node/instrumentation-mongoose/test/mongoose.test.ts b/plugins/node/instrumentation-mongoose/test/mongoose.test.ts index 37ce6c70ec..b907300b69 100644 --- a/plugins/node/instrumentation-mongoose/test/mongoose.test.ts +++ b/plugins/node/instrumentation-mongoose/test/mongoose.test.ts @@ -16,7 +16,10 @@ import 'mocha'; import { expect } from 'expect'; import { context, ROOT_CONTEXT } from '@opentelemetry/api'; -import { SemanticAttributes } from '@opentelemetry/semantic-conventions'; +import { + SEMATTRS_DB_OPERATION, + SEMATTRS_DB_STATEMENT, +} from '@opentelemetry/semantic-conventions'; import { MongooseInstrumentation } from '../src'; import { getTestSpans, @@ -89,7 +92,7 @@ describe('mongoose instrumentation', () => { const spans = getTestSpans(); expect(spans.length).toBe(1); assertSpan(spans[0] as ReadableSpan); - expect(spans[0].attributes[SemanticAttributes.DB_OPERATION]).toBe('save'); + expect(spans[0].attributes[SEMATTRS_DB_OPERATION]).toBe('save'); const statement = getStatement(spans[0] as ReadableSpan); expect(statement.document).toEqual(expect.objectContaining(document)); }); @@ -107,7 +110,7 @@ describe('mongoose instrumentation', () => { expect(spans.length).toBe(1); assertSpan(spans[0] as ReadableSpan); - expect(spans[0].attributes[SemanticAttributes.DB_OPERATION]).toBe('save'); + expect(spans[0].attributes[SEMATTRS_DB_OPERATION]).toBe('save'); const statement = getStatement(spans[0] as ReadableSpan); expect(statement.document).toEqual(expect.objectContaining(document)); done(); @@ -120,7 +123,7 @@ describe('mongoose instrumentation', () => { const spans = getTestSpans(); expect(spans.length).toBe(1); assertSpan(spans[0] as ReadableSpan); - expect(spans[0].attributes[SemanticAttributes.DB_OPERATION]).toBe('find'); + expect(spans[0].attributes[SEMATTRS_DB_OPERATION]).toBe('find'); const statement = getStatement(spans[0] as ReadableSpan); expect(statement.condition).toEqual({ id: '_test' }); }); @@ -135,12 +138,12 @@ describe('mongoose instrumentation', () => { expect(spans.length).toBe(2); assertSpan(spans[0] as ReadableSpan); assertSpan(spans[1] as ReadableSpan); - expect(spans[0].attributes[SemanticAttributes.DB_OPERATION]).toBe('find'); - expect(spans[0].attributes[SemanticAttributes.DB_STATEMENT]).toMatch( + expect(spans[0].attributes[SEMATTRS_DB_OPERATION]).toBe('find'); + expect(spans[0].attributes[SEMATTRS_DB_STATEMENT]).toMatch( /.*{"id":"_test[1-2]"}.*/g ); - expect(spans[1].attributes[SemanticAttributes.DB_OPERATION]).toBe('find'); - expect(spans[1].attributes[SemanticAttributes.DB_STATEMENT]).toMatch( + expect(spans[1].attributes[SEMATTRS_DB_OPERATION]).toBe('find'); + expect(spans[1].attributes[SEMATTRS_DB_STATEMENT]).toMatch( /.*{"id":"_test[1-2]"}.*/g ); }); @@ -151,7 +154,7 @@ describe('mongoose instrumentation', () => { const spans = getTestSpans(); expect(spans.length).toBe(1); assertSpan(spans[0] as ReadableSpan); - expect(spans[0].attributes[SemanticAttributes.DB_OPERATION]).toBe('find'); + expect(spans[0].attributes[SEMATTRS_DB_OPERATION]).toBe('find'); const statement = getStatement(spans[0] as ReadableSpan); expect(statement.condition).toEqual({ id: '_test' }); expect(statement.options).toEqual({ @@ -168,7 +171,7 @@ describe('mongoose instrumentation', () => { const spans = getTestSpans(); expect(spans.length).toBe(2); assertSpan(spans[1] as ReadableSpan); - expect(spans[1].attributes[SemanticAttributes.DB_OPERATION]).toBe('remove'); + expect(spans[1].attributes[SEMATTRS_DB_OPERATION]).toBe('remove'); }); it('instrumenting remove operation with callbacks [deprecated]', done => { @@ -177,9 +180,7 @@ describe('mongoose instrumentation', () => { const spans = getTestSpans(); expect(spans.length).toBe(2); assertSpan(spans[1] as ReadableSpan); - expect(spans[1].attributes[SemanticAttributes.DB_OPERATION]).toBe( - 'remove' - ); + expect(spans[1].attributes[SEMATTRS_DB_OPERATION]).toBe('remove'); expect(getStatement(spans[1] as ReadableSpan).options).toEqual({ overwrite: true, }); @@ -194,9 +195,7 @@ describe('mongoose instrumentation', () => { const spans = getTestSpans(); expect(spans.length).toBe(1); assertSpan(spans[0] as ReadableSpan); - expect(spans[0].attributes[SemanticAttributes.DB_OPERATION]).toBe( - 'deleteOne' - ); + expect(spans[0].attributes[SEMATTRS_DB_OPERATION]).toBe('deleteOne'); }); it('instrumenting updateOne operation on models', async () => { @@ -206,9 +205,7 @@ describe('mongoose instrumentation', () => { const spans = getTestSpans(); expect(spans.length).toBe(2); assertSpan(spans[1] as ReadableSpan); - expect(spans[1].attributes[SemanticAttributes.DB_OPERATION]).toBe( - 'updateOne' - ); + expect(spans[1].attributes[SEMATTRS_DB_OPERATION]).toBe('updateOne'); const statement = getStatement(spans[1] as ReadableSpan); expect(statement.options).toEqual({ skip: 0 }); @@ -226,9 +223,7 @@ describe('mongoose instrumentation', () => { const spans = getTestSpans(); expect(spans.length).toBe(1); assertSpan(spans[0] as ReadableSpan); - expect(spans[0].attributes[SemanticAttributes.DB_OPERATION]).toBe( - 'updateOne' - ); + expect(spans[0].attributes[SEMATTRS_DB_OPERATION]).toBe('updateOne'); const statement = getStatement(spans[0] as ReadableSpan); expect(statement.options).toEqual({ skip: 0 }); @@ -242,7 +237,7 @@ describe('mongoose instrumentation', () => { const spans = getTestSpans(); expect(spans.length).toBe(1); assertSpan(spans[0] as ReadableSpan); - expect(spans[0].attributes[SemanticAttributes.DB_OPERATION]).toBe('count'); + expect(spans[0].attributes[SEMATTRS_DB_OPERATION]).toBe('count'); const statement = getStatement(spans[0] as ReadableSpan); expect(statement.options).toEqual({}); expect(statement.condition).toEqual({}); @@ -254,9 +249,7 @@ describe('mongoose instrumentation', () => { const spans = getTestSpans(); expect(spans.length).toBe(1); assertSpan(spans[0] as ReadableSpan); - expect(spans[0].attributes[SemanticAttributes.DB_OPERATION]).toBe( - 'countDocuments' - ); + expect(spans[0].attributes[SEMATTRS_DB_OPERATION]).toBe('countDocuments'); const statement = getStatement(spans[0] as ReadableSpan); expect(statement.options).toEqual({}); expect(statement.condition).toEqual({ email: 'john.doe@example.com' }); @@ -268,7 +261,7 @@ describe('mongoose instrumentation', () => { const spans = getTestSpans(); expect(spans.length).toBe(1); assertSpan(spans[0] as ReadableSpan); - expect(spans[0].attributes[SemanticAttributes.DB_OPERATION]).toBe( + expect(spans[0].attributes[SEMATTRS_DB_OPERATION]).toBe( 'estimatedDocumentCount' ); const statement = getStatement(spans[0] as ReadableSpan); @@ -282,9 +275,7 @@ describe('mongoose instrumentation', () => { const spans = getTestSpans(); expect(spans.length).toBe(1); assertSpan(spans[0] as ReadableSpan); - expect(spans[0].attributes[SemanticAttributes.DB_OPERATION]).toBe( - 'deleteMany' - ); + expect(spans[0].attributes[SEMATTRS_DB_OPERATION]).toBe('deleteMany'); const statement = getStatement(spans[0] as ReadableSpan); expect(statement.options).toEqual({}); expect(statement.condition).toEqual({}); @@ -296,9 +287,7 @@ describe('mongoose instrumentation', () => { const spans = getTestSpans(); expect(spans.length).toBe(1); assertSpan(spans[0] as ReadableSpan); - expect(spans[0].attributes[SemanticAttributes.DB_OPERATION]).toBe( - 'findOne' - ); + expect(spans[0].attributes[SEMATTRS_DB_OPERATION]).toBe('findOne'); const statement = getStatement(spans[0] as ReadableSpan); expect(statement.options).toEqual({}); expect(statement.condition).toEqual({ email: 'john.doe@example.com' }); @@ -313,7 +302,7 @@ describe('mongoose instrumentation', () => { const spans = getTestSpans(); expect(spans.length).toBe(1); assertSpan(spans[0] as ReadableSpan); - expect(spans[0].attributes[SemanticAttributes.DB_OPERATION]).toBe('update'); + expect(spans[0].attributes[SEMATTRS_DB_OPERATION]).toBe('update'); const statement = getStatement(spans[0] as ReadableSpan); expect(statement.options).toEqual({}); expect(statement.condition).toEqual({ email: 'john.doe@example.com' }); @@ -326,9 +315,7 @@ describe('mongoose instrumentation', () => { const spans = getTestSpans(); expect(spans.length).toBe(1); assertSpan(spans[0] as ReadableSpan); - expect(spans[0].attributes[SemanticAttributes.DB_OPERATION]).toBe( - 'updateOne' - ); + expect(spans[0].attributes[SEMATTRS_DB_OPERATION]).toBe('updateOne'); const statement = getStatement(spans[0] as ReadableSpan); expect(statement.options).toEqual({}); expect(statement.condition).toEqual({ email: 'john.doe@example.com' }); @@ -341,9 +328,7 @@ describe('mongoose instrumentation', () => { const spans = getTestSpans(); expect(spans.length).toBe(1); assertSpan(spans[0] as ReadableSpan); - expect(spans[0].attributes[SemanticAttributes.DB_OPERATION]).toBe( - 'updateMany' - ); + expect(spans[0].attributes[SEMATTRS_DB_OPERATION]).toBe('updateMany'); const statement = getStatement(spans[0] as ReadableSpan); expect(statement.options).toEqual({}); expect(statement.condition).toEqual({ age: 18 }); @@ -356,9 +341,7 @@ describe('mongoose instrumentation', () => { const spans = getTestSpans(); expect(spans.length).toBe(1); assertSpan(spans[0] as ReadableSpan); - expect(spans[0].attributes[SemanticAttributes.DB_OPERATION]).toBe( - 'findOneAndDelete' - ); + expect(spans[0].attributes[SEMATTRS_DB_OPERATION]).toBe('findOneAndDelete'); const statement = getStatement(spans[0] as ReadableSpan); expect(statement.options).toEqual({}); expect(statement.condition).toEqual({ email: 'john.doe@example.com' }); @@ -374,12 +357,8 @@ describe('mongoose instrumentation', () => { expect(spans.length).toBe(2); assertSpan(spans[0] as ReadableSpan); assertSpan(spans[1] as ReadableSpan); - expect(spans[0].attributes[SemanticAttributes.DB_OPERATION]).toBe( - 'findOne' - ); - expect(spans[1].attributes[SemanticAttributes.DB_OPERATION]).toBe( - 'findOneAndUpdate' - ); + expect(spans[0].attributes[SEMATTRS_DB_OPERATION]).toBe('findOne'); + expect(spans[1].attributes[SEMATTRS_DB_OPERATION]).toBe('findOneAndUpdate'); const statement = getStatement(spans[1] as ReadableSpan); expect(statement.options).toEqual({}); expect(statement.condition).toEqual({ email: 'john.doe@example.com' }); @@ -392,9 +371,7 @@ describe('mongoose instrumentation', () => { const spans = getTestSpans(); expect(spans.length).toBe(1); assertSpan(spans[0] as ReadableSpan); - expect(spans[0].attributes[SemanticAttributes.DB_OPERATION]).toBe( - 'findOneAndRemove' - ); + expect(spans[0].attributes[SEMATTRS_DB_OPERATION]).toBe('findOneAndRemove'); const statement = getStatement(spans[0] as ReadableSpan); expect(statement.options).toEqual({}); expect(statement.condition).toEqual({ email: 'john.doe@example.com' }); @@ -411,7 +388,7 @@ describe('mongoose instrumentation', () => { const spans = getTestSpans(); expect(spans.length).toBe(1); assertSpan(spans[0] as ReadableSpan); - expect(spans[0].attributes[SemanticAttributes.DB_OPERATION]).toBe('save'); + expect(spans[0].attributes[SEMATTRS_DB_OPERATION]).toBe('save'); const statement = getStatement(spans[0] as ReadableSpan); expect(statement.options).toEqual({}); expect(statement.document).toEqual(expect.objectContaining(document)); @@ -426,9 +403,7 @@ describe('mongoose instrumentation', () => { const spans = getTestSpans(); expect(spans.length).toBe(1); assertSpan(spans[0] as ReadableSpan); - expect(spans[0].attributes[SemanticAttributes.DB_OPERATION]).toBe( - 'aggregate' - ); + expect(spans[0].attributes[SEMATTRS_DB_OPERATION]).toBe('aggregate'); const statement = getStatement(spans[0] as ReadableSpan); expect(statement.aggregatePipeline).toEqual([ { $match: { firstName: 'John' } }, @@ -446,9 +421,7 @@ describe('mongoose instrumentation', () => { const spans = getTestSpans(); expect(spans.length).toBe(1); assertSpan(spans[0] as ReadableSpan); - expect(spans[0].attributes[SemanticAttributes.DB_OPERATION]).toBe( - 'aggregate' - ); + expect(spans[0].attributes[SEMATTRS_DB_OPERATION]).toBe('aggregate'); const statement = getStatement(spans[0] as ReadableSpan); expect(statement.aggregatePipeline).toEqual([ { $match: { firstName: 'John' } }, @@ -483,9 +456,7 @@ describe('mongoose instrumentation', () => { const spans = getTestSpans(); expect(spans.length).toBe(1); assertSpan(spans[0] as ReadableSpan); - expect(spans[0].attributes[SemanticAttributes.DB_STATEMENT]).toBe( - undefined - ); + expect(spans[0].attributes[SEMATTRS_DB_STATEMENT]).toBe(undefined); }); it('projection is sent to serializer', async () => { @@ -503,7 +474,7 @@ describe('mongoose instrumentation', () => { expect(spans.length).toBe(1); assertSpan(spans[0] as ReadableSpan); const reqPayload = JSON.parse( - spans[0].attributes[SemanticAttributes.DB_STATEMENT] as string + spans[0].attributes[SEMATTRS_DB_STATEMENT] as string ); expect(reqPayload.fields).toStrictEqual(projection); }); diff --git a/plugins/node/instrumentation-runtime-node/LICENSE b/plugins/node/instrumentation-runtime-node/LICENSE index e50e8c80f9..261eeb9e9f 100644 --- a/plugins/node/instrumentation-runtime-node/LICENSE +++ b/plugins/node/instrumentation-runtime-node/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/plugins/node/instrumentation-tedious/LICENSE b/plugins/node/instrumentation-tedious/LICENSE index e50e8c80f9..261eeb9e9f 100644 --- a/plugins/node/instrumentation-tedious/LICENSE +++ b/plugins/node/instrumentation-tedious/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/plugins/node/instrumentation-undici/.tav.yml b/plugins/node/instrumentation-undici/.tav.yml index 9ef69e2462..88b92a7898 100644 --- a/plugins/node/instrumentation-undici/.tav.yml +++ b/plugins/node/instrumentation-undici/.tav.yml @@ -1,8 +1,12 @@ undici: jobs: - - versions: ">=5 <6" + - versions: + include: ">=5.12.0 <6" + mode: max-7 node: '>=14' commands: npm run test - - versions: ">=6 <7" + - versions: + include: ">=6 <7" + mode: max-7 node: '>=18' commands: npm run test diff --git a/plugins/node/instrumentation-undici/README.md b/plugins/node/instrumentation-undici/README.md index 38b6fd6e9e..08a7128404 100644 --- a/plugins/node/instrumentation-undici/README.md +++ b/plugins/node/instrumentation-undici/README.md @@ -14,6 +14,10 @@ If you're looking the instrumentation for browser's `fetch` API it is located at npm install --save @opentelemetry/instrumentation-undici ``` +## Supported Versions + +- `undici@>=5.12.0` + ## Usage OpenTelemetry Undici/fetch Instrumentation allows the user to automatically collect trace data and export them to their backend of choice, to give observability to distributed systems. diff --git a/plugins/node/instrumentation-undici/package.json b/plugins/node/instrumentation-undici/package.json index b235be769a..fd21b60b47 100644 --- a/plugins/node/instrumentation-undici/package.json +++ b/plugins/node/instrumentation-undici/package.json @@ -1,7 +1,7 @@ { "name": "@opentelemetry/instrumentation-undici", "version": "0.1.0", - "description": "OpenTelemetry undici/fetch automatic instrumentation package.", + "description": "OpenTelemetry instrumentation for undici and Node.js fetch().", "main": "build/src/index.js", "types": "build/src/index.d.ts", "repository": "open-telemetry/opentelemetry-js-contrib", @@ -14,7 +14,6 @@ "clean": "rimraf build/*", "lint": "eslint . --ext .ts", "lint:fix": "eslint . --ext .ts --fix", - "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../../", "watch": "tsc -w", "precompile": "tsc --version && lerna run version:update --scope @opentelemetry/instrumentation-undici --include-dependencies", "prewatch": "npm run precompile", @@ -53,10 +52,10 @@ "rimraf": "5.0.5", "semver": "^7.6.0", "superagent": "8.0.9", - "test-all-versions": "6.0.0", + "test-all-versions": "6.1.0", "ts-mocha": "10.0.0", "typescript": "4.4.4", - "undici": "6.10.1" + "undici": "6.11.1" }, "peerDependencies": { "@opentelemetry/api": "^1.7.0" diff --git a/plugins/node/instrumentation-undici/src/undici.ts b/plugins/node/instrumentation-undici/src/undici.ts index 262bea42cd..0fa07f97a3 100644 --- a/plugins/node/instrumentation-undici/src/undici.ts +++ b/plugins/node/instrumentation-undici/src/undici.ts @@ -270,10 +270,13 @@ export class UndiciInstrumentation extends InstrumentationBase { for (let i = 0; i < headerEntries.length; i++) { const [k, v] = headerEntries[i]; - if (typeof request.headers === 'string') { - request.headers += `${k}: ${v}\r\n`; - } else { + if (typeof request.addHeader === 'function') { request.addHeader(k, v); + } else if (typeof request.headers === 'string') { + request.headers += `${k}: ${v}\r\n`; + } else if (Array.isArray(request.headers)) { + // undici@6.11.0 accidentally, briefly removed `request.addHeader()`. + request.headers.push(k, v); } } this._recordFromReq.set(request, { span, attributes, startTime }); diff --git a/plugins/node/instrumentation-undici/test/undici.test.ts b/plugins/node/instrumentation-undici/test/undici.test.ts index fd48803a3f..c125b2e189 100644 --- a/plugins/node/instrumentation-undici/test/undici.test.ts +++ b/plugins/node/instrumentation-undici/test/undici.test.ts @@ -38,8 +38,6 @@ import { assertSpan } from './utils/assertSpan'; import type { fetch, stream, request, Client, Dispatcher } from 'undici'; -type PromisedValue = T extends Promise ? R : never; - const instrumentation = new UndiciInstrumentation(); instrumentation.enable(); instrumentation.disable(); @@ -121,6 +119,10 @@ describe('UndiciInstrumentation `undici` tests', function () { propagation.disable(); mockServer.mockListener(undefined); mockServer.stop(done); + + // Close kept-alive sockets. This can save a 4s keep-alive delay before the + // process exits. + (undici as any).getGlobalDispatcher().close(); }); beforeEach(function () { @@ -217,37 +219,36 @@ describe('UndiciInstrumentation `undici` tests', function () { 'foo-client': 'bar', }; - // In version v5 if `undici` you get the following error when requesting with a method - // that is not one of the known ones in uppercase. Using - // - // SocketError: other side closed - // at Socket.onSocketEnd (node_modules/undici/lib/client.js:1118:22) - // at endReadableNT (internal/streams/readable.js:1333:12) - // at processTicksAndRejections (internal/process/task_queues.js:82:21) - let firstQueryResponse: PromisedValue>; - let secondQueryResponse: PromisedValue>; + const queryRequestUrl = `${protocol}://${hostname}:${mockServer.port}/?query=test`; + let firstQueryResponse; try { - const queryRequestUrl = `${protocol}://${hostname}:${mockServer.port}/?query=test`; firstQueryResponse = await undici.request(queryRequestUrl, { headers, // @ts-expect-error - method type expects in uppercase method: 'get', }); - await consumeResponseBody(firstQueryResponse.body); - - secondQueryResponse = await undici.request(queryRequestUrl, { - headers, - // @ts-expect-error - method type expects known HTTP method (GET, POST, PUT, ...) - method: 'custom', - }); - await consumeResponseBody(secondQueryResponse.body); - } catch (undiciErr) { - const { stack } = undiciErr as Error; - - if (stack?.startsWith('SocketError: other side closed')) { - this.skip(); - } + } catch (err: any) { + // This request is using a bogus HTTP method `get`. If (a) using Node.js + // v14, v16, or early v18.x versions and (b) this request is re-using + // a socket (from an earlier keep-alive request in this test file), + // then Node.js will emit 'end' on the socket. Undici then throws + // `SocketError: other side closed`. Given this is only for old Node.js + // versions and for this rare case of using a bogus HTTP method, we will + // skip out of this test instead of attempting to fully understand it. + assert.strictEqual(err.message, 'other side closed'); + this.skip(); + } + if (!firstQueryResponse) { + return; } + await consumeResponseBody(firstQueryResponse.body); + + const secondQueryResponse = await undici.request(queryRequestUrl, { + headers, + // @ts-expect-error - method type expects known HTTP method (GET, POST, PUT, ...) + method: 'custom', + }); + await consumeResponseBody(secondQueryResponse.body); assert.ok( firstQueryResponse!.headers['propagation-error'] === undefined, diff --git a/plugins/node/opentelemetry-instrumentation-aws-lambda/LICENSE b/plugins/node/opentelemetry-instrumentation-aws-lambda/LICENSE index e50e8c80f9..261eeb9e9f 100644 --- a/plugins/node/opentelemetry-instrumentation-aws-lambda/LICENSE +++ b/plugins/node/opentelemetry-instrumentation-aws-lambda/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/plugins/node/opentelemetry-instrumentation-aws-sdk/LICENSE b/plugins/node/opentelemetry-instrumentation-aws-sdk/LICENSE index e50e8c80f9..261eeb9e9f 100644 --- a/plugins/node/opentelemetry-instrumentation-aws-sdk/LICENSE +++ b/plugins/node/opentelemetry-instrumentation-aws-sdk/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/plugins/node/opentelemetry-instrumentation-bunyan/LICENSE b/plugins/node/opentelemetry-instrumentation-bunyan/LICENSE index e50e8c80f9..261eeb9e9f 100644 --- a/plugins/node/opentelemetry-instrumentation-bunyan/LICENSE +++ b/plugins/node/opentelemetry-instrumentation-bunyan/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/plugins/node/opentelemetry-instrumentation-cassandra/LICENSE b/plugins/node/opentelemetry-instrumentation-cassandra/LICENSE index e50e8c80f9..261eeb9e9f 100644 --- a/plugins/node/opentelemetry-instrumentation-cassandra/LICENSE +++ b/plugins/node/opentelemetry-instrumentation-cassandra/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/plugins/node/opentelemetry-instrumentation-connect/LICENSE b/plugins/node/opentelemetry-instrumentation-connect/LICENSE index e50e8c80f9..261eeb9e9f 100644 --- a/plugins/node/opentelemetry-instrumentation-connect/LICENSE +++ b/plugins/node/opentelemetry-instrumentation-connect/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/plugins/node/opentelemetry-instrumentation-dns/LICENSE b/plugins/node/opentelemetry-instrumentation-dns/LICENSE index e50e8c80f9..261eeb9e9f 100644 --- a/plugins/node/opentelemetry-instrumentation-dns/LICENSE +++ b/plugins/node/opentelemetry-instrumentation-dns/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/plugins/node/opentelemetry-instrumentation-express/LICENSE b/plugins/node/opentelemetry-instrumentation-express/LICENSE index e50e8c80f9..261eeb9e9f 100644 --- a/plugins/node/opentelemetry-instrumentation-express/LICENSE +++ b/plugins/node/opentelemetry-instrumentation-express/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/plugins/node/opentelemetry-instrumentation-fastify/LICENSE b/plugins/node/opentelemetry-instrumentation-fastify/LICENSE index e50e8c80f9..261eeb9e9f 100644 --- a/plugins/node/opentelemetry-instrumentation-fastify/LICENSE +++ b/plugins/node/opentelemetry-instrumentation-fastify/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/plugins/node/opentelemetry-instrumentation-generic-pool/LICENSE b/plugins/node/opentelemetry-instrumentation-generic-pool/LICENSE index e50e8c80f9..261eeb9e9f 100644 --- a/plugins/node/opentelemetry-instrumentation-generic-pool/LICENSE +++ b/plugins/node/opentelemetry-instrumentation-generic-pool/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/plugins/node/opentelemetry-instrumentation-graphql/LICENSE b/plugins/node/opentelemetry-instrumentation-graphql/LICENSE index e50e8c80f9..261eeb9e9f 100644 --- a/plugins/node/opentelemetry-instrumentation-graphql/LICENSE +++ b/plugins/node/opentelemetry-instrumentation-graphql/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/plugins/node/opentelemetry-instrumentation-hapi/LICENSE b/plugins/node/opentelemetry-instrumentation-hapi/LICENSE index e50e8c80f9..261eeb9e9f 100644 --- a/plugins/node/opentelemetry-instrumentation-hapi/LICENSE +++ b/plugins/node/opentelemetry-instrumentation-hapi/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/plugins/node/opentelemetry-instrumentation-ioredis/LICENSE b/plugins/node/opentelemetry-instrumentation-ioredis/LICENSE index e50e8c80f9..261eeb9e9f 100644 --- a/plugins/node/opentelemetry-instrumentation-ioredis/LICENSE +++ b/plugins/node/opentelemetry-instrumentation-ioredis/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/plugins/node/opentelemetry-instrumentation-ioredis/package.json b/plugins/node/opentelemetry-instrumentation-ioredis/package.json index 688c37abba..4ecc2eb1b3 100644 --- a/plugins/node/opentelemetry-instrumentation-ioredis/package.json +++ b/plugins/node/opentelemetry-instrumentation-ioredis/package.json @@ -63,13 +63,13 @@ "sinon": "15.2.0", "test-all-versions": "6.1.0", "ts-mocha": "10.0.0", - "typescript": "4.4.4" + "typescript": "4.4.4", + "@types/ioredis4": "npm:@types/ioredis@4.28.10" }, "dependencies": { "@opentelemetry/instrumentation": "^0.50.0", "@opentelemetry/redis-common": "^0.36.1", - "@opentelemetry/semantic-conventions": "^1.0.0", - "@types/ioredis4": "npm:@types/ioredis@^4.28.10" + "@opentelemetry/semantic-conventions": "^1.0.0" }, "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-ioredis#readme" } diff --git a/plugins/node/opentelemetry-instrumentation-knex/LICENSE b/plugins/node/opentelemetry-instrumentation-knex/LICENSE index e50e8c80f9..261eeb9e9f 100644 --- a/plugins/node/opentelemetry-instrumentation-knex/LICENSE +++ b/plugins/node/opentelemetry-instrumentation-knex/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/plugins/node/opentelemetry-instrumentation-knex/README.md b/plugins/node/opentelemetry-instrumentation-knex/README.md index 05537459cc..ba3e97846e 100644 --- a/plugins/node/opentelemetry-instrumentation-knex/README.md +++ b/plugins/node/opentelemetry-instrumentation-knex/README.md @@ -48,6 +48,24 @@ registerInstrumentations({ | ------- | ---- | ------- | ----------- | | `maxQueryLength` | `number` | `100` | Truncate `db.statement` attribute to a maximum length. If the statement is truncated `'..'` is added to it's end. Default `1022`. `-1` leaves `db.statement` untouched. | +## Semantic Conventions + +This package uses `@opentelemetry/semantic-conventions` version `1.22+`, which implements Semantic Convention [Version 1.7.0](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.7.0/semantic_conventions/README.md) + +Attributes collected: + +| Attribute | Short Description | +| ----------------------- | ------------------------------------------------------------------------------ | +| `db.name` | This attribute is used to report the name of the database being accessed. | +| `db.operation` | The name of the operation being executed. | +| `db.sql.table` | The name of the primary table that the operation is acting upon. | +| `db.statement` | The database statement being executed. | +| `db.system` | An identifier for the database management system (DBMS) product being used. | +| `db.user` | Username for accessing the database. | +| `net.peer.name` | Remote hostname or similar. | +| `net.peer.port` | Remote port number. | +| `net.transport` | Transport protocol used. | + ## Useful links - For more information on OpenTelemetry, visit: diff --git a/plugins/node/opentelemetry-instrumentation-knex/package.json b/plugins/node/opentelemetry-instrumentation-knex/package.json index 0248695c58..5a8b7078c6 100644 --- a/plugins/node/opentelemetry-instrumentation-knex/package.json +++ b/plugins/node/opentelemetry-instrumentation-knex/package.json @@ -58,7 +58,7 @@ }, "dependencies": { "@opentelemetry/instrumentation": "^0.50.0", - "@opentelemetry/semantic-conventions": "^1.0.0" + "@opentelemetry/semantic-conventions": "^1.22.0" }, "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-knex#readme" } diff --git a/plugins/node/opentelemetry-instrumentation-knex/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-knex/src/instrumentation.ts index 257232f278..bb6e6114b5 100644 --- a/plugins/node/opentelemetry-instrumentation-knex/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-knex/src/instrumentation.ts @@ -23,7 +23,17 @@ import { InstrumentationNodeModuleFile, isWrapped, } from '@opentelemetry/instrumentation'; -import { SemanticAttributes } from '@opentelemetry/semantic-conventions'; +import { + SEMATTRS_DB_NAME, + SEMATTRS_DB_OPERATION, + SEMATTRS_DB_SQL_TABLE, + SEMATTRS_DB_STATEMENT, + SEMATTRS_DB_SYSTEM, + SEMATTRS_DB_USER, + SEMATTRS_NET_PEER_NAME, + SEMATTRS_NET_PEER_PORT, + SEMATTRS_NET_TRANSPORT, +} from '@opentelemetry/semantic-conventions'; import * as utils from './utils'; import * as types from './types'; @@ -144,18 +154,18 @@ export class KnexInstrumentation extends InstrumentationBase { const attributes: api.SpanAttributes = { 'knex.version': moduleVersion, - [SemanticAttributes.DB_SYSTEM]: utils.mapSystem(config.client), - [SemanticAttributes.DB_SQL_TABLE]: table, - [SemanticAttributes.DB_OPERATION]: operation, - [SemanticAttributes.DB_USER]: config?.connection?.user, - [SemanticAttributes.DB_NAME]: name, - [SemanticAttributes.NET_PEER_NAME]: config?.connection?.host, - [SemanticAttributes.NET_PEER_PORT]: config?.connection?.port, - [SemanticAttributes.NET_TRANSPORT]: + [SEMATTRS_DB_SYSTEM]: utils.mapSystem(config.client), + [SEMATTRS_DB_SQL_TABLE]: table, + [SEMATTRS_DB_OPERATION]: operation, + [SEMATTRS_DB_USER]: config?.connection?.user, + [SEMATTRS_DB_NAME]: name, + [SEMATTRS_NET_PEER_NAME]: config?.connection?.host, + [SEMATTRS_NET_PEER_PORT]: config?.connection?.port, + [SEMATTRS_NET_TRANSPORT]: config?.connection?.filename === ':memory:' ? 'inproc' : undefined, }; if (maxLen !== 0) { - attributes[SemanticAttributes.DB_STATEMENT] = utils.limitLength( + attributes[SEMATTRS_DB_STATEMENT] = utils.limitLength( query?.sql, maxLen ); diff --git a/plugins/node/opentelemetry-instrumentation-knex/src/utils.ts b/plugins/node/opentelemetry-instrumentation-knex/src/utils.ts index 6c7e6fbdba..da640ceae3 100644 --- a/plugins/node/opentelemetry-instrumentation-knex/src/utils.ts +++ b/plugins/node/opentelemetry-instrumentation-knex/src/utils.ts @@ -14,7 +14,10 @@ * limitations under the License. */ -import { DbSystemValues } from '@opentelemetry/semantic-conventions'; +import { + DBSYSTEMVALUES_SQLITE, + DBSYSTEMVALUES_POSTGRESQL, +} from '@opentelemetry/semantic-conventions'; type Exception = { new (message: string): Exception; @@ -52,8 +55,8 @@ export const cloneErrorWithNewMessage = (err: Exception, message: string) => { }; const systemMap = new Map([ - ['sqlite3', DbSystemValues.SQLITE], - ['pg', DbSystemValues.POSTGRESQL], + ['sqlite3', DBSYSTEMVALUES_SQLITE], + ['pg', DBSYSTEMVALUES_POSTGRESQL], ]); export const mapSystem = (knexSystem: string) => { return systemMap.get(knexSystem) || knexSystem; diff --git a/plugins/node/opentelemetry-instrumentation-koa/LICENSE b/plugins/node/opentelemetry-instrumentation-koa/LICENSE index e50e8c80f9..261eeb9e9f 100644 --- a/plugins/node/opentelemetry-instrumentation-koa/LICENSE +++ b/plugins/node/opentelemetry-instrumentation-koa/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/plugins/node/opentelemetry-instrumentation-memcached/LICENSE b/plugins/node/opentelemetry-instrumentation-memcached/LICENSE index e50e8c80f9..261eeb9e9f 100644 --- a/plugins/node/opentelemetry-instrumentation-memcached/LICENSE +++ b/plugins/node/opentelemetry-instrumentation-memcached/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/plugins/node/opentelemetry-instrumentation-mongodb/LICENSE b/plugins/node/opentelemetry-instrumentation-mongodb/LICENSE index e50e8c80f9..261eeb9e9f 100644 --- a/plugins/node/opentelemetry-instrumentation-mongodb/LICENSE +++ b/plugins/node/opentelemetry-instrumentation-mongodb/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/plugins/node/opentelemetry-instrumentation-mongodb/README.md b/plugins/node/opentelemetry-instrumentation-mongodb/README.md index 07b50e95d2..efec965ee9 100644 --- a/plugins/node/opentelemetry-instrumentation-mongodb/README.md +++ b/plugins/node/opentelemetry-instrumentation-mongodb/README.md @@ -55,6 +55,22 @@ Mongodb instrumentation has few options available to choose from. You can set th | `responseHook` | `MongoDBInstrumentationExecutionResponseHook` (function) | Function for adding custom attributes from db response | | `dbStatementSerializer` | `DbStatementSerializer` (function) | Custom serializer function for the db.statement tag | +## Semantic Conventions + +This package uses `@opentelemetry/semantic-conventions` version `1.22+`, which implements Semantic Convention [Version 1.7.0](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.7.0/semantic_conventions/README.md) + +Attributes collected: + +| Attribute | Short Description | +| ----------------------- | ------------------------------------------------------------------------------ | +| `db.system` | An identifier for the database management system (DBMS) product being used. | +| `db.connection_string` | The connection string used to connect to the database. | +| `db.name` | This attribute is used to report the name of the database being accessed. | +| `db.operation` | The name of the operation being executed. | +| `db.mongodb.collection` | The collection being accessed within the database stated in `db.name`. | +| `net.peer.name` | Remote hostname or similar. | +| `net.peer.port` | Remote port number. | + ## Useful links - For more information on OpenTelemetry, visit: diff --git a/plugins/node/opentelemetry-instrumentation-mongodb/package.json b/plugins/node/opentelemetry-instrumentation-mongodb/package.json index 967c35c088..f3d704c7da 100644 --- a/plugins/node/opentelemetry-instrumentation-mongodb/package.json +++ b/plugins/node/opentelemetry-instrumentation-mongodb/package.json @@ -68,7 +68,7 @@ "dependencies": { "@opentelemetry/instrumentation": "^0.50.0", "@opentelemetry/sdk-metrics": "^1.9.1", - "@opentelemetry/semantic-conventions": "^1.0.0" + "@opentelemetry/semantic-conventions": "^1.22.0" }, "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-mongodb#readme" } diff --git a/plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts index 0a1dad9af9..d5239d9706 100644 --- a/plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts @@ -29,8 +29,15 @@ import { safeExecuteInTheMiddle, } from '@opentelemetry/instrumentation'; import { - DbSystemValues, - SemanticAttributes, + DBSYSTEMVALUES_MONGODB, + SEMATTRS_DB_CONNECTION_STRING, + SEMATTRS_DB_MONGODB_COLLECTION, + SEMATTRS_DB_NAME, + SEMATTRS_DB_OPERATION, + SEMATTRS_DB_STATEMENT, + SEMATTRS_DB_SYSTEM, + SEMATTRS_NET_PEER_NAME, + SEMATTRS_NET_PEER_PORT, } from '@opentelemetry/semantic-conventions'; import { MongoDBInstrumentationConfig, CommandResult } from './types'; import { @@ -898,18 +905,18 @@ export class MongoDBInstrumentation extends InstrumentationBase { ) { // add database related attributes span.setAttributes({ - [SemanticAttributes.DB_SYSTEM]: DbSystemValues.MONGODB, - [SemanticAttributes.DB_NAME]: dbName, - [SemanticAttributes.DB_MONGODB_COLLECTION]: dbCollection, - [SemanticAttributes.DB_OPERATION]: operation, - [SemanticAttributes.DB_CONNECTION_STRING]: `mongodb://${host}:${port}/${dbName}`, + [SEMATTRS_DB_SYSTEM]: DBSYSTEMVALUES_MONGODB, + [SEMATTRS_DB_NAME]: dbName, + [SEMATTRS_DB_MONGODB_COLLECTION]: dbCollection, + [SEMATTRS_DB_OPERATION]: operation, + [SEMATTRS_DB_CONNECTION_STRING]: `mongodb://${host}:${port}/${dbName}`, }); if (host && port) { - span.setAttribute(SemanticAttributes.NET_PEER_NAME, host); + span.setAttribute(SEMATTRS_NET_PEER_NAME, host); const portNumber = parseInt(port, 10); if (!isNaN(portNumber)) { - span.setAttribute(SemanticAttributes.NET_PEER_PORT, portNumber); + span.setAttribute(SEMATTRS_NET_PEER_PORT, portNumber); } } if (!commandObj) return; @@ -921,7 +928,7 @@ export class MongoDBInstrumentation extends InstrumentationBase { safeExecuteInTheMiddle( () => { const query = dbStatementSerializer(commandObj); - span.setAttribute(SemanticAttributes.DB_STATEMENT, query); + span.setAttribute(SEMATTRS_DB_STATEMENT, query); }, err => { if (err) { diff --git a/plugins/node/opentelemetry-instrumentation-mysql/LICENSE b/plugins/node/opentelemetry-instrumentation-mysql/LICENSE index e50e8c80f9..261eeb9e9f 100644 --- a/plugins/node/opentelemetry-instrumentation-mysql/LICENSE +++ b/plugins/node/opentelemetry-instrumentation-mysql/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/plugins/node/opentelemetry-instrumentation-mysql/README.md b/plugins/node/opentelemetry-instrumentation-mysql/README.md index 6b86badf8e..e632521fb6 100644 --- a/plugins/node/opentelemetry-instrumentation-mysql/README.md +++ b/plugins/node/opentelemetry-instrumentation-mysql/README.md @@ -49,6 +49,23 @@ See [examples/mysql](https://github.com/open-telemetry/opentelemetry-js-contrib/ | [`enhancedDatabaseReporting`](./src/types.ts#L24) | `boolean` | `false` | If true, an attribute containing the query's parameters will be attached the spans generated to represent the query | | +## Semantic Conventions + +This package uses `@opentelemetry/semantic-conventions` version `1.22+`, which implements Semantic Convention [Version 1.7.0](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.7.0/semantic_conventions/README.md) + +Attributes collected: + +| Attribute | Short Description | +| ----------------------- | ------------------------------------------------------------------------------ | +| `db.connection_string` | The connection string used to connect to the database. | +| `db.name` | This attribute is used to report the name of the database being accessed. | +| `db.operation` | The name of the operation being executed. | +| `db.statement` | The database statement being executed. | +| `db.system` | An identifier for the database management system (DBMS) product being used. | +| `db.user` | Username for accessing the database. | +| `net.peer.name` | Remote hostname or similar. | +| `net.peer.port` | Remote port number. | + ## Useful links - For more information on OpenTelemetry, visit: diff --git a/plugins/node/opentelemetry-instrumentation-mysql/package.json b/plugins/node/opentelemetry-instrumentation-mysql/package.json index fccb9fe6ae..13d2c6d3af 100644 --- a/plugins/node/opentelemetry-instrumentation-mysql/package.json +++ b/plugins/node/opentelemetry-instrumentation-mysql/package.json @@ -60,7 +60,7 @@ }, "dependencies": { "@opentelemetry/instrumentation": "^0.50.0", - "@opentelemetry/semantic-conventions": "^1.0.0", + "@opentelemetry/semantic-conventions": "^1.22.0", "@types/mysql": "2.15.22" }, "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-mysql#readme" diff --git a/plugins/node/opentelemetry-instrumentation-mysql/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-mysql/src/instrumentation.ts index 8ef20b9e2b..9ff48fd684 100644 --- a/plugins/node/opentelemetry-instrumentation-mysql/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-mysql/src/instrumentation.ts @@ -29,8 +29,9 @@ import { isWrapped, } from '@opentelemetry/instrumentation'; import { - DbSystemValues, - SemanticAttributes, + DBSYSTEMVALUES_MYSQL, + SEMATTRS_DB_STATEMENT, + SEMATTRS_DB_SYSTEM, } from '@opentelemetry/semantic-conventions'; import type * as mysqlTypes from 'mysql'; import { AttributeNames } from './AttributeNames'; @@ -54,7 +55,7 @@ export class MySQLInstrumentation extends InstrumentationBase< typeof mysqlTypes > { static readonly COMMON_ATTRIBUTES = { - [SemanticAttributes.DB_SYSTEM]: DbSystemValues.MYSQL, + [SEMATTRS_DB_SYSTEM]: DBSYSTEMVALUES_MYSQL, }; private _connectionsUsage!: UpDownCounter; @@ -331,10 +332,7 @@ export class MySQLInstrumentation extends InstrumentationBase< }, }); - span.setAttribute( - SemanticAttributes.DB_STATEMENT, - getDbStatement(query) - ); + span.setAttribute(SEMATTRS_DB_STATEMENT, getDbStatement(query)); const instrumentationConfig: MySQLInstrumentationConfig = thisPlugin.getConfig(); diff --git a/plugins/node/opentelemetry-instrumentation-mysql/src/utils.ts b/plugins/node/opentelemetry-instrumentation-mysql/src/utils.ts index 05eb1d809f..8230052d0e 100644 --- a/plugins/node/opentelemetry-instrumentation-mysql/src/utils.ts +++ b/plugins/node/opentelemetry-instrumentation-mysql/src/utils.ts @@ -14,8 +14,14 @@ * limitations under the License. */ -import { SpanAttributes } from '@opentelemetry/api'; -import { SemanticAttributes } from '@opentelemetry/semantic-conventions'; +import { Attributes } from '@opentelemetry/api'; +import { + SEMATTRS_DB_CONNECTION_STRING, + SEMATTRS_DB_NAME, + SEMATTRS_DB_USER, + SEMATTRS_NET_PEER_NAME, + SEMATTRS_NET_PEER_PORT, +} from '@opentelemetry/semantic-conventions'; import type { ConnectionConfig, PoolActualConfig, @@ -25,37 +31,29 @@ import type { import type * as mysqlTypes from 'mysql'; /** - * Get an SpanAttributes map from a mysql connection config object + * Get an Attributes map from a mysql connection config object * * @param config ConnectionConfig */ export function getConnectionAttributes( config: ConnectionConfig | PoolActualConfig -): SpanAttributes { +): Attributes { const { host, port, database, user } = getConfig(config); const portNumber = parseInt(port, 10); if (!isNaN(portNumber)) { return { - [SemanticAttributes.NET_PEER_NAME]: host, - [SemanticAttributes.NET_PEER_PORT]: portNumber, - [SemanticAttributes.DB_CONNECTION_STRING]: getJDBCString( - host, - port, - database - ), - [SemanticAttributes.DB_NAME]: database, - [SemanticAttributes.DB_USER]: user, + [SEMATTRS_NET_PEER_NAME]: host, + [SEMATTRS_NET_PEER_PORT]: portNumber, + [SEMATTRS_DB_CONNECTION_STRING]: getJDBCString(host, port, database), + [SEMATTRS_DB_NAME]: database, + [SEMATTRS_DB_USER]: user, }; } return { - [SemanticAttributes.NET_PEER_NAME]: host, - [SemanticAttributes.DB_CONNECTION_STRING]: getJDBCString( - host, - port, - database - ), - [SemanticAttributes.DB_NAME]: database, - [SemanticAttributes.DB_USER]: user, + [SEMATTRS_NET_PEER_NAME]: host, + [SEMATTRS_DB_CONNECTION_STRING]: getJDBCString(host, port, database), + [SEMATTRS_DB_NAME]: database, + [SEMATTRS_DB_USER]: user, }; } diff --git a/plugins/node/opentelemetry-instrumentation-mysql/test/index.test.ts b/plugins/node/opentelemetry-instrumentation-mysql/test/index.test.ts index eaef649b3c..676081d47e 100644 --- a/plugins/node/opentelemetry-instrumentation-mysql/test/index.test.ts +++ b/plugins/node/opentelemetry-instrumentation-mysql/test/index.test.ts @@ -17,8 +17,13 @@ import { context, Context, trace, SpanStatusCode } from '@opentelemetry/api'; import { AsyncHooksContextManager } from '@opentelemetry/context-async-hooks'; import { - DbSystemValues, - SemanticAttributes, + DBSYSTEMVALUES_MYSQL, + SEMATTRS_DB_NAME, + SEMATTRS_DB_STATEMENT, + SEMATTRS_DB_SYSTEM, + SEMATTRS_DB_USER, + SEMATTRS_NET_PEER_NAME, + SEMATTRS_NET_PEER_PORT, } from '@opentelemetry/semantic-conventions'; import * as testUtils from '@opentelemetry/contrib-test-utils'; import { @@ -868,15 +873,12 @@ function assertSpan( values?: any, errorMessage?: string ) { - assert.strictEqual( - span.attributes[SemanticAttributes.DB_SYSTEM], - DbSystemValues.MYSQL - ); - assert.strictEqual(span.attributes[SemanticAttributes.DB_NAME], database); - assert.strictEqual(span.attributes[SemanticAttributes.NET_PEER_PORT], port); - assert.strictEqual(span.attributes[SemanticAttributes.NET_PEER_NAME], host); - assert.strictEqual(span.attributes[SemanticAttributes.DB_USER], user); - assert.strictEqual(span.attributes[SemanticAttributes.DB_STATEMENT], sql); + assert.strictEqual(span.attributes[SEMATTRS_DB_SYSTEM], DBSYSTEMVALUES_MYSQL); + assert.strictEqual(span.attributes[SEMATTRS_DB_NAME], database); + assert.strictEqual(span.attributes[SEMATTRS_NET_PEER_PORT], port); + assert.strictEqual(span.attributes[SEMATTRS_NET_PEER_NAME], host); + assert.strictEqual(span.attributes[SEMATTRS_DB_USER], user); + assert.strictEqual(span.attributes[SEMATTRS_DB_STATEMENT], sql); if (errorMessage) { assert.strictEqual(span.status.message, errorMessage); assert.strictEqual(span.status.code, SpanStatusCode.ERROR); diff --git a/plugins/node/opentelemetry-instrumentation-mysql2/LICENSE b/plugins/node/opentelemetry-instrumentation-mysql2/LICENSE index e50e8c80f9..261eeb9e9f 100644 --- a/plugins/node/opentelemetry-instrumentation-mysql2/LICENSE +++ b/plugins/node/opentelemetry-instrumentation-mysql2/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/plugins/node/opentelemetry-instrumentation-mysql2/README.md b/plugins/node/opentelemetry-instrumentation-mysql2/README.md index 04f15355ef..a0f3c73658 100644 --- a/plugins/node/opentelemetry-instrumentation-mysql2/README.md +++ b/plugins/node/opentelemetry-instrumentation-mysql2/README.md @@ -49,6 +49,22 @@ You can set the following instrumentation options: | `responseHook` | `MySQL2InstrumentationExecutionResponseHook` (function) | Function for adding custom attributes from db response | | `addSqlCommenterCommentToQueries` | `boolean` | If true, adds [sqlcommenter](https://github.com/open-telemetry/opentelemetry-sqlcommenter) specification compliant comment to queries with tracing context (default false). _NOTE: A comment will not be added to queries that already contain `--` or `/* ... */` in them, even if these are not actually part of comments_ | +## Semantic Conventions + +This package uses `@opentelemetry/semantic-conventions` version `1.22+`, which implements Semantic Convention [Version 1.7.0](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.7.0/semantic_conventions/README.md) + +Attributes collected: + +| Attribute | Short Description | +| ----------------------- | ------------------------------------------------------------------------------ | +| `db.connection_string` | The connection string used to connect to the database. | +| `db.name` | This attribute is used to report the name of the database being accessed. | +| `db.statement` | The database statement being executed. | +| `db.system` | An identifier for the database management system (DBMS) product being used. | +| `db.user` | Username for accessing the database. | +| `net.peer.name` | Remote hostname or similar. | +| `net.peer.port` | Remote port number. | + ## Useful links - For more information on OpenTelemetry, visit: diff --git a/plugins/node/opentelemetry-instrumentation-mysql2/package.json b/plugins/node/opentelemetry-instrumentation-mysql2/package.json index b20fb7aaf6..5d7d885d02 100644 --- a/plugins/node/opentelemetry-instrumentation-mysql2/package.json +++ b/plugins/node/opentelemetry-instrumentation-mysql2/package.json @@ -62,7 +62,7 @@ }, "dependencies": { "@opentelemetry/instrumentation": "^0.50.0", - "@opentelemetry/semantic-conventions": "^1.0.0", + "@opentelemetry/semantic-conventions": "^1.22.0", "@opentelemetry/sql-common": "^0.40.0" }, "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-mysql2#readme" diff --git a/plugins/node/opentelemetry-instrumentation-mysql2/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-mysql2/src/instrumentation.ts index ea792f8025..2d79311bcb 100644 --- a/plugins/node/opentelemetry-instrumentation-mysql2/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-mysql2/src/instrumentation.ts @@ -22,8 +22,9 @@ import { safeExecuteInTheMiddle, } from '@opentelemetry/instrumentation'; import { - DbSystemValues, - SemanticAttributes, + DBSYSTEMVALUES_MYSQL, + SEMATTRS_DB_STATEMENT, + SEMATTRS_DB_SYSTEM, } from '@opentelemetry/semantic-conventions'; import { addSqlCommenterComment } from '@opentelemetry/sql-common'; import type * as mysqlTypes from 'mysql2'; @@ -40,7 +41,7 @@ type formatType = typeof mysqlTypes.format; export class MySQL2Instrumentation extends InstrumentationBase { static readonly COMMON_ATTRIBUTES = { - [SemanticAttributes.DB_SYSTEM]: DbSystemValues.MYSQL, + [SEMATTRS_DB_SYSTEM]: DBSYSTEMVALUES_MYSQL, }; constructor(config?: MySQL2InstrumentationConfig) { @@ -115,11 +116,7 @@ export class MySQL2Instrumentation extends InstrumentationBase { attributes: { ...MySQL2Instrumentation.COMMON_ATTRIBUTES, ...getConnectionAttributes(this.config), - [SemanticAttributes.DB_STATEMENT]: getDbStatement( - query, - format, - values - ), + [SEMATTRS_DB_STATEMENT]: getDbStatement(query, format, values), }, }); diff --git a/plugins/node/opentelemetry-instrumentation-mysql2/src/utils.ts b/plugins/node/opentelemetry-instrumentation-mysql2/src/utils.ts index 82333c109f..cfd9f2ef0f 100644 --- a/plugins/node/opentelemetry-instrumentation-mysql2/src/utils.ts +++ b/plugins/node/opentelemetry-instrumentation-mysql2/src/utils.ts @@ -14,8 +14,14 @@ * limitations under the License. */ -import { SpanAttributes } from '@opentelemetry/api'; -import { SemanticAttributes } from '@opentelemetry/semantic-conventions'; +import { Attributes } from '@opentelemetry/api'; +import { + SEMATTRS_DB_CONNECTION_STRING, + SEMATTRS_DB_NAME, + SEMATTRS_DB_USER, + SEMATTRS_NET_PEER_NAME, + SEMATTRS_NET_PEER_PORT, +} from '@opentelemetry/semantic-conventions'; /* Following types declare an expectation on mysql2 types and define a subset we @@ -42,35 +48,27 @@ interface Config { connectionConfig?: Config; } /** - * Get an SpanAttributes map from a mysql connection config object + * Get an Attributes map from a mysql connection config object * * @param config ConnectionConfig */ -export function getConnectionAttributes(config: Config): SpanAttributes { +export function getConnectionAttributes(config: Config): Attributes { const { host, port, database, user } = getConfig(config); const portNumber = parseInt(port, 10); if (!isNaN(portNumber)) { return { - [SemanticAttributes.NET_PEER_NAME]: host, - [SemanticAttributes.NET_PEER_PORT]: portNumber, - [SemanticAttributes.DB_CONNECTION_STRING]: getJDBCString( - host, - port, - database - ), - [SemanticAttributes.DB_NAME]: database, - [SemanticAttributes.DB_USER]: user, + [SEMATTRS_NET_PEER_NAME]: host, + [SEMATTRS_NET_PEER_PORT]: portNumber, + [SEMATTRS_DB_CONNECTION_STRING]: getJDBCString(host, port, database), + [SEMATTRS_DB_NAME]: database, + [SEMATTRS_DB_USER]: user, }; } return { - [SemanticAttributes.NET_PEER_NAME]: host, - [SemanticAttributes.DB_CONNECTION_STRING]: getJDBCString( - host, - port, - database - ), - [SemanticAttributes.DB_NAME]: database, - [SemanticAttributes.DB_USER]: user, + [SEMATTRS_NET_PEER_NAME]: host, + [SEMATTRS_DB_CONNECTION_STRING]: getJDBCString(host, port, database), + [SEMATTRS_DB_NAME]: database, + [SEMATTRS_DB_USER]: user, }; } diff --git a/plugins/node/opentelemetry-instrumentation-mysql2/test/mysql.test.ts b/plugins/node/opentelemetry-instrumentation-mysql2/test/mysql.test.ts index 4c7a4bab23..7b2bfe74ee 100644 --- a/plugins/node/opentelemetry-instrumentation-mysql2/test/mysql.test.ts +++ b/plugins/node/opentelemetry-instrumentation-mysql2/test/mysql.test.ts @@ -18,8 +18,13 @@ import * as semver from 'semver'; import { context, trace, SpanStatusCode } from '@opentelemetry/api'; import { AsyncHooksContextManager } from '@opentelemetry/context-async-hooks'; import { - DbSystemValues, - SemanticAttributes, + DBSYSTEMVALUES_MYSQL, + SEMATTRS_DB_NAME, + SEMATTRS_DB_STATEMENT, + SEMATTRS_DB_SYSTEM, + SEMATTRS_DB_USER, + SEMATTRS_NET_PEER_NAME, + SEMATTRS_NET_PEER_PORT, } from '@opentelemetry/semantic-conventions'; import * as testUtils from '@opentelemetry/contrib-test-utils'; import { @@ -177,10 +182,7 @@ describe('mysql2@2.x', () => { query.on('end', () => { const spans = memoryExporter.getFinishedSpans(); assert.strictEqual(spans[0].name, 'SELECT'); - assert.strictEqual( - spans[0].attributes[SemanticAttributes.DB_STATEMENT], - sql - ); + assert.strictEqual(spans[0].attributes[SEMATTRS_DB_STATEMENT], sql); done(); }); }); @@ -198,7 +200,7 @@ describe('mysql2@2.x', () => { const spans = memoryExporter.getFinishedSpans(); assert.strictEqual(spans[0].name, 'SELECT'); assert.strictEqual( - spans[0].attributes[SemanticAttributes.DB_STATEMENT], + spans[0].attributes[SEMATTRS_DB_STATEMENT], query.sql ); done(); @@ -1215,16 +1217,13 @@ function assertSpan( values?: any, errorMessage?: string ) { + assert.strictEqual(span.attributes[SEMATTRS_DB_SYSTEM], DBSYSTEMVALUES_MYSQL); + assert.strictEqual(span.attributes[SEMATTRS_DB_NAME], database); + assert.strictEqual(span.attributes[SEMATTRS_NET_PEER_PORT], port); + assert.strictEqual(span.attributes[SEMATTRS_NET_PEER_NAME], host); + assert.strictEqual(span.attributes[SEMATTRS_DB_USER], user); assert.strictEqual( - span.attributes[SemanticAttributes.DB_SYSTEM], - DbSystemValues.MYSQL - ); - assert.strictEqual(span.attributes[SemanticAttributes.DB_NAME], database); - assert.strictEqual(span.attributes[SemanticAttributes.NET_PEER_PORT], port); - assert.strictEqual(span.attributes[SemanticAttributes.NET_PEER_NAME], host); - assert.strictEqual(span.attributes[SemanticAttributes.DB_USER], user); - assert.strictEqual( - span.attributes[SemanticAttributes.DB_STATEMENT], + span.attributes[SEMATTRS_DB_STATEMENT], mysqlTypes.format(sql, values) ); if (errorMessage) { diff --git a/plugins/node/opentelemetry-instrumentation-nestjs-core/LICENSE b/plugins/node/opentelemetry-instrumentation-nestjs-core/LICENSE index e50e8c80f9..261eeb9e9f 100644 --- a/plugins/node/opentelemetry-instrumentation-nestjs-core/LICENSE +++ b/plugins/node/opentelemetry-instrumentation-nestjs-core/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/plugins/node/opentelemetry-instrumentation-net/LICENSE b/plugins/node/opentelemetry-instrumentation-net/LICENSE index e50e8c80f9..261eeb9e9f 100644 --- a/plugins/node/opentelemetry-instrumentation-net/LICENSE +++ b/plugins/node/opentelemetry-instrumentation-net/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/plugins/node/opentelemetry-instrumentation-pg/LICENSE b/plugins/node/opentelemetry-instrumentation-pg/LICENSE index e50e8c80f9..261eeb9e9f 100644 --- a/plugins/node/opentelemetry-instrumentation-pg/LICENSE +++ b/plugins/node/opentelemetry-instrumentation-pg/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/plugins/node/opentelemetry-instrumentation-pino/LICENSE b/plugins/node/opentelemetry-instrumentation-pino/LICENSE index e50e8c80f9..261eeb9e9f 100644 --- a/plugins/node/opentelemetry-instrumentation-pino/LICENSE +++ b/plugins/node/opentelemetry-instrumentation-pino/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/plugins/node/opentelemetry-instrumentation-redis-4/LICENSE b/plugins/node/opentelemetry-instrumentation-redis-4/LICENSE index e50e8c80f9..261eeb9e9f 100644 --- a/plugins/node/opentelemetry-instrumentation-redis-4/LICENSE +++ b/plugins/node/opentelemetry-instrumentation-redis-4/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/plugins/node/opentelemetry-instrumentation-redis-4/README.md b/plugins/node/opentelemetry-instrumentation-redis-4/README.md index dec67f105d..19eea1b33a 100644 --- a/plugins/node/opentelemetry-instrumentation-redis-4/README.md +++ b/plugins/node/opentelemetry-instrumentation-redis-4/README.md @@ -71,6 +71,20 @@ const redisInstrumentation = new RedisInstrumentation({ }); ``` +## Semantic Conventions + +This package uses `@opentelemetry/semantic-conventions` version `1.22+`, which implements Semantic Convention [Version 1.7.0](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.7.0/semantic_conventions/README.md) + +Attributes collected: + +| Attribute | Short Description | +| ---------------------- | ---------------------------------------------------------------------------- | +| `db.connection_string` | The connection string used to connect to the database (without credentials). | +| `db.statement` | The database statement being executed. | +| `db.system` | An identifier for the database management system (DBMS) product being used. | +| `net.peer.name` | Remote hostname or similar, see note below. | +| `net.peer.port` | Remote port number. | + ## Useful links - For more information on OpenTelemetry, visit: diff --git a/plugins/node/opentelemetry-instrumentation-redis-4/package.json b/plugins/node/opentelemetry-instrumentation-redis-4/package.json index 08077ae594..f6e0957832 100644 --- a/plugins/node/opentelemetry-instrumentation-redis-4/package.json +++ b/plugins/node/opentelemetry-instrumentation-redis-4/package.json @@ -68,7 +68,7 @@ "dependencies": { "@opentelemetry/instrumentation": "^0.50.0", "@opentelemetry/redis-common": "^0.36.1", - "@opentelemetry/semantic-conventions": "^1.0.0" + "@opentelemetry/semantic-conventions": "^1.22.0" }, "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-redis-4#readme" } diff --git a/plugins/node/opentelemetry-instrumentation-redis-4/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-redis-4/src/instrumentation.ts index e018845e2d..825defe5cf 100644 --- a/plugins/node/opentelemetry-instrumentation-redis-4/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-redis-4/src/instrumentation.ts @@ -32,7 +32,7 @@ import { getClientAttributes } from './utils'; import { defaultDbStatementSerializer } from '@opentelemetry/redis-common'; import { RedisInstrumentationConfig } from './types'; import { VERSION } from './version'; -import { SemanticAttributes } from '@opentelemetry/semantic-conventions'; +import { SEMATTRS_DB_STATEMENT } from '@opentelemetry/semantic-conventions'; import type { MultiErrorReply } from './internal-types'; const OTEL_OPEN_SPANS = Symbol( @@ -405,7 +405,7 @@ export class RedisInstrumentation extends InstrumentationBase { try { const dbStatement = dbStatementSerializer(commandName, commandArgs); if (dbStatement != null) { - attributes[SemanticAttributes.DB_STATEMENT] = dbStatement; + attributes[SEMATTRS_DB_STATEMENT] = dbStatement; } } catch (e) { this._diag.error('dbStatementSerializer throw an exception', e, { diff --git a/plugins/node/opentelemetry-instrumentation-redis-4/src/utils.ts b/plugins/node/opentelemetry-instrumentation-redis-4/src/utils.ts index 4275f10175..7bdbf768ac 100644 --- a/plugins/node/opentelemetry-instrumentation-redis-4/src/utils.ts +++ b/plugins/node/opentelemetry-instrumentation-redis-4/src/utils.ts @@ -15,8 +15,11 @@ */ import { Attributes, DiagLogger } from '@opentelemetry/api'; import { - DbSystemValues, - SemanticAttributes, + SEMATTRS_DB_SYSTEM, + SEMATTRS_DB_CONNECTION_STRING, + SEMATTRS_NET_PEER_NAME, + SEMATTRS_NET_PEER_PORT, + DBSYSTEMVALUES_REDIS, } from '@opentelemetry/semantic-conventions'; export function getClientAttributes( @@ -24,10 +27,10 @@ export function getClientAttributes( options: any ): Attributes { return { - [SemanticAttributes.DB_SYSTEM]: DbSystemValues.REDIS, - [SemanticAttributes.NET_PEER_NAME]: options?.socket?.host, - [SemanticAttributes.NET_PEER_PORT]: options?.socket?.port, - [SemanticAttributes.DB_CONNECTION_STRING]: + [SEMATTRS_DB_SYSTEM]: DBSYSTEMVALUES_REDIS, + [SEMATTRS_NET_PEER_NAME]: options?.socket?.host, + [SEMATTRS_NET_PEER_PORT]: options?.socket?.port, + [SEMATTRS_DB_CONNECTION_STRING]: removeCredentialsFromDBConnectionStringAttribute(diag, options?.url), }; } diff --git a/plugins/node/opentelemetry-instrumentation-redis-4/test/redis.test.ts b/plugins/node/opentelemetry-instrumentation-redis-4/test/redis.test.ts index 713c2130fe..6200b4c1eb 100644 --- a/plugins/node/opentelemetry-instrumentation-redis-4/test/redis.test.ts +++ b/plugins/node/opentelemetry-instrumentation-redis-4/test/redis.test.ts @@ -41,7 +41,14 @@ import { trace, context, } from '@opentelemetry/api'; -import { SemanticAttributes } from '@opentelemetry/semantic-conventions'; +import { + SEMATTRS_DB_CONNECTION_STRING, + SEMATTRS_DB_STATEMENT, + SEMATTRS_DB_SYSTEM, + SEMATTRS_EXCEPTION_MESSAGE, + SEMATTRS_NET_PEER_NAME, + SEMATTRS_NET_PEER_PORT, +} from '@opentelemetry/semantic-conventions'; import { RedisResponseCustomAttributeFunction } from '../src/types'; import { hrTimeToMilliseconds, suppressTracing } from '@opentelemetry/core'; @@ -94,24 +101,21 @@ describe('redis@^4.0.0', () => { assert.ok(setSpan); assert.strictEqual(setSpan?.kind, SpanKind.CLIENT); assert.strictEqual(setSpan?.name, 'redis-SET'); + assert.strictEqual(setSpan?.attributes[SEMATTRS_DB_SYSTEM], 'redis'); assert.strictEqual( - setSpan?.attributes[SemanticAttributes.DB_SYSTEM], - 'redis' - ); - assert.strictEqual( - setSpan?.attributes[SemanticAttributes.DB_STATEMENT], + setSpan?.attributes[SEMATTRS_DB_STATEMENT], 'SET key [1 other arguments]' ); assert.strictEqual( - setSpan?.attributes[SemanticAttributes.NET_PEER_NAME], + setSpan?.attributes[SEMATTRS_NET_PEER_NAME], redisTestConfig.host ); assert.strictEqual( - setSpan?.attributes[SemanticAttributes.NET_PEER_PORT], + setSpan?.attributes[SEMATTRS_NET_PEER_PORT], redisTestConfig.port ); assert.strictEqual( - setSpan?.attributes[SemanticAttributes.DB_CONNECTION_STRING], + setSpan?.attributes[SEMATTRS_DB_CONNECTION_STRING], redisTestUrl ); @@ -119,24 +123,18 @@ describe('redis@^4.0.0', () => { assert.ok(getSpan); assert.strictEqual(getSpan?.kind, SpanKind.CLIENT); assert.strictEqual(getSpan?.name, 'redis-GET'); + assert.strictEqual(getSpan?.attributes[SEMATTRS_DB_SYSTEM], 'redis'); + assert.strictEqual(getSpan?.attributes[SEMATTRS_DB_STATEMENT], 'GET key'); assert.strictEqual( - getSpan?.attributes[SemanticAttributes.DB_SYSTEM], - 'redis' - ); - assert.strictEqual( - getSpan?.attributes[SemanticAttributes.DB_STATEMENT], - 'GET key' - ); - assert.strictEqual( - getSpan?.attributes[SemanticAttributes.NET_PEER_NAME], + getSpan?.attributes[SEMATTRS_NET_PEER_NAME], redisTestConfig.host ); assert.strictEqual( - getSpan?.attributes[SemanticAttributes.NET_PEER_PORT], + getSpan?.attributes[SEMATTRS_NET_PEER_PORT], redisTestConfig.port ); assert.strictEqual( - getSpan?.attributes[SemanticAttributes.DB_CONNECTION_STRING], + getSpan?.attributes[SEMATTRS_DB_CONNECTION_STRING], redisTestUrl ); }); @@ -149,15 +147,15 @@ describe('redis@^4.0.0', () => { assert.ok(setSpan); assert.strictEqual( - setSpan?.attributes[SemanticAttributes.DB_STATEMENT], + setSpan?.attributes[SEMATTRS_DB_STATEMENT], 'SET key [1 other arguments]' ); assert.strictEqual( - setSpan?.attributes[SemanticAttributes.NET_PEER_NAME], + setSpan?.attributes[SEMATTRS_NET_PEER_NAME], redisTestConfig.host ); assert.strictEqual( - setSpan?.attributes[SemanticAttributes.NET_PEER_PORT], + setSpan?.attributes[SEMATTRS_NET_PEER_PORT], redisTestConfig.port ); }); @@ -180,7 +178,7 @@ describe('redis@^4.0.0', () => { ); assert.strictEqual(exceptions.length, 1); assert.strictEqual( - exceptions?.[0].attributes?.[SemanticAttributes.EXCEPTION_MESSAGE], + exceptions?.[0].attributes?.[SEMATTRS_EXCEPTION_MESSAGE], 'ERR value is not an integer or out of range' ); }); @@ -202,20 +200,17 @@ describe('redis@^4.0.0', () => { assert.strictEqual(span.name, 'redis-connect'); + assert.strictEqual(span.attributes[SEMATTRS_DB_SYSTEM], 'redis'); assert.strictEqual( - span.attributes[SemanticAttributes.DB_SYSTEM], - 'redis' - ); - assert.strictEqual( - span.attributes[SemanticAttributes.NET_PEER_NAME], + span.attributes[SEMATTRS_NET_PEER_NAME], redisTestConfig.host ); assert.strictEqual( - span.attributes[SemanticAttributes.NET_PEER_PORT], + span.attributes[SEMATTRS_NET_PEER_PORT], redisTestConfig.port ); assert.strictEqual( - span.attributes[SemanticAttributes.DB_CONNECTION_STRING], + span.attributes[SEMATTRS_DB_CONNECTION_STRING], redisTestUrl ); }); @@ -235,7 +230,7 @@ describe('redis@^4.0.0', () => { assert.strictEqual(span.name, 'redis-connect'); assert.strictEqual(span.status.code, SpanStatusCode.ERROR); assert.strictEqual( - span.attributes[SemanticAttributes.DB_CONNECTION_STRING], + span.attributes[SEMATTRS_DB_CONNECTION_STRING], redisURL ); }); @@ -258,11 +253,11 @@ describe('redis@^4.0.0', () => { assert.strictEqual(span.name, 'redis-connect'); assert.strictEqual(span.status.code, SpanStatusCode.ERROR); assert.strictEqual( - span.attributes[SemanticAttributes.NET_PEER_NAME], + span.attributes[SEMATTRS_NET_PEER_NAME], redisTestConfig.host ); assert.strictEqual( - span.attributes[SemanticAttributes.DB_CONNECTION_STRING], + span.attributes[SEMATTRS_DB_CONNECTION_STRING], expectAttributeConnString ); }); @@ -285,11 +280,11 @@ describe('redis@^4.0.0', () => { assert.strictEqual(span.name, 'redis-connect'); assert.strictEqual(span.status.code, SpanStatusCode.ERROR); assert.strictEqual( - span.attributes[SemanticAttributes.NET_PEER_NAME], + span.attributes[SEMATTRS_NET_PEER_NAME], redisTestConfig.host ); assert.strictEqual( - span.attributes[SemanticAttributes.DB_CONNECTION_STRING], + span.attributes[SEMATTRS_DB_CONNECTION_STRING], expectAttributeConnString ); }); @@ -314,38 +309,38 @@ describe('redis@^4.0.0', () => { assert.ok(multiSetSpan); assert.strictEqual(multiSetSpan.name, 'redis-SET'); assert.strictEqual( - multiSetSpan.attributes[SemanticAttributes.DB_STATEMENT], + multiSetSpan.attributes[SEMATTRS_DB_STATEMENT], 'SET key [1 other arguments]' ); assert.strictEqual( - multiSetSpan?.attributes[SemanticAttributes.NET_PEER_NAME], + multiSetSpan?.attributes[SEMATTRS_NET_PEER_NAME], redisTestConfig.host ); assert.strictEqual( - multiSetSpan?.attributes[SemanticAttributes.NET_PEER_PORT], + multiSetSpan?.attributes[SEMATTRS_NET_PEER_PORT], redisTestConfig.port ); assert.strictEqual( - multiSetSpan?.attributes[SemanticAttributes.DB_CONNECTION_STRING], + multiSetSpan?.attributes[SEMATTRS_DB_CONNECTION_STRING], redisTestUrl ); assert.ok(multiGetSpan); assert.strictEqual(multiGetSpan.name, 'redis-GET'); assert.strictEqual( - multiGetSpan.attributes[SemanticAttributes.DB_STATEMENT], + multiGetSpan.attributes[SEMATTRS_DB_STATEMENT], 'GET another-key' ); assert.strictEqual( - multiGetSpan?.attributes[SemanticAttributes.NET_PEER_NAME], + multiGetSpan?.attributes[SEMATTRS_NET_PEER_NAME], redisTestConfig.host ); assert.strictEqual( - multiGetSpan?.attributes[SemanticAttributes.NET_PEER_PORT], + multiGetSpan?.attributes[SEMATTRS_NET_PEER_PORT], redisTestConfig.port ); assert.strictEqual( - multiGetSpan?.attributes[SemanticAttributes.DB_CONNECTION_STRING], + multiGetSpan?.attributes[SEMATTRS_DB_CONNECTION_STRING], redisTestUrl ); }); @@ -360,19 +355,19 @@ describe('redis@^4.0.0', () => { const [multiSetSpan] = getTestSpans(); assert.ok(multiSetSpan); assert.strictEqual( - multiSetSpan.attributes[SemanticAttributes.DB_STATEMENT], + multiSetSpan.attributes[SEMATTRS_DB_STATEMENT], 'SET key [1 other arguments]' ); assert.strictEqual( - multiSetSpan?.attributes[SemanticAttributes.NET_PEER_NAME], + multiSetSpan?.attributes[SEMATTRS_NET_PEER_NAME], redisTestConfig.host ); assert.strictEqual( - multiSetSpan?.attributes[SemanticAttributes.NET_PEER_PORT], + multiSetSpan?.attributes[SEMATTRS_NET_PEER_PORT], redisTestConfig.port ); assert.strictEqual( - multiSetSpan?.attributes[SemanticAttributes.DB_CONNECTION_STRING], + multiSetSpan?.attributes[SEMATTRS_DB_CONNECTION_STRING], redisTestUrl ); }); @@ -513,7 +508,7 @@ describe('redis@^4.0.0', () => { await client.set('key', 'value'); const [span] = getTestSpans(); assert.strictEqual( - span.attributes[SemanticAttributes.DB_STATEMENT], + span.attributes[SEMATTRS_DB_STATEMENT], 'SET key value' ); }); @@ -527,7 +522,7 @@ describe('redis@^4.0.0', () => { await client.set('key', 'value'); const [span] = getTestSpans(); assert.ok(span); - assert.ok(!(SemanticAttributes.DB_STATEMENT in span.attributes)); + assert.ok(!(SEMATTRS_DB_STATEMENT in span.attributes)); }); }); diff --git a/plugins/node/opentelemetry-instrumentation-redis/LICENSE b/plugins/node/opentelemetry-instrumentation-redis/LICENSE index e50e8c80f9..261eeb9e9f 100644 --- a/plugins/node/opentelemetry-instrumentation-redis/LICENSE +++ b/plugins/node/opentelemetry-instrumentation-redis/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/plugins/node/opentelemetry-instrumentation-redis/README.md b/plugins/node/opentelemetry-instrumentation-redis/README.md index 693edfdd21..e93e4c7873 100644 --- a/plugins/node/opentelemetry-instrumentation-redis/README.md +++ b/plugins/node/opentelemetry-instrumentation-redis/README.md @@ -74,6 +74,20 @@ const redisInstrumentation = new RedisInstrumentation({ }); ``` +## Semantic Conventions + +This package uses `@opentelemetry/semantic-conventions` version `1.22+`, which implements Semantic Convention [Version 1.7.0](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.7.0/semantic_conventions/README.md) + +Attributes collected: + +| Attribute | Short Description | Notes | +|------------------------|--------------------------------------------------------------|--------------------------------------| +| `db.connection_string` | URL to Redis server address, of the form `redis://host:port` | Key: `SEMATTRS_DB_CONNECTION_STRING` | +| `db.statement` | Executed Redis statement | Key: `SEMATTRS_DB_STATEMENT` | +| `db.system` | Database identifier; always `redis` | Key: `SEMATTRS_DB_SYSTEM` | +| `net.peer.name` | Hostname or IP of the connected Redis server | Key: `SEMATTRS_NET_PEER_NAME` | +| `net.peer.port` | Port of the connected Redis server | Key: `SEMATTRS_NET_PORT_NAME` | + ## Useful links - For more information on OpenTelemetry, visit: diff --git a/plugins/node/opentelemetry-instrumentation-redis/package.json b/plugins/node/opentelemetry-instrumentation-redis/package.json index 67d8fc6c1a..7c52f2cb7b 100644 --- a/plugins/node/opentelemetry-instrumentation-redis/package.json +++ b/plugins/node/opentelemetry-instrumentation-redis/package.json @@ -68,7 +68,7 @@ "dependencies": { "@opentelemetry/instrumentation": "^0.50.0", "@opentelemetry/redis-common": "^0.36.1", - "@opentelemetry/semantic-conventions": "^1.0.0" + "@opentelemetry/semantic-conventions": "^1.22.0" }, "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-redis#readme" } diff --git a/plugins/node/opentelemetry-instrumentation-redis/src/utils.ts b/plugins/node/opentelemetry-instrumentation-redis/src/utils.ts index 7575e51376..fed4f769f9 100644 --- a/plugins/node/opentelemetry-instrumentation-redis/src/utils.ts +++ b/plugins/node/opentelemetry-instrumentation-redis/src/utils.ts @@ -28,8 +28,12 @@ import { RedisCommand, RedisInstrumentationConfig } from './types'; import { EventEmitter } from 'events'; import { RedisInstrumentation } from './'; import { - DbSystemValues, - SemanticAttributes, + DBSYSTEMVALUES_REDIS, + SEMATTRS_DB_CONNECTION_STRING, + SEMATTRS_DB_STATEMENT, + SEMATTRS_DB_SYSTEM, + SEMATTRS_NET_PEER_NAME, + SEMATTRS_NET_PEER_PORT, } from '@opentelemetry/semantic-conventions'; import { safeExecuteInTheMiddle } from '@opentelemetry/instrumentation'; import { RedisPluginClientTypes } from './internal-types'; @@ -100,11 +104,8 @@ export const getTracedInternalSendCommand = ( { kind: SpanKind.CLIENT, attributes: { - [SemanticAttributes.DB_SYSTEM]: DbSystemValues.REDIS, - [SemanticAttributes.DB_STATEMENT]: dbStatementSerializer( - cmd.command, - cmd.args - ), + [SEMATTRS_DB_SYSTEM]: DBSYSTEMVALUES_REDIS, + [SEMATTRS_DB_STATEMENT]: dbStatementSerializer(cmd.command, cmd.args), }, } ); @@ -112,13 +113,13 @@ export const getTracedInternalSendCommand = ( // Set attributes for not explicitly typed RedisPluginClientTypes if (this.options) { span.setAttributes({ - [SemanticAttributes.NET_PEER_NAME]: this.options.host, - [SemanticAttributes.NET_PEER_PORT]: this.options.port, + [SEMATTRS_NET_PEER_NAME]: this.options.host, + [SEMATTRS_NET_PEER_PORT]: this.options.port, }); } if (this.address) { span.setAttribute( - SemanticAttributes.DB_CONNECTION_STRING, + SEMATTRS_DB_CONNECTION_STRING, `redis://${this.address}` ); } diff --git a/plugins/node/opentelemetry-instrumentation-redis/test/redis.test.ts b/plugins/node/opentelemetry-instrumentation-redis/test/redis.test.ts index 01d449a57e..63ab337e86 100644 --- a/plugins/node/opentelemetry-instrumentation-redis/test/redis.test.ts +++ b/plugins/node/opentelemetry-instrumentation-redis/test/redis.test.ts @@ -32,8 +32,12 @@ import { import * as assert from 'assert'; import { RedisInstrumentation } from '../src'; import { - DbSystemValues, - SemanticAttributes, + DBSYSTEMVALUES_REDIS, + SEMATTRS_DB_CONNECTION_STRING, + SEMATTRS_DB_STATEMENT, + SEMATTRS_DB_SYSTEM, + SEMATTRS_NET_PEER_NAME, + SEMATTRS_NET_PEER_PORT, } from '@opentelemetry/semantic-conventions'; const instrumentation = new RedisInstrumentation(); @@ -53,10 +57,10 @@ const CONFIG = { const URL = `redis://${CONFIG.host}:${CONFIG.port}`; const DEFAULT_ATTRIBUTES = { - [SemanticAttributes.DB_SYSTEM]: DbSystemValues.REDIS, - [SemanticAttributes.NET_PEER_NAME]: CONFIG.host, - [SemanticAttributes.NET_PEER_PORT]: CONFIG.port, - [SemanticAttributes.DB_CONNECTION_STRING]: URL, + [SEMATTRS_DB_SYSTEM]: DBSYSTEMVALUES_REDIS, + [SEMATTRS_NET_PEER_NAME]: CONFIG.host, + [SEMATTRS_NET_PEER_PORT]: CONFIG.port, + [SEMATTRS_DB_CONNECTION_STRING]: URL, }; const unsetStatus: SpanStatus = { @@ -192,7 +196,7 @@ describe('redis@2.x', () => { it(`should create a child span for ${operation.description}`, done => { const attributes = { ...DEFAULT_ATTRIBUTES, - [SemanticAttributes.DB_STATEMENT]: `${operation.command} ${operation.expectedDbStatement}`, + [SEMATTRS_DB_STATEMENT]: `${operation.command} ${operation.expectedDbStatement}`, }; const span = tracer.startSpan('test span'); context.with(trace.setSpan(context.active(), span), () => { @@ -281,7 +285,7 @@ describe('redis@2.x', () => { operation.args ); assert.strictEqual( - endedSpans[0].attributes[SemanticAttributes.DB_STATEMENT], + endedSpans[0].attributes[SEMATTRS_DB_STATEMENT], expectedStatement ); done(); diff --git a/plugins/node/opentelemetry-instrumentation-restify/LICENSE b/plugins/node/opentelemetry-instrumentation-restify/LICENSE index e50e8c80f9..261eeb9e9f 100644 --- a/plugins/node/opentelemetry-instrumentation-restify/LICENSE +++ b/plugins/node/opentelemetry-instrumentation-restify/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/plugins/node/opentelemetry-instrumentation-restify/README.md b/plugins/node/opentelemetry-instrumentation-restify/README.md index 2e16ea7490..fd9b7fc7cd 100644 --- a/plugins/node/opentelemetry-instrumentation-restify/README.md +++ b/plugins/node/opentelemetry-instrumentation-restify/README.md @@ -62,6 +62,16 @@ const restifyInstrumentation = new RestifyInstrumentation({ }); ``` +## Semantic Conventions + +This package uses `@opentelemetry/semantic-conventions` version `1.22+`, which implements Semantic Convention [Version 1.7.0](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.7.0/semantic_conventions/README.md) + +Attributes collected: + +| Attribute | Short Description | +| ------------ | ---------------------------------- | +| `http.route` | The matched route (path template). | + ## Useful links - For more information on OpenTelemetry, visit: diff --git a/plugins/node/opentelemetry-instrumentation-restify/package.json b/plugins/node/opentelemetry-instrumentation-restify/package.json index ddd13d9b97..dbe6fa86ed 100644 --- a/plugins/node/opentelemetry-instrumentation-restify/package.json +++ b/plugins/node/opentelemetry-instrumentation-restify/package.json @@ -63,7 +63,7 @@ "dependencies": { "@opentelemetry/core": "^1.8.0", "@opentelemetry/instrumentation": "^0.50.0", - "@opentelemetry/semantic-conventions": "^1.0.0" + "@opentelemetry/semantic-conventions": "^1.22.0" }, "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-restify#readme" } diff --git a/plugins/node/opentelemetry-instrumentation-restify/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-restify/src/instrumentation.ts index 9efe444502..a29679f6ba 100644 --- a/plugins/node/opentelemetry-instrumentation-restify/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-restify/src/instrumentation.ts @@ -20,7 +20,7 @@ import type * as restify from 'restify'; import * as api from '@opentelemetry/api'; import type { Server } from 'restify'; import { LayerType } from './types'; -import * as AttributeNames from './enums/AttributeNames'; +import { AttributeNames } from './enums/AttributeNames'; import { VERSION } from './version'; import * as constants from './constants'; import { @@ -30,7 +30,7 @@ import { isWrapped, safeExecuteInTheMiddle, } from '@opentelemetry/instrumentation'; -import { SemanticAttributes } from '@opentelemetry/semantic-conventions'; +import { SEMATTRS_HTTP_ROUTE } from '@opentelemetry/semantic-conventions'; import { isPromise, isAsyncFunction } from './utils'; import { getRPCMetadata, RPCType } from '@opentelemetry/core'; import type { RestifyInstrumentationConfig } from './types'; @@ -185,11 +185,11 @@ export class RestifyInstrumentation extends InstrumentationBase { ? `request handler - ${route}` : `middleware - ${fnName || 'anonymous'}`; const attributes = { - [AttributeNames.AttributeNames.NAME]: fnName, - [AttributeNames.AttributeNames.VERSION]: this._moduleVersion || 'n/a', - [AttributeNames.AttributeNames.TYPE]: metadata.type, - [AttributeNames.AttributeNames.METHOD]: metadata.methodName, - [SemanticAttributes.HTTP_ROUTE]: route, + [AttributeNames.NAME]: fnName, + [AttributeNames.VERSION]: this._moduleVersion || 'n/a', + [AttributeNames.TYPE]: metadata.type, + [AttributeNames.METHOD]: metadata.methodName, + [SEMATTRS_HTTP_ROUTE]: route, }; const span = this.tracer.startSpan( spanName, diff --git a/plugins/node/opentelemetry-instrumentation-restify/test/restify.test.ts b/plugins/node/opentelemetry-instrumentation-restify/test/restify.test.ts index 6af016aed0..bea8b196a0 100644 --- a/plugins/node/opentelemetry-instrumentation-restify/test/restify.test.ts +++ b/plugins/node/opentelemetry-instrumentation-restify/test/restify.test.ts @@ -15,7 +15,7 @@ */ import { context, trace, Span } from '@opentelemetry/api'; -import { SemanticAttributes } from '@opentelemetry/semantic-conventions'; +import { SEMATTRS_HTTP_METHOD } from '@opentelemetry/semantic-conventions'; import { RPCMetadata, RPCType, setRPCMetadata } from '@opentelemetry/core'; import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node'; import { AsyncHooksContextManager } from '@opentelemetry/context-async-hooks'; @@ -493,10 +493,7 @@ describe('Restify Instrumentation', () => { describe('using requestHook in config', () => { it('calls requestHook provided function when set in config', async () => { const requestHook = (span: Span, info: RestifyRequestInfo) => { - span.setAttribute( - SemanticAttributes.HTTP_METHOD, - info.request.method - ); + span.setAttribute(SEMATTRS_HTTP_METHOD, info.request.method); span.setAttribute('restify.layer', info.layerType); }; @@ -518,10 +515,7 @@ describe('Restify Instrumentation', () => { // span from get const span = memoryExporter.getFinishedSpans()[2]; assert.notStrictEqual(span, undefined); - assert.strictEqual( - span.attributes[SemanticAttributes.HTTP_METHOD], - 'GET' - ); + assert.strictEqual(span.attributes[SEMATTRS_HTTP_METHOD], 'GET'); assert.strictEqual( span.attributes['restify.layer'], 'request_handler' @@ -533,10 +527,7 @@ describe('Restify Instrumentation', () => { it('does not propagate an error from a requestHook that throws exception', async () => { const requestHook = (span: Span, info: RestifyRequestInfo) => { - span.setAttribute( - SemanticAttributes.HTTP_METHOD, - info.request.method - ); + span.setAttribute(SEMATTRS_HTTP_METHOD, info.request.method); throw Error('error thrown in requestHook'); }; @@ -559,10 +550,7 @@ describe('Restify Instrumentation', () => { // span from get const span = memoryExporter.getFinishedSpans()[2]; assert.notStrictEqual(span, undefined); - assert.strictEqual( - span.attributes[SemanticAttributes.HTTP_METHOD], - 'GET' - ); + assert.strictEqual(span.attributes[SEMATTRS_HTTP_METHOD], 'GET'); } } ); diff --git a/plugins/node/opentelemetry-instrumentation-router/LICENSE b/plugins/node/opentelemetry-instrumentation-router/LICENSE index e50e8c80f9..261eeb9e9f 100644 --- a/plugins/node/opentelemetry-instrumentation-router/LICENSE +++ b/plugins/node/opentelemetry-instrumentation-router/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/plugins/node/opentelemetry-instrumentation-router/README.md b/plugins/node/opentelemetry-instrumentation-router/README.md index 427dcc7a9f..152a9cf081 100644 --- a/plugins/node/opentelemetry-instrumentation-router/README.md +++ b/plugins/node/opentelemetry-instrumentation-router/README.md @@ -40,6 +40,16 @@ registerInstrumentations({ See [examples/router](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/examples/router) for a short example. +## Semantic Conventions + +This package uses `@opentelemetry/semantic-conventions` version `1.22+`, which implements Semantic Convention [Version 1.7.0](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.7.0/semantic_conventions/README.md) + +Attributes collected: + +| Attribute | Short Description | +| ------------ | ---------------------------------- | +| `http.route` | The matched route (path template). | + ## Useful links - For more information on OpenTelemetry, visit: diff --git a/plugins/node/opentelemetry-instrumentation-router/package.json b/plugins/node/opentelemetry-instrumentation-router/package.json index b57544e4de..48a8335379 100644 --- a/plugins/node/opentelemetry-instrumentation-router/package.json +++ b/plugins/node/opentelemetry-instrumentation-router/package.json @@ -57,7 +57,7 @@ }, "dependencies": { "@opentelemetry/instrumentation": "^0.50.0", - "@opentelemetry/semantic-conventions": "^1.0.0" + "@opentelemetry/semantic-conventions": "^1.22.0" }, "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-router#readme" } diff --git a/plugins/node/opentelemetry-instrumentation-router/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-router/src/instrumentation.ts index 8733daf1ab..46f6a84836 100644 --- a/plugins/node/opentelemetry-instrumentation-router/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-router/src/instrumentation.ts @@ -22,7 +22,7 @@ import { InstrumentationNodeModuleFile, isWrapped, } from '@opentelemetry/instrumentation'; -import { SemanticAttributes } from '@opentelemetry/semantic-conventions'; +import { SEMATTRS_HTTP_ROUTE } from '@opentelemetry/semantic-conventions'; import * as http from 'http'; import type * as Router from 'router'; @@ -182,7 +182,7 @@ export default class RouterInstrumentation extends InstrumentationBase { [AttributeNames.NAME]: fnName, [AttributeNames.VERSION]: this._moduleVersion, [AttributeNames.TYPE]: type, - [SemanticAttributes.HTTP_ROUTE]: route, + [SEMATTRS_HTTP_ROUTE]: route, }; const parent = api.context.active(); diff --git a/plugins/node/opentelemetry-instrumentation-winston/LICENSE b/plugins/node/opentelemetry-instrumentation-winston/LICENSE index e50e8c80f9..261eeb9e9f 100644 --- a/plugins/node/opentelemetry-instrumentation-winston/LICENSE +++ b/plugins/node/opentelemetry-instrumentation-winston/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/plugins/node/opentelemetry-instrumentation-winston/README.md b/plugins/node/opentelemetry-instrumentation-winston/README.md index d6bcbcca99..90d80acc66 100644 --- a/plugins/node/opentelemetry-instrumentation-winston/README.md +++ b/plugins/node/opentelemetry-instrumentation-winston/README.md @@ -60,6 +60,7 @@ logger.info('foobar'); | Option | Type | Description | | ----------------------- | ----------------- | ----------- | | `disableLogSending` | `boolean` | Whether to disable [log sending](#log-sending). Default `false`. | +| `logSeverity` | `SeverityNumber` | Control severity level for [log sending](#log-sending). Default `SeverityNumber.UNSPECIFIED`, it will use Winston Logger's current level when unspecified. | | `disableLogCorrelation` | `boolean` | Whether to disable [log correlation](#log-correlation). Default `false`. | | `logHook` | `LogHookFunction` | An option hook to inject additional context to a log record after trace-context has been added. This requires `disableLogCorrelation` to be false. | diff --git a/plugins/node/opentelemetry-instrumentation-winston/package.json b/plugins/node/opentelemetry-instrumentation-winston/package.json index faeb6280f3..0c25fbb7cb 100644 --- a/plugins/node/opentelemetry-instrumentation-winston/package.json +++ b/plugins/node/opentelemetry-instrumentation-winston/package.json @@ -64,6 +64,7 @@ "winston2": "npm:winston@2.4.7" }, "dependencies": { + "@opentelemetry/api-logs": "^0.50.0", "@opentelemetry/instrumentation": "^0.50.0" }, "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-winston#readme" diff --git a/plugins/node/opentelemetry-instrumentation-winston/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-winston/src/instrumentation.ts index d89107144c..de72ed235b 100644 --- a/plugins/node/opentelemetry-instrumentation-winston/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-winston/src/instrumentation.ts @@ -15,6 +15,7 @@ */ import { context, trace, isSpanContextValid, Span } from '@opentelemetry/api'; +import { SeverityNumber } from '@opentelemetry/api-logs'; import { InstrumentationBase, InstrumentationNodeModuleDefinition, @@ -206,7 +207,17 @@ export class WinstonInstrumentation extends InstrumentationBase { let newTransports = Array.isArray(originalTransports) ? originalTransports : []; - const openTelemetryTransport = new OpenTelemetryTransportV3(); + let transportOptions = {}; + if (config.logSeverity) { + const winstonLevel = instrumentation._winstonLevelFromSeverity( + config.logSeverity, + args[0].levels + ); + transportOptions = { level: winstonLevel }; + } + const openTelemetryTransport = new OpenTelemetryTransportV3( + transportOptions + ); if (originalTransports && !Array.isArray(originalTransports)) { newTransports = [originalTransports]; } @@ -244,4 +255,118 @@ export class WinstonInstrumentation extends InstrumentationBase { } return record; } + + private _winstonLevelFromSeverity( + severity: SeverityNumber, + winstonLevels: { [key: string]: number } | undefined + ): string | undefined { + if (winstonLevels) { + if (isNpmLevels(winstonLevels)) { + if (severity >= SeverityNumber.ERROR) { + return 'error'; + } else if (severity >= SeverityNumber.WARN) { + return 'warn'; + } else if (severity >= SeverityNumber.INFO) { + return 'info'; + } else if (severity >= SeverityNumber.DEBUG3) { + return 'http'; + } else if (severity >= SeverityNumber.DEBUG2) { + return 'verbose'; + } else if (severity >= SeverityNumber.DEBUG) { + return 'debug'; + } else if (severity >= SeverityNumber.TRACE) { + return 'silly'; + } + } else if (isCliLevels(winstonLevels)) { + if (severity >= SeverityNumber.ERROR) { + return 'error'; + } else if (severity >= SeverityNumber.WARN) { + return 'warn'; + } else if (severity >= SeverityNumber.INFO3) { + return 'help'; + } else if (severity >= SeverityNumber.INFO2) { + return 'data'; + } else if (severity >= SeverityNumber.INFO) { + return 'info'; + } else if (severity >= SeverityNumber.DEBUG) { + return 'debug'; + } else if (severity >= SeverityNumber.TRACE4) { + return 'prompt'; + } else if (severity >= SeverityNumber.TRACE3) { + return 'verbose'; + } else if (severity >= SeverityNumber.TRACE2) { + return 'input'; + } else if (severity >= SeverityNumber.TRACE) { + return 'silly'; + } + } else if (isSyslogLevels(winstonLevels)) { + if (severity >= SeverityNumber.FATAL2) { + return 'emerg'; + } else if (severity >= SeverityNumber.FATAL) { + return 'alert'; + } else if (severity >= SeverityNumber.ERROR2) { + return 'crit'; + } else if (severity >= SeverityNumber.ERROR) { + return 'error'; + } else if (severity >= SeverityNumber.WARN) { + return 'warning'; + } else if (severity >= SeverityNumber.INFO2) { + return 'notice'; + } else if (severity >= SeverityNumber.INFO) { + return 'info'; + } else if (severity >= SeverityNumber.TRACE) { + return 'debug'; + } + } + // Unknown level + this._diag.warn( + 'failed to configure severity with existing winston levels' + ); + } + + function isCliLevels(arg: any): boolean { + return ( + arg && + arg.error !== undefined && + arg.warn && + arg.help && + arg.data && + arg.info && + arg.debug && + arg.prompt && + arg.verbose && + arg.input && + arg.silly + ); + } + + function isNpmLevels(arg: any): boolean { + return ( + arg && + arg.error !== undefined && + arg.warn && + arg.info && + arg.http && + arg.verbose && + arg.debug && + arg.silly + ); + } + + function isSyslogLevels(arg: any): boolean { + return ( + arg && + arg.emerg !== undefined && + arg.alert && + arg.crit && + arg.error && + arg.warning && + arg.notice && + arg.info && + arg.debug + ); + } + + return; + } } diff --git a/plugins/node/opentelemetry-instrumentation-winston/src/internal-types.ts b/plugins/node/opentelemetry-instrumentation-winston/src/internal-types.ts index cba7ee90d2..e71eff3c83 100644 --- a/plugins/node/opentelemetry-instrumentation-winston/src/internal-types.ts +++ b/plugins/node/opentelemetry-instrumentation-winston/src/internal-types.ts @@ -22,7 +22,6 @@ import type { export type Winston3LogMethod = Winston3Logger['write']; export type Winston3ConfigureMethod = Winston3Logger['configure']; export type { Winston3Logger }; - export type { Winston2LogMethod }; export type Winston2LoggerModule = { Logger: Winston2Logger & { diff --git a/plugins/node/opentelemetry-instrumentation-winston/src/types.ts b/plugins/node/opentelemetry-instrumentation-winston/src/types.ts index 5621bc8797..e6fabea502 100644 --- a/plugins/node/opentelemetry-instrumentation-winston/src/types.ts +++ b/plugins/node/opentelemetry-instrumentation-winston/src/types.ts @@ -15,6 +15,7 @@ */ import { Span } from '@opentelemetry/api'; +import { SeverityNumber } from '@opentelemetry/api-logs'; import { InstrumentationConfig } from '@opentelemetry/instrumentation'; // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -28,6 +29,11 @@ export interface WinstonInstrumentationConfig extends InstrumentationConfig { */ disableLogSending?: boolean; + /** + * Control Log sending severity level, logs will be sent for specified severity and higher. + */ + logSeverity?: SeverityNumber; + /** * Whether to disable the injection trace-context fields, and possibly other * fields from `logHook()`, into log records for log correlation. diff --git a/plugins/node/opentelemetry-instrumentation-winston/test/winston.test.ts b/plugins/node/opentelemetry-instrumentation-winston/test/winston.test.ts index fe62a946b9..2ecb4eab37 100644 --- a/plugins/node/opentelemetry-instrumentation-winston/test/winston.test.ts +++ b/plugins/node/opentelemetry-instrumentation-winston/test/winston.test.ts @@ -383,4 +383,89 @@ describe('WinstonInstrumentation', () => { } }); }); + describe('logSeverity config', () => { + beforeEach(() => { + instrumentation.setConfig({ + disableLogSending: false, + }); + memoryLogExporter.getFinishedLogRecords().length = 0; // clear + }); + + it('npm levels', () => { + if (!isWinston2) { + instrumentation.setConfig({ + disableLogSending: false, + logSeverity: SeverityNumber.DEBUG, + }); + initLogger(LevelsType.npm); + logger.log('silly', 'silly'); + logger.log('debug', 'debug'); + logger.log('verbose', 'verbose'); + logger.log('http', 'http'); + logger.log('info', 'info'); + logger.log('warn', 'warn'); + logger.log('error', 'error'); + const logRecords = memoryLogExporter.getFinishedLogRecords(); + assert.strictEqual(logRecords.length, 6); + assert.strictEqual(logRecords[0].body, 'debug'); + assert.strictEqual(logRecords[1].body, 'verbose'); + assert.strictEqual(logRecords[2].body, 'http'); + assert.strictEqual(logRecords[3].body, 'info'); + assert.strictEqual(logRecords[4].body, 'warn'); + assert.strictEqual(logRecords[5].body, 'error'); + } + }); + + it('cli levels', () => { + if (!isWinston2) { + instrumentation.setConfig({ + disableLogSending: false, + logSeverity: SeverityNumber.INFO, + }); + initLogger(LevelsType.cli); + logger.log('silly', 'silly'); + logger.log('input', 'input'); + logger.log('verbose', 'verbose'); + logger.log('prompt', 'prompt'); + logger.log('debug', 'debug'); + logger.log('info', 'info'); + logger.log('data', 'data'); + logger.log('help', 'help'); + logger.log('warn', 'warn'); + logger.log('error', 'error'); + const logRecords = memoryLogExporter.getFinishedLogRecords(); + assert.strictEqual(logRecords.length, 5); + assert.strictEqual(logRecords[0].body, 'info'); + assert.strictEqual(logRecords[1].body, 'data'); + assert.strictEqual(logRecords[2].body, 'help'); + assert.strictEqual(logRecords[3].body, 'warn'); + assert.strictEqual(logRecords[4].body, 'error'); + } + }); + + it('syslog levels', () => { + if (!isWinston2) { + instrumentation.setConfig({ + disableLogSending: false, + logSeverity: SeverityNumber.WARN, + }); + initLogger(LevelsType.syslog); + logger.log('debug', 'debug'); + logger.log('info', 'info'); + logger.log('notice', 'notice'); + logger.log('warning', 'warning'); + logger.log('error', 'error'); + logger.log('crit', 'crit'); + logger.log('alert', 'alert'); + logger.log('emerg', 'emerg'); + const logRecords = memoryLogExporter.getFinishedLogRecords(); + assert.strictEqual(logRecords.length, 5); + assert.strictEqual(logRecords[0].body, 'warning'); + assert.strictEqual(logRecords[1].body, 'error'); + assert.strictEqual(logRecords[2].body, 'crit'); + assert.strictEqual(logRecords[3].body, 'alert'); + assert.strictEqual(logRecords[4].body, 'emerg'); + } + }); + }); }); diff --git a/plugins/web/opentelemetry-instrumentation-document-load/LICENSE b/plugins/web/opentelemetry-instrumentation-document-load/LICENSE index e50e8c80f9..261eeb9e9f 100644 --- a/plugins/web/opentelemetry-instrumentation-document-load/LICENSE +++ b/plugins/web/opentelemetry-instrumentation-document-load/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/plugins/web/opentelemetry-instrumentation-user-interaction/LICENSE b/plugins/web/opentelemetry-instrumentation-user-interaction/LICENSE index e50e8c80f9..261eeb9e9f 100644 --- a/plugins/web/opentelemetry-instrumentation-user-interaction/LICENSE +++ b/plugins/web/opentelemetry-instrumentation-user-interaction/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/plugins/web/opentelemetry-plugin-react-load/LICENSE b/plugins/web/opentelemetry-plugin-react-load/LICENSE index e50e8c80f9..261eeb9e9f 100644 --- a/plugins/web/opentelemetry-plugin-react-load/LICENSE +++ b/plugins/web/opentelemetry-plugin-react-load/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/propagators/opentelemetry-propagator-aws-xray/.eslintignore b/propagators/opentelemetry-propagator-aws-xray/.eslintignore deleted file mode 100644 index 378eac25d3..0000000000 --- a/propagators/opentelemetry-propagator-aws-xray/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -build diff --git a/propagators/opentelemetry-propagator-aws-xray/.eslintrc.js b/propagators/opentelemetry-propagator-aws-xray/.eslintrc.js deleted file mode 100644 index 01b8d09740..0000000000 --- a/propagators/opentelemetry-propagator-aws-xray/.eslintrc.js +++ /dev/null @@ -1,9 +0,0 @@ -module.exports = { - "env": { - "mocha": true, - "commonjs": true, - "browser": true, - "jquery": true - }, - ...require('../../eslint.config.js') -} diff --git a/propagators/opentelemetry-propagator-aws-xray/CHANGELOG.md b/propagators/opentelemetry-propagator-aws-xray/CHANGELOG.md deleted file mode 100644 index 3a072e7e09..0000000000 --- a/propagators/opentelemetry-propagator-aws-xray/CHANGELOG.md +++ /dev/null @@ -1,62 +0,0 @@ -# Changelog - -## [1.3.1](https://github.com/open-telemetry/opentelemetry-js-contrib/compare/propagator-aws-xray-v1.3.0...propagator-aws-xray-v1.3.1) (2023-08-14) - - -### Bug Fixes - -* Revert "feat(minification): Add importHelpers and tslib as a dependency ([#1545](https://github.com/open-telemetry/opentelemetry-js-contrib/issues/1545))" ([#1611](https://github.com/open-telemetry/opentelemetry-js-contrib/issues/1611)) ([e5bca5f](https://github.com/open-telemetry/opentelemetry-js-contrib/commit/e5bca5fe5b27adc59c8de8fe4087d38b69d93bd4)) - -## [1.3.0](https://github.com/open-telemetry/opentelemetry-js-contrib/compare/propagator-aws-xray-v1.2.1...propagator-aws-xray-v1.3.0) (2023-07-12) - - -### Features - -* **minification:** Add importHelpers and tslib as a dependency ([#1545](https://github.com/open-telemetry/opentelemetry-js-contrib/issues/1545)) ([65f612e](https://github.com/open-telemetry/opentelemetry-js-contrib/commit/65f612e35c4d67b9935dc3a9155588b35d915482)) - -## [1.2.1](https://github.com/open-telemetry/opentelemetry-js-contrib/compare/propagator-aws-xray-v1.2.0...propagator-aws-xray-v1.2.1) (2023-05-16) - - -### Bug Fixes - -* **eslint-config:** replace gts with prettier and eslint ([#1439](https://github.com/open-telemetry/opentelemetry-js-contrib/issues/1439)) ([2571c37](https://github.com/open-telemetry/opentelemetry-js-contrib/commit/2571c371be1b5738442200cab2415b6a04c32aab)) - -## [1.2.0](https://github.com/open-telemetry/opentelemetry-js-contrib/compare/propagator-aws-xray-v1.1.1...propagator-aws-xray-v1.2.0) (2023-02-07) - - -### Features - -* **propagator/aws-xray:** Extract X-Ray header in a case-insensitive fashion ([#1328](https://github.com/open-telemetry/opentelemetry-js-contrib/issues/1328)) ([4227d8a](https://github.com/open-telemetry/opentelemetry-js-contrib/commit/4227d8a3df7b0782d76844e89d452e0432a704f4)) - -## [1.1.1](https://github.com/open-telemetry/opentelemetry-js-contrib/compare/propagator-aws-xray-v1.1.0...propagator-aws-xray-v1.1.1) (2022-11-02) - - -### Bug Fixes - -* address webpack memory issue for browser tests ([#1264](https://github.com/open-telemetry/opentelemetry-js-contrib/issues/1264)) ([c7f08fe](https://github.com/open-telemetry/opentelemetry-js-contrib/commit/c7f08fed51bca68b0c522769c3c589102b98ec93)) - -## [1.1.0](https://github.com/open-telemetry/opentelemetry-js-contrib/compare/propagator-aws-xray-v1.0.1...propagator-aws-xray-v1.1.0) (2022-05-14) - - -### Features - -* add supported node versions for all packages ([#973](https://github.com/open-telemetry/opentelemetry-js-contrib/issues/973)) ([baaacbd](https://github.com/open-telemetry/opentelemetry-js-contrib/commit/baaacbdd35ca4baab0afae64647aa8c0380ee4b7)) -* remove colors dependency ([#943](https://github.com/open-telemetry/opentelemetry-js-contrib/issues/943)) ([b21b96c](https://github.com/open-telemetry/opentelemetry-js-contrib/commit/b21b96c1a3a4f871370f970d6b2825f00e1fe595)), closes [#826](https://github.com/open-telemetry/opentelemetry-js-contrib/issues/826) -* update webpack outside of examples ([#963](https://github.com/open-telemetry/opentelemetry-js-contrib/issues/963)) ([9a58648](https://github.com/open-telemetry/opentelemetry-js-contrib/commit/9a586480ed6a7677fb1283a61d05540345c52617)) -* use Otel SDK 1.2/0.28 ([#984](https://github.com/open-telemetry/opentelemetry-js-contrib/issues/984)) ([098c2ed](https://github.com/open-telemetry/opentelemetry-js-contrib/commit/098c2ed6f9c5ab7bd865685018c0777245aab3b7)) - -### [1.0.1](https://www.github.com/open-telemetry/opentelemetry-js-contrib/compare/propagator-aws-xray-v1.0.0...propagator-aws-xray-v1.0.1) (2022-01-24) - - -### Bug Fixes - -* fix CI by forcing colors@1.4.0 ([#825](https://www.github.com/open-telemetry/opentelemetry-js-contrib/issues/825)) ([0ec9f08](https://www.github.com/open-telemetry/opentelemetry-js-contrib/commit/0ec9f080520fe0f146a915a656300ef53a151ace)) -* rename lerna's --include-filtered-dependencies option ([#817](https://www.github.com/open-telemetry/opentelemetry-js-contrib/issues/817)) ([cf268e7](https://www.github.com/open-telemetry/opentelemetry-js-contrib/commit/cf268e7a92b7800ad6dbec9ca77466f9ee03ee1a)) - -## [1.0.0](https://www.github.com/open-telemetry/opentelemetry-js-contrib/compare/propagator-aws-xray-v0.25.0...propagator-aws-xray-v1.0.0) (2021-10-22) - - -### Features - -* bumped aws components to 1.0 ([#658](https://www.github.com/open-telemetry/opentelemetry-js-contrib/issues/658)) ([44d21fe](https://www.github.com/open-telemetry/opentelemetry-js-contrib/commit/44d21fe5030d2f64bedde1efc50a1173e0c49f3d)) -* support API and SDK 1.0 ([#706](https://www.github.com/open-telemetry/opentelemetry-js-contrib/issues/706)) ([096b694](https://www.github.com/open-telemetry/opentelemetry-js-contrib/commit/096b694bbc3079f0ab4ee0462869b10eb8185202)) diff --git a/propagators/opentelemetry-propagator-aws-xray/LICENSE b/propagators/opentelemetry-propagator-aws-xray/LICENSE deleted file mode 100644 index e50e8c80f9..0000000000 --- a/propagators/opentelemetry-propagator-aws-xray/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [2022] OpenTelemetry Authors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/propagators/opentelemetry-propagator-aws-xray/README.md b/propagators/opentelemetry-propagator-aws-xray/README.md deleted file mode 100644 index 9f2cb4e307..0000000000 --- a/propagators/opentelemetry-propagator-aws-xray/README.md +++ /dev/null @@ -1,78 +0,0 @@ -# OpenTelemetry Propagator AWS X-Ray - -[![NPM Published Version][npm-img]][npm-url] -[![Apache License][license-image]][license-image] - -The OpenTelemetry Propagator for AWS X-Ray provides HTTP header propagation for systems that are using AWS `X-Amzn-Trace-Id` format. -This propagator translates the OpenTelemetry SpanContext into the equivalent AWS header format, for use with the OpenTelemetry JS SDK. -`TraceState` is currently not propagated. - -## Status - -| Maturity | [Component Owner](../../.github/component_owners.yml) | Compatibility | -| ----------------------------------------- | ----------------------------------------------------- | --------------------- | -| [Stable](../../../CONTRIBUTING.md#stable) | @carolabadeer | API 1.0+
SDK 1.0+ | - -## Installation - -```sh -npm install --save @opentelemetry/propagator-aws-xray -``` - -## Usage - -In the [global tracer configuration file](https://opentelemetry.io/docs/instrumentation/js/getting-started/nodejs/#setup), configure the following: - -```js -const { NodeTracerProvider } = require('@opentelemetry/sdk-trace-node'); -const { AWSXRayPropagator } = require('@opentelemetry/propagator-aws-xray'); -// ... - -const provider = new NodeTracerProvider(); - -// Set the global trace context propagator to use X-Ray formatted trace header -provider.register({ - propagator: new AWSXRayPropagator() -}); -``` - -## Propagator Details - -Example header:`X-Amzn-Trace-Id: Root=1-5759e988-bd862e3fe1be46a994272793;Parent=53995c3f42cd8ad8;Sampled=1` - -The header consists of three parts: the root trace ID, the parent ID and the sampling decision. - -### Root - The AWS X-Ray format trace ID - -* Format: (spec-version)-(timestamp)-(UUID) - * spec_version - The version of the AWS X-Ray header format. Currently, only "1" is valid. - * timestamp - 32-bit number in base16 format, corresponds to the first 8 characters of the OpenTelemetry trace ID. Note, while X-Ray calls this timestamp, for the purpose of propagation it is opaque and any value will work. - * UUID - 96-bit random number in base16 format, corresponds to the last 10 characters of the OpenTelemetry trace ID. - -Root is analogous to the [OpenTelemetry Trace ID](https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/overview.md#spancontext), with some small format changes. -For additional reading, see the [AWS X-Ray Trace ID](https://docs.aws.amazon.com/xray/latest/devguide/xray-api-sendingdata.html#xray-api-traceids) public documentation. - -### Parent - The ID of the AWS X-Ray Segment - -* 64-bit random number in base16 format. Populated from the [OpenTelemetry Span ID](https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/overview.md#spancontext). - -### Sampled - The sampling decision - -* Defined in the AWS X-Ray specification as a tri-state field, with "0", "1" and "?" as valid values. Only "0" and "1" are used in this propagator. If "?", a new trace will be started. -* Populated from the [OpenTelemetry trace flags](https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/overview.md#spancontext). - -## Useful links - -* For more information on OpenTelemetry, visit: -* For more about OpenTelemetry JavaScript: -* For help or feedback on this project, join us in [GitHub Discussions][discussions-url] - -## License - -Apache 2.0 - See [LICENSE][license-url] for more information. - -[discussions-url]: https://github.com/open-telemetry/opentelemetry-js/discussions -[license-url]: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/LICENSE -[license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat -[npm-url]: https://www.npmjs.com/package/@opentelemetry/propagator-aws-xray -[npm-img]: https://badge.fury.io/js/%40opentelemetry%2Fpropagator-aws-xray.svg diff --git a/propagators/opentelemetry-propagator-aws-xray/karma.conf.js b/propagators/opentelemetry-propagator-aws-xray/karma.conf.js deleted file mode 100644 index edcd9f055f..0000000000 --- a/propagators/opentelemetry-propagator-aws-xray/karma.conf.js +++ /dev/null @@ -1,24 +0,0 @@ -/*! - * Copyright 2020, OpenTelemetry Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -const karmaWebpackConfig = require('../../karma.webpack'); -const karmaBaseConfig = require('../../karma.base'); - -module.exports = (config) => { - config.set(Object.assign({}, karmaBaseConfig, { - webpack: karmaWebpackConfig - })) -}; diff --git a/propagators/opentelemetry-propagator-aws-xray/package.json b/propagators/opentelemetry-propagator-aws-xray/package.json deleted file mode 100644 index f96cceba01..0000000000 --- a/propagators/opentelemetry-propagator-aws-xray/package.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "name": "@opentelemetry/propagator-aws-xray", - "version": "1.3.1", - "description": "OpenTelemetry AWS Xray propagator provides context propagation for systems that are using AWS X-Ray format.", - "main": "build/src/index.js", - "module": "build/esm/index.js", - "types": "build/src/index.d.ts", - "repository": "open-telemetry/opentelemetry-js-contrib", - "scripts": { - "precompile": "tsc --version && lerna run version:update --scope @opentelemetry/propagator-aws-xray --include-dependencies", - "prewatch": "npm run precompile", - "compile": "tsc --build tsconfig.json tsconfig.esm.json", - "clean": "tsc --build --clean tsconfig.json tsconfig.esm.json", - "test": "nyc ts-mocha -p tsconfig.json test/**/*.test.ts", - "test:browser": "nyc karma start --single-run", - "lint": "eslint . --ext .ts", - "lint:fix": "eslint . --ext .ts --fix", - "watch": "tsc --build --watch tsconfig.json tsconfig.esm.json", - "prepublishOnly": "npm run compile" - }, - "keywords": [ - "opentelemetry", - "nodejs", - "tracing", - "profiling", - "awsxray" - ], - "author": "OpenTelemetry Authors", - "license": "Apache-2.0", - "engines": { - "node": ">=14" - }, - "files": [ - "build/esm/**/*.js", - "build/esm/**/*.js.map", - "build/esm/**/*.d.ts", - "build/src/**/*.js", - "build/src/**/*.js.map", - "build/src/**/*.d.ts" - ], - "publishConfig": { - "access": "public" - }, - "peerDependencies": { - "@opentelemetry/api": "^1.0.0" - }, - "devDependencies": { - "@opentelemetry/api": "^1.0.0", - "@types/mocha": "8.2.3", - "@types/node": "18.6.5", - "@types/webpack-env": "1.16.2", - "@jsdevtools/coverage-istanbul-loader": "3.0.5", - "karma": "6.3.16", - "karma-chrome-launcher": "^3.1.1", - "karma-coverage-istanbul-reporter": "3.0.3", - "karma-mocha": "2.0.1", - "karma-spec-reporter": "0.0.36", - "karma-webpack": "4.0.2", - "mocha": "7.2.0", - "nyc": "15.1.0", - "rimraf": "5.0.5", - "ts-loader": "8.3.0", - "ts-mocha": "10.0.0", - "typescript": "4.4.4", - "webpack": "4.46.0" - }, - "dependencies": { - "@opentelemetry/core": "^1.0.0" - }, - "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/propagators/opentelemetry-propagator-aws-xray#readme" -} diff --git a/propagators/opentelemetry-propagator-aws-xray/src/AWSXRayPropagator.ts b/propagators/opentelemetry-propagator-aws-xray/src/AWSXRayPropagator.ts deleted file mode 100644 index e06568d9ee..0000000000 --- a/propagators/opentelemetry-propagator-aws-xray/src/AWSXRayPropagator.ts +++ /dev/null @@ -1,200 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { - trace, - Context, - TextMapPropagator, - SpanContext, - TraceFlags, - TextMapSetter, - TextMapGetter, - isSpanContextValid, - isValidSpanId, - isValidTraceId, - INVALID_TRACEID, - INVALID_SPANID, - INVALID_SPAN_CONTEXT, -} from '@opentelemetry/api'; - -export const AWSXRAY_TRACE_ID_HEADER = 'x-amzn-trace-id'; - -const TRACE_HEADER_DELIMITER = ';'; -const KV_DELIMITER = '='; - -const TRACE_ID_KEY = 'Root'; -const TRACE_ID_LENGTH = 35; -const TRACE_ID_VERSION = '1'; -const TRACE_ID_DELIMITER = '-'; -const TRACE_ID_DELIMITER_INDEX_1 = 1; -const TRACE_ID_DELIMITER_INDEX_2 = 10; -const TRACE_ID_FIRST_PART_LENGTH = 8; - -const PARENT_ID_KEY = 'Parent'; - -const SAMPLED_FLAG_KEY = 'Sampled'; -const IS_SAMPLED = '1'; -const NOT_SAMPLED = '0'; - -/** - * Implementation of the AWS X-Ray Trace Header propagation protocol. See AWS - * Tracing header spec - * - * An example AWS Xray Tracing Header is shown below: - * X-Amzn-Trace-Id: Root=1-5759e988-bd862e3fe1be46a994272793;Parent=53995c3f42cd8ad8;Sampled=1 - */ -export class AWSXRayPropagator implements TextMapPropagator { - inject(context: Context, carrier: unknown, setter: TextMapSetter) { - const spanContext = trace.getSpan(context)?.spanContext(); - if (!spanContext || !isSpanContextValid(spanContext)) return; - - const otTraceId = spanContext.traceId; - const timestamp = otTraceId.substring(0, TRACE_ID_FIRST_PART_LENGTH); - const randomNumber = otTraceId.substring(TRACE_ID_FIRST_PART_LENGTH); - - const parentId = spanContext.spanId; - const samplingFlag = - (TraceFlags.SAMPLED & spanContext.traceFlags) === TraceFlags.SAMPLED - ? IS_SAMPLED - : NOT_SAMPLED; - // TODO: Add OT trace state to the X-Ray trace header - - const traceHeader = `Root=1-${timestamp}-${randomNumber};Parent=${parentId};Sampled=${samplingFlag}`; - setter.set(carrier, AWSXRAY_TRACE_ID_HEADER, traceHeader); - } - - extract(context: Context, carrier: unknown, getter: TextMapGetter): Context { - const spanContext = this.getSpanContextFromHeader(carrier, getter); - if (!isSpanContextValid(spanContext)) return context; - - return trace.setSpan(context, trace.wrapSpanContext(spanContext)); - } - - fields(): string[] { - return [AWSXRAY_TRACE_ID_HEADER]; - } - - private getSpanContextFromHeader( - carrier: unknown, - getter: TextMapGetter - ): SpanContext { - const headerKeys = getter.keys(carrier); - const relevantHeaderKey = headerKeys.find(e => { - return e.toLowerCase() === AWSXRAY_TRACE_ID_HEADER; - }); - if (!relevantHeaderKey) { - return INVALID_SPAN_CONTEXT; - } - const traceHeader = getter.get(carrier, relevantHeaderKey); - - if (!traceHeader || typeof traceHeader !== 'string') { - return INVALID_SPAN_CONTEXT; - } - - let pos = 0; - let trimmedPart: string; - let parsedTraceId = INVALID_TRACEID; - let parsedSpanId = INVALID_SPANID; - let parsedTraceFlags = null; - while (pos < traceHeader.length) { - const delimiterIndex = traceHeader.indexOf(TRACE_HEADER_DELIMITER, pos); - if (delimiterIndex >= 0) { - trimmedPart = traceHeader.substring(pos, delimiterIndex).trim(); - pos = delimiterIndex + 1; - } else { - //last part - trimmedPart = traceHeader.substring(pos).trim(); - pos = traceHeader.length; - } - const equalsIndex = trimmedPart.indexOf(KV_DELIMITER); - - const value = trimmedPart.substring(equalsIndex + 1); - - if (trimmedPart.startsWith(TRACE_ID_KEY)) { - parsedTraceId = AWSXRayPropagator._parseTraceId(value); - } else if (trimmedPart.startsWith(PARENT_ID_KEY)) { - parsedSpanId = AWSXRayPropagator._parseSpanId(value); - } else if (trimmedPart.startsWith(SAMPLED_FLAG_KEY)) { - parsedTraceFlags = AWSXRayPropagator._parseTraceFlag(value); - } - } - if (parsedTraceFlags === null) { - return INVALID_SPAN_CONTEXT; - } - const resultSpanContext: SpanContext = { - traceId: parsedTraceId, - spanId: parsedSpanId, - traceFlags: parsedTraceFlags, - isRemote: true, - }; - if (!isSpanContextValid(resultSpanContext)) { - return INVALID_SPAN_CONTEXT; - } - return resultSpanContext; - } - - private static _parseTraceId(xrayTraceId: string): string { - // Check length of trace id - if (xrayTraceId.length !== TRACE_ID_LENGTH) { - return INVALID_TRACEID; - } - - // Check version trace id version - if (!xrayTraceId.startsWith(TRACE_ID_VERSION)) { - return INVALID_TRACEID; - } - - // Check delimiters - if ( - xrayTraceId.charAt(TRACE_ID_DELIMITER_INDEX_1) !== TRACE_ID_DELIMITER || - xrayTraceId.charAt(TRACE_ID_DELIMITER_INDEX_2) !== TRACE_ID_DELIMITER - ) { - return INVALID_TRACEID; - } - - const epochPart = xrayTraceId.substring( - TRACE_ID_DELIMITER_INDEX_1 + 1, - TRACE_ID_DELIMITER_INDEX_2 - ); - const uniquePart = xrayTraceId.substring( - TRACE_ID_DELIMITER_INDEX_2 + 1, - TRACE_ID_LENGTH - ); - const resTraceId = epochPart + uniquePart; - - // Check the content of trace id - if (!isValidTraceId(resTraceId)) { - return INVALID_TRACEID; - } - - return resTraceId; - } - - private static _parseSpanId(xrayParentId: string): string { - return isValidSpanId(xrayParentId) ? xrayParentId : INVALID_SPANID; - } - - private static _parseTraceFlag(xraySampledFlag: string): TraceFlags | null { - if (xraySampledFlag === NOT_SAMPLED) { - return TraceFlags.NONE; - } - if (xraySampledFlag === IS_SAMPLED) { - return TraceFlags.SAMPLED; - } - return null; - } -} diff --git a/propagators/opentelemetry-propagator-aws-xray/src/index.ts b/propagators/opentelemetry-propagator-aws-xray/src/index.ts deleted file mode 100644 index dea8476683..0000000000 --- a/propagators/opentelemetry-propagator-aws-xray/src/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export * from './AWSXRayPropagator'; diff --git a/propagators/opentelemetry-propagator-aws-xray/test/AWSXRayPropagator.test.ts b/propagators/opentelemetry-propagator-aws-xray/test/AWSXRayPropagator.test.ts deleted file mode 100644 index 5cf47916d5..0000000000 --- a/propagators/opentelemetry-propagator-aws-xray/test/AWSXRayPropagator.test.ts +++ /dev/null @@ -1,328 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as assert from 'assert'; - -import { - defaultTextMapGetter, - defaultTextMapSetter, - INVALID_SPAN_CONTEXT, - ROOT_CONTEXT, - SpanContext, - TraceFlags, - trace, -} from '@opentelemetry/api'; -import { TraceState } from '@opentelemetry/core'; - -import { AWSXRAY_TRACE_ID_HEADER, AWSXRayPropagator } from '../src'; - -describe('AWSXRayPropagator', () => { - const xrayPropagator = new AWSXRayPropagator(); - const TRACE_ID = '8a3c60f7d188f8fa79d48a391a778fa6'; - const SPAN_ID = '53995c3f42cd8ad8'; - const SAMPLED_TRACE_FLAG = TraceFlags.SAMPLED; - const NOT_SAMPLED_TRACE_FLAG = TraceFlags.NONE; - - let carrier: { [key: string]: unknown }; - - beforeEach(() => { - carrier = {}; - }); - - describe('.inject()', () => { - it('should inject sampled context', () => { - const spanContext: SpanContext = { - traceId: TRACE_ID, - spanId: SPAN_ID, - traceFlags: SAMPLED_TRACE_FLAG, - }; - xrayPropagator.inject( - trace.setSpan(ROOT_CONTEXT, trace.wrapSpanContext(spanContext)), - carrier, - defaultTextMapSetter - ); - - assert.deepStrictEqual( - carrier[AWSXRAY_TRACE_ID_HEADER], - 'Root=1-8a3c60f7-d188f8fa79d48a391a778fa6;Parent=53995c3f42cd8ad8;Sampled=1' - ); - }); - - it('should inject not sampled context', () => { - const spanContext: SpanContext = { - traceId: TRACE_ID, - spanId: SPAN_ID, - traceFlags: NOT_SAMPLED_TRACE_FLAG, - }; - xrayPropagator.inject( - trace.setSpan(ROOT_CONTEXT, trace.wrapSpanContext(spanContext)), - carrier, - defaultTextMapSetter - ); - - assert.deepStrictEqual( - carrier[AWSXRAY_TRACE_ID_HEADER], - 'Root=1-8a3c60f7-d188f8fa79d48a391a778fa6;Parent=53995c3f42cd8ad8;Sampled=0' - ); - }); - - it('should inject with TraceState', () => { - const traceState = new TraceState(); - traceState.set('foo', 'bar'); - const spanContext: SpanContext = { - traceId: TRACE_ID, - spanId: SPAN_ID, - traceFlags: SAMPLED_TRACE_FLAG, - traceState: traceState, - }; - xrayPropagator.inject( - trace.setSpan(ROOT_CONTEXT, trace.wrapSpanContext(spanContext)), - carrier, - defaultTextMapSetter - ); - - // TODO: assert trace state when the propagator supports it - assert.deepStrictEqual( - carrier[AWSXRAY_TRACE_ID_HEADER], - 'Root=1-8a3c60f7-d188f8fa79d48a391a778fa6;Parent=53995c3f42cd8ad8;Sampled=1' - ); - }); - - it('inject without spanContext - should inject nothing', () => { - xrayPropagator.inject(ROOT_CONTEXT, carrier, defaultTextMapSetter); - - assert.deepStrictEqual(carrier, {}); - }); - - it('inject default invalid spanContext - should inject nothing', () => { - xrayPropagator.inject( - trace.setSpan( - ROOT_CONTEXT, - trace.wrapSpanContext(INVALID_SPAN_CONTEXT) - ), - carrier, - defaultTextMapSetter - ); - - assert.deepStrictEqual(carrier, {}); - }); - }); - - describe('.extract()', () => { - it('extract nothing from context', () => { - // context remains untouched - assert.strictEqual( - xrayPropagator.extract(ROOT_CONTEXT, carrier, defaultTextMapGetter), - ROOT_CONTEXT - ); - }); - - it('should extract sampled context', () => { - carrier[AWSXRAY_TRACE_ID_HEADER] = - 'Root=1-8a3c60f7-d188f8fa79d48a391a778fa6;Parent=53995c3f42cd8ad8;Sampled=1'; - const extractedSpanContext = trace - .getSpan( - xrayPropagator.extract(ROOT_CONTEXT, carrier, defaultTextMapGetter) - ) - ?.spanContext(); - - assert.deepStrictEqual(extractedSpanContext, { - traceId: TRACE_ID, - spanId: SPAN_ID, - isRemote: true, - traceFlags: TraceFlags.SAMPLED, - }); - }); - - it('should extract sampled context with arbitrary order', () => { - carrier[AWSXRAY_TRACE_ID_HEADER] = - 'Parent=53995c3f42cd8ad8;Sampled=1;Root=1-8a3c60f7-d188f8fa79d48a391a778fa6'; - const extractedSpanContext = trace - .getSpan( - xrayPropagator.extract(ROOT_CONTEXT, carrier, defaultTextMapGetter) - ) - ?.spanContext(); - - assert.deepStrictEqual(extractedSpanContext, { - traceId: TRACE_ID, - spanId: SPAN_ID, - isRemote: true, - traceFlags: TraceFlags.SAMPLED, - }); - }); - - it('should extract context with additional fields', () => { - carrier[AWSXRAY_TRACE_ID_HEADER] = - 'Root=1-8a3c60f7-d188f8fa79d48a391a778fa6;Parent=53995c3f42cd8ad8;Sampled=1;Foo=Bar'; - const extractedSpanContext = trace - .getSpan( - xrayPropagator.extract(ROOT_CONTEXT, carrier, defaultTextMapGetter) - ) - ?.spanContext(); - - // TODO: assert additional fields when the propagator supports it - assert.deepStrictEqual(extractedSpanContext, { - traceId: TRACE_ID, - spanId: SPAN_ID, - isRemote: true, - traceFlags: TraceFlags.SAMPLED, - }); - }); - - it('extract empty header value - should return undefined', () => { - carrier[AWSXRAY_TRACE_ID_HEADER] = ''; - const extractedSpanContext = trace - .getSpan( - xrayPropagator.extract(ROOT_CONTEXT, carrier, defaultTextMapGetter) - ) - ?.spanContext(); - - assert.deepStrictEqual(extractedSpanContext, undefined); - }); - - it('extract invalid traceId - should return undefined', () => { - carrier[AWSXRAY_TRACE_ID_HEADER] = - 'Root=1-abcdefgh-ijklmnopabcdefghijklmnop;Parent=53995c3f42cd8ad8;Sampled=0'; - const extractedSpanContext = trace - .getSpan( - xrayPropagator.extract(ROOT_CONTEXT, carrier, defaultTextMapGetter) - ) - ?.spanContext(); - - assert.deepStrictEqual(extractedSpanContext, undefined); - }); - - it('extract invalid traceId size - should return undefined', () => { - carrier[AWSXRAY_TRACE_ID_HEADER] = - 'Root=1-8a3c60f7-d188f8fa79d48a391a778fa600;Parent=53995c3f42cd8ad8;Sampled=0'; - const extractedSpanContext = trace - .getSpan( - xrayPropagator.extract(ROOT_CONTEXT, carrier, defaultTextMapGetter) - ) - ?.spanContext(); - - assert.deepStrictEqual(extractedSpanContext, undefined); - }); - - it('extract invalid traceId delimiter - should return undefined', () => { - carrier[AWSXRAY_TRACE_ID_HEADER] = - 'Root=1*8a3c60f7+d188f8fa79d48a391a778fa6;Parent=53995c3f42cd8ad8;Sampled=1;Foo=Bar'; - const extractedSpanContext = trace - .getSpan( - xrayPropagator.extract(ROOT_CONTEXT, carrier, defaultTextMapGetter) - ) - ?.spanContext(); - - assert.deepStrictEqual(extractedSpanContext, undefined); - }); - - it('extract invalid spanId - should return undefined', () => { - carrier[AWSXRAY_TRACE_ID_HEADER] = - 'Root=1-8a3c60f7-d188f8fa79d48a391a778fa6;Parent=abcdefghijklmnop;Sampled=0'; - const extractedSpanContext = trace - .getSpan( - xrayPropagator.extract(ROOT_CONTEXT, carrier, defaultTextMapGetter) - ) - ?.spanContext(); - - assert.deepStrictEqual(extractedSpanContext, undefined); - }); - - it('extract invalid spanId size - should return undefined', () => { - carrier[AWSXRAY_TRACE_ID_HEADER] = - 'Root=1-8a3c60f7-d188f8fa79d48a391a778fa6;Parent=53995c3f42cd8ad800;Sampled=0'; - const extractedSpanContext = trace - .getSpan( - xrayPropagator.extract(ROOT_CONTEXT, carrier, defaultTextMapGetter) - ) - ?.spanContext(); - - assert.deepStrictEqual(extractedSpanContext, undefined); - }); - - it('extract invalid traceFlags - should return undefined', () => { - carrier[AWSXRAY_TRACE_ID_HEADER] = - 'Root=1-8a3c60f7-d188f8fa79d48a391a778fa6;Parent=53995c3f42cd8ad8;Sampled='; - const extractedSpanContext = trace - .getSpan( - xrayPropagator.extract(ROOT_CONTEXT, carrier, defaultTextMapGetter) - ) - ?.spanContext(); - - assert.deepStrictEqual(extractedSpanContext, undefined); - }); - - it('extract invalid traceFlags length - should return undefined', () => { - carrier[AWSXRAY_TRACE_ID_HEADER] = - 'Root=1-8a3c60f7-d188f8fa79d48a391a778fa6;Parent=53995c3f42cd8ad8;Sampled=10220'; - const extractedSpanContext = trace - .getSpan( - xrayPropagator.extract(ROOT_CONTEXT, carrier, defaultTextMapGetter) - ) - ?.spanContext(); - - assert.deepStrictEqual(extractedSpanContext, undefined); - }); - - it('extract nonnumeric invalid traceFlags - should return undefined', () => { - carrier[AWSXRAY_TRACE_ID_HEADER] = - 'Root=1-8a3c60f7-d188f8fa79d48a391a778fa6;Parent=53995c3f42cd8ad8;Sampled=a'; - const extractedSpanContext = trace - .getSpan( - xrayPropagator.extract(ROOT_CONTEXT, carrier, defaultTextMapGetter) - ) - ?.spanContext(); - - assert.deepStrictEqual(extractedSpanContext, undefined); - }); - - it('extract invalid aws xray version - should return undefined', () => { - carrier[AWSXRAY_TRACE_ID_HEADER] = - 'Root=2-8a3c60f7-d188f8fa79d48a391a778fa6;Parent=53995c3f42cd8ad8;Sampled=1'; - const extractedSpanContext = trace - .getSpan( - xrayPropagator.extract(ROOT_CONTEXT, carrier, defaultTextMapGetter) - ) - ?.spanContext(); - - assert.deepStrictEqual(extractedSpanContext, undefined); - }); - - it('extracts context in a case-insensitive fashion', () => { - carrier[AWSXRAY_TRACE_ID_HEADER.toUpperCase()] = - 'Root=1-8a3c60f7-d188f8fa79d48a391a778fa6;Parent=53995c3f42cd8ad8;Sampled=1;Foo=Bar'; - const extractedSpanContext = trace - .getSpan( - xrayPropagator.extract(ROOT_CONTEXT, carrier, defaultTextMapGetter) - ) - ?.spanContext(); - - assert.deepStrictEqual(extractedSpanContext, { - traceId: TRACE_ID, - spanId: SPAN_ID, - isRemote: true, - traceFlags: TraceFlags.SAMPLED, - }); - }); - - describe('.fields()', () => { - it('should return a field with AWS X-Ray Trace ID header', () => { - const expectedField = xrayPropagator.fields(); - - assert.deepStrictEqual([AWSXRAY_TRACE_ID_HEADER], expectedField); - }); - }); - }); -}); diff --git a/propagators/opentelemetry-propagator-aws-xray/test/index-webpack.ts b/propagators/opentelemetry-propagator-aws-xray/test/index-webpack.ts deleted file mode 100644 index 061a48ccfa..0000000000 --- a/propagators/opentelemetry-propagator-aws-xray/test/index-webpack.ts +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -const testsContext = require.context('.', true, /test$/); -testsContext.keys().forEach(testsContext); - -const srcContext = require.context('.', true, /src$/); -srcContext.keys().forEach(srcContext); diff --git a/propagators/opentelemetry-propagator-aws-xray/tsconfig.esm.json b/propagators/opentelemetry-propagator-aws-xray/tsconfig.esm.json deleted file mode 100644 index a94adff6aa..0000000000 --- a/propagators/opentelemetry-propagator-aws-xray/tsconfig.esm.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "extends": "../../tsconfig.base.esm.json", - "compilerOptions": { - "rootDir": "src", - "outDir": "build/esm", - "tsBuildInfoFile": "build/esm/tsconfig.esm.tsbuildinfo" - }, - "include": [ - "src/**/*.ts" - ] -} diff --git a/propagators/opentelemetry-propagator-aws-xray/tsconfig.json b/propagators/opentelemetry-propagator-aws-xray/tsconfig.json deleted file mode 100644 index 4078877ce6..0000000000 --- a/propagators/opentelemetry-propagator-aws-xray/tsconfig.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "extends": "../../tsconfig.base", - "compilerOptions": { - "rootDir": ".", - "outDir": "build" - }, - "include": [ - "src/**/*.ts", - "test/**/*.ts" - ] -} diff --git a/propagators/opentelemetry-propagator-grpc-census-binary/LICENSE b/propagators/opentelemetry-propagator-grpc-census-binary/LICENSE index e50e8c80f9..261eeb9e9f 100644 --- a/propagators/opentelemetry-propagator-grpc-census-binary/LICENSE +++ b/propagators/opentelemetry-propagator-grpc-census-binary/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/propagators/opentelemetry-propagator-instana/LICENSE b/propagators/opentelemetry-propagator-instana/LICENSE index e50e8c80f9..261eeb9e9f 100644 --- a/propagators/opentelemetry-propagator-instana/LICENSE +++ b/propagators/opentelemetry-propagator-instana/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/propagators/opentelemetry-propagator-ot-trace/LICENSE b/propagators/opentelemetry-propagator-ot-trace/LICENSE index e50e8c80f9..261eeb9e9f 100644 --- a/propagators/opentelemetry-propagator-ot-trace/LICENSE +++ b/propagators/opentelemetry-propagator-ot-trace/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] OpenTelemetry Authors + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/release-please-config.json b/release-please-config.json index 746fc5ced8..243d5ebd64 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -64,7 +64,6 @@ "plugins/web/opentelemetry-instrumentation-long-task": {}, "plugins/web/opentelemetry-instrumentation-user-interaction": {}, "plugins/web/opentelemetry-plugin-react-load": {}, - "propagators/opentelemetry-propagator-aws-xray": {}, "propagators/opentelemetry-propagator-grpc-census-binary": {}, "propagators/opentelemetry-propagator-instana": {}, "propagators/opentelemetry-propagator-ot-trace": {}