diff --git a/.github/component_owners.yml b/.github/component_owners.yml index a3ad46b401..880c784403 100644 --- a/.github/component_owners.yml +++ b/.github/component_owners.yml @@ -4,6 +4,9 @@ components: - legendecas detectors/node/opentelemetry-resource-detector-aws: - carolabadeer + detectors/node/opentelemetry-resource-detector-azure: + - jacksonweber + - hectorhdzg detectors/node/opentelemetry-resource-detector-container: - abhee11 detectors/node/opentelemetry-resource-detector-gcp: diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 048875a6cf..061a464830 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -15,7 +15,7 @@ jobs: fetch-depth: 0 - name: Setup Node - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: 14 registry-url: 'https://registry.npmjs.org' diff --git a/.github/workflows/test-all-versions.yml b/.github/workflows/test-all-versions.yml index 2b480d8be2..7941917545 100644 --- a/.github/workflows/test-all-versions.yml +++ b/.github/workflows/test-all-versions.yml @@ -110,7 +110,7 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v4 with: node-version: ${{ matrix.node }} - name: Set MySQL variables diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index d5bdf612ce..2e82c88a96 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -118,7 +118,7 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v4 with: node-version: ${{ matrix.node }} - name: Set MySQL variables @@ -177,7 +177,7 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v4 with: node-version: ${{ matrix.node }} - name: Cache Dependencies diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 15dcd7fa2b..9436b24cd1 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1 +1 @@ -{"detectors/node/opentelemetry-resource-detector-alibaba-cloud":"0.28.2","detectors/node/opentelemetry-resource-detector-aws":"1.3.2","detectors/node/opentelemetry-resource-detector-container":"0.3.2","detectors/node/opentelemetry-resource-detector-gcp":"0.29.2","detectors/node/opentelemetry-resource-detector-github":"0.28.1","detectors/node/opentelemetry-resource-detector-instana":"0.5.2","metapackages/auto-instrumentations-node":"0.39.3","metapackages/auto-instrumentations-web":"0.33.2","packages/opentelemetry-host-metrics":"0.33.1","packages/opentelemetry-id-generator-aws-xray":"1.2.1","packages/opentelemetry-propagation-utils":"0.30.2","packages/opentelemetry-redis-common":"0.36.1","packages/opentelemetry-sql-common":"0.40.0","packages/opentelemetry-test-utils":"0.34.2","plugins/node/instrumentation-amqplib":"0.33.2","plugins/node/instrumentation-cucumber":"0.1.1","plugins/node/instrumentation-dataloader":"0.5.2","plugins/node/instrumentation-fs":"0.8.2","plugins/node/instrumentation-lru-memoizer":"0.33.2","plugins/node/instrumentation-mongoose":"0.33.2","plugins/node/instrumentation-socket.io":"0.34.2","plugins/node/instrumentation-tedious":"0.6.2","plugins/node/opentelemetry-instrumentation-aws-lambda":"0.37.1","plugins/node/opentelemetry-instrumentation-aws-sdk":"0.36.1","plugins/node/opentelemetry-instrumentation-bunyan":"0.32.2","plugins/node/opentelemetry-instrumentation-cassandra":"0.33.2","plugins/node/opentelemetry-instrumentation-connect":"0.32.2","plugins/node/opentelemetry-instrumentation-dns":"0.32.3","plugins/node/opentelemetry-instrumentation-express":"0.33.2","plugins/node/opentelemetry-instrumentation-fastify":"0.32.3","plugins/node/opentelemetry-instrumentation-generic-pool":"0.32.3","plugins/node/opentelemetry-instrumentation-graphql":"0.35.2","plugins/node/opentelemetry-instrumentation-hapi":"0.33.1","plugins/node/opentelemetry-instrumentation-ioredis":"0.35.2","plugins/node/opentelemetry-instrumentation-knex":"0.32.2","plugins/node/opentelemetry-instrumentation-koa":"0.36.1","plugins/node/opentelemetry-instrumentation-memcached":"0.32.2","plugins/node/opentelemetry-instrumentation-mongodb":"0.37.1","plugins/node/opentelemetry-instrumentation-mysql":"0.34.2","plugins/node/opentelemetry-instrumentation-mysql2":"0.34.2","plugins/node/opentelemetry-instrumentation-nestjs-core":"0.33.2","plugins/node/opentelemetry-instrumentation-net":"0.32.2","plugins/node/opentelemetry-instrumentation-pg":"0.36.2","plugins/node/opentelemetry-instrumentation-pino":"0.34.2","plugins/node/opentelemetry-instrumentation-redis":"0.35.2","plugins/node/opentelemetry-instrumentation-redis-4":"0.35.2","plugins/node/opentelemetry-instrumentation-restify":"0.34.1","plugins/node/opentelemetry-instrumentation-router":"0.33.2","plugins/node/opentelemetry-instrumentation-winston":"0.32.2","plugins/web/opentelemetry-instrumentation-document-load":"0.33.2","plugins/web/opentelemetry-instrumentation-long-task":"0.33.2","plugins/web/opentelemetry-instrumentation-user-interaction":"0.33.2","plugins/web/opentelemetry-plugin-react-load":"0.29.1","propagators/opentelemetry-propagator-aws-xray":"1.3.1","propagators/opentelemetry-propagator-grpc-census-binary":"0.27.1","propagators/opentelemetry-propagator-instana":"0.3.1","propagators/opentelemetry-propagator-ot-trace":"0.27.1"} +{"detectors/node/opentelemetry-resource-detector-alibaba-cloud":"0.28.2","detectors/node/opentelemetry-resource-detector-aws":"1.3.2","detectors/node/opentelemetry-resource-detector-azure":"0.1.0","detectors/node/opentelemetry-resource-detector-container":"0.3.2","detectors/node/opentelemetry-resource-detector-gcp":"0.29.2","detectors/node/opentelemetry-resource-detector-github":"0.28.1","detectors/node/opentelemetry-resource-detector-instana":"0.5.2","metapackages/auto-instrumentations-node":"0.39.4","metapackages/auto-instrumentations-web":"0.33.2","packages/opentelemetry-host-metrics":"0.33.1","packages/opentelemetry-id-generator-aws-xray":"1.2.1","packages/opentelemetry-propagation-utils":"0.30.2","packages/opentelemetry-redis-common":"0.36.1","packages/opentelemetry-sql-common":"0.40.0","packages/opentelemetry-test-utils":"0.34.2","plugins/node/instrumentation-amqplib":"0.33.2","plugins/node/instrumentation-cucumber":"0.1.1","plugins/node/instrumentation-dataloader":"0.5.2","plugins/node/instrumentation-fs":"0.8.2","plugins/node/instrumentation-lru-memoizer":"0.33.2","plugins/node/instrumentation-mongoose":"0.33.2","plugins/node/instrumentation-socket.io":"0.34.2","plugins/node/instrumentation-tedious":"0.6.2","plugins/node/opentelemetry-instrumentation-aws-lambda":"0.37.1","plugins/node/opentelemetry-instrumentation-aws-sdk":"0.36.1","plugins/node/opentelemetry-instrumentation-bunyan":"0.32.2","plugins/node/opentelemetry-instrumentation-cassandra":"0.33.2","plugins/node/opentelemetry-instrumentation-connect":"0.32.2","plugins/node/opentelemetry-instrumentation-dns":"0.32.3","plugins/node/opentelemetry-instrumentation-express":"0.33.2","plugins/node/opentelemetry-instrumentation-fastify":"0.32.3","plugins/node/opentelemetry-instrumentation-generic-pool":"0.32.3","plugins/node/opentelemetry-instrumentation-graphql":"0.35.2","plugins/node/opentelemetry-instrumentation-hapi":"0.33.1","plugins/node/opentelemetry-instrumentation-ioredis":"0.35.2","plugins/node/opentelemetry-instrumentation-knex":"0.32.2","plugins/node/opentelemetry-instrumentation-koa":"0.36.1","plugins/node/opentelemetry-instrumentation-memcached":"0.32.2","plugins/node/opentelemetry-instrumentation-mongodb":"0.37.1","plugins/node/opentelemetry-instrumentation-mysql":"0.34.2","plugins/node/opentelemetry-instrumentation-mysql2":"0.34.2","plugins/node/opentelemetry-instrumentation-nestjs-core":"0.33.2","plugins/node/opentelemetry-instrumentation-net":"0.32.2","plugins/node/opentelemetry-instrumentation-pg":"0.36.2","plugins/node/opentelemetry-instrumentation-pino":"0.34.2","plugins/node/opentelemetry-instrumentation-redis":"0.35.2","plugins/node/opentelemetry-instrumentation-redis-4":"0.35.3","plugins/node/opentelemetry-instrumentation-restify":"0.34.1","plugins/node/opentelemetry-instrumentation-router":"0.33.2","plugins/node/opentelemetry-instrumentation-winston":"0.32.2","plugins/web/opentelemetry-instrumentation-document-load":"0.33.2","plugins/web/opentelemetry-instrumentation-long-task":"0.33.2","plugins/web/opentelemetry-instrumentation-user-interaction":"0.33.2","plugins/web/opentelemetry-plugin-react-load":"0.29.1","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/detectors/node/opentelemetry-resource-detector-azure/.eslintignore b/detectors/node/opentelemetry-resource-detector-azure/.eslintignore new file mode 100644 index 0000000000..378eac25d3 --- /dev/null +++ b/detectors/node/opentelemetry-resource-detector-azure/.eslintignore @@ -0,0 +1 @@ +build diff --git a/detectors/node/opentelemetry-resource-detector-azure/.eslintrc.js b/detectors/node/opentelemetry-resource-detector-azure/.eslintrc.js new file mode 100644 index 0000000000..029ade4634 --- /dev/null +++ b/detectors/node/opentelemetry-resource-detector-azure/.eslintrc.js @@ -0,0 +1,7 @@ +module.exports = { + env: { + mocha: true, + node: true, + }, + ...require("../../../eslint.config.js"), +}; diff --git a/detectors/node/opentelemetry-resource-detector-azure/.npmignore b/detectors/node/opentelemetry-resource-detector-azure/.npmignore new file mode 100644 index 0000000000..42eabef04c --- /dev/null +++ b/detectors/node/opentelemetry-resource-detector-azure/.npmignore @@ -0,0 +1,3 @@ +/bin +/coverage +/test diff --git a/detectors/node/opentelemetry-resource-detector-azure/CHANGELOG.md b/detectors/node/opentelemetry-resource-detector-azure/CHANGELOG.md new file mode 100644 index 0000000000..c3dae7b4c9 --- /dev/null +++ b/detectors/node/opentelemetry-resource-detector-azure/CHANGELOG.md @@ -0,0 +1,7 @@ +# Changelog + +## [0.1.0]() () + +### Features + +* Added resource detectors for Azure App Services and VMs ([#1740](https://github.com/open-telemetry/opentelemetry-js-contrib/pull/1740)) diff --git a/detectors/node/opentelemetry-resource-detector-azure/LICENSE b/detectors/node/opentelemetry-resource-detector-azure/LICENSE new file mode 100644 index 0000000000..6f13cd2fe6 --- /dev/null +++ b/detectors/node/opentelemetry-resource-detector-azure/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [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. diff --git a/detectors/node/opentelemetry-resource-detector-azure/README.md b/detectors/node/opentelemetry-resource-detector-azure/README.md new file mode 100644 index 0000000000..ea4efc6862 --- /dev/null +++ b/detectors/node/opentelemetry-resource-detector-azure/README.md @@ -0,0 +1,77 @@ +# OpenTelemetry Resource Detector for Azure + +[![NPM Published Version][npm-img]][npm-url] +[![Apache License][license-image]][license-image] + +[component owners](https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/.github/component_owners.yml): @JacksonWeber + +Resource detector for Azure. + +## Installation + +```bash +npm install --save @opentelemetry/resource-detector-azure +``` + +## Usage + +```typescript +import { detectResources } from '@opentelemetry/resources'; +import { azureAppServiceDetector } from '@opentelemetry/resource-detector-azure'; +const resource = detectResourcesSync({ + detectors: [azureAppServiceDetector], +}); + +const tracerProvider = new NodeTracerProvider({ resource }); +``` + +## Available Detectors + +### App Service Resource Detector + +| Attribute | Description | +|-------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| azure.app.service.stamp | The specific "stamp" cluster within Azure where the App Service is running, e.g., "waws-prod-sn1-001". | +| cloud.platform | The cloud platform. Here, it's always "azure_app_service". | +| cloud.provider | The cloud service provider. In this context, it's always "azure". | +| cloud.resource_id | The Azure Resource Manager URI uniquely identifying the Azure App Service. Typically in the format "/subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Web/sites/{siteName}". | +| cloud.region | The Azure region where the App Service is hosted, e.g., "East US", "West Europe", etc. | +| deployment.environment | The deployment slot where the Azure App Service is running, such as "staging", "production", etc. | +| host.id | The primary hostname for the app, excluding any custom hostnames. | +| service.instance.id | The specific instance of the Azure App Service, useful in a scaled-out configuration. | +| service.name | The name of the Azure App Service. | + +### VM Resource Detector + +| Attribute | Description | +|--------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| azure.vm.scaleset.name | The name of the Virtual Machine Scale Set if the VM is part of one. | +| azure.vm.sku | The SKU of the Azure Virtual Machine's operating system. For instance, for a VM running Windows Server 2019 Datacenter edition, this value would be "2019-Datacenter". | +| cloud.platform | The cloud platform, which is always set to "azure_vm" in this context. | +| cloud.provider | The cloud service provider, which is always set to "azure" in this context. | +| cloud.region | The Azure region where the Virtual Machine is hosted, such as "East US", "West Europe", etc. | +| cloud.resource_id | The Azure Resource Manager URI uniquely identifying the Azure Virtual Machine. It typically follows this format: "/subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Compute/virtualMachines/{vmName}". | +| host.id | A unique identifier for the VM host, for instance, "02aab8a4-74ef-476e-8182-f6d2ba4166a6". | +| host.name | The name of the host machine. | +| host.type | The size of the VM instance, for example, "Standard_D2s_v3". | +| os.type | The type of operating system running on the VM, such as "Linux" or "Windows". | +| os.version | The version of the operating system running on the VM. | +| service.instance.id | An identifier for a specific instance of the service running on the Azure VM, for example, "02aab8a4-74ef-476e-8182-f6d2ba4166a6". | + +### Azure Functions Resource Detector + +| Attribute | Description | +|-------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| cloud.platform | The cloud platform. Here, it's always "azure_functions". | +| cloud.provider | The cloud service provider. In this context, it's always "azure". | +| cloud.region | The Azure region where the Azure Function is hosted, e.g., "East US", "West Europe", etc. | +| faas.instance | The specific instance of the Azure App Service, useful in a scaled-out configuration. | +| faas.name | The name of the Azure App Service. | +| faas.version | The version of the Azure Function being executed, e.g., "~4". | +| faas.max_memory | The amount of memory available to the Azure Function expressed in MiB. | + +## 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] diff --git a/detectors/node/opentelemetry-resource-detector-azure/package.json b/detectors/node/opentelemetry-resource-detector-azure/package.json new file mode 100644 index 0000000000..6b47e05fba --- /dev/null +++ b/detectors/node/opentelemetry-resource-detector-azure/package.json @@ -0,0 +1,53 @@ +{ + "name": "@opentelemetry/resource-detector-azure", + "version": "0.1.0", + "description": "OpenTelemetry SDK resource detector for Azure", + "main": "build/src/index.js", + "types": "build/src/index.d.ts", + "repository": "open-telemetry/opentelemetry-js-contrib", + "scripts": { + "clean": "rimraf build/*", + "compile": "tsc -p .", + "lint": "eslint . --ext .ts", + "lint:fix": "eslint . --ext .ts --fix", + "precompile": "tsc --version && lerna run version:update --scope @opentelemetry/resource-detector-azure --include-dependencies", + "prewatch": "npm run precompile", + "prepare": "npm run compile", + "test": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts'", + "tdd": "npm run test -- --watch-extensions ts --watch", + "watch": "tsc -w" + }, + "author": "OpenTelemetry Authors", + "license": "Apache-2.0", + "engines": { + "node": ">=14" + }, + "files": [ + "build/src/**/*.js", + "build/src/**/*.js.map", + "build/src/**/*.d.ts", + "LICENSE", + "README.md" + ], + "publishConfig": { + "access": "public" + }, + "devDependencies": { + "@opentelemetry/api": "^1.0.0", + "@opentelemetry/contrib-test-utils": "^0.34.1", + "@types/mocha": "8.2.3", + "@types/node": "18.6.5", + "@types/sinon": "10.0.18", + "mocha": "7.2.0", + "nock": "13.3.3", + "nyc": "15.1.0", + "rimraf": "5.0.5", + "ts-mocha": "10.0.0", + "typescript": "4.4.4" + }, + "dependencies": { + "@opentelemetry/resources": "^1.10.1", + "@opentelemetry/semantic-conventions": "^1.0.0" + }, + "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/detectors/node/opentelemetry-resource-detector-azure#readme" +} diff --git a/detectors/node/opentelemetry-resource-detector-azure/src/detectors/AzureAppServiceDetector.ts b/detectors/node/opentelemetry-resource-detector-azure/src/detectors/AzureAppServiceDetector.ts new file mode 100644 index 0000000000..8fe785fa82 --- /dev/null +++ b/detectors/node/opentelemetry-resource-detector-azure/src/detectors/AzureAppServiceDetector.ts @@ -0,0 +1,104 @@ +/* + * 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 { DetectorSync, IResource, Resource } from '@opentelemetry/resources'; +import { + AZURE_APP_SERVICE_STAMP_RESOURCE_ATTRIBUTE, + REGION_NAME, + WEBSITE_HOME_STAMPNAME, + WEBSITE_HOSTNAME, + WEBSITE_INSTANCE_ID, + WEBSITE_OWNER_NAME, + WEBSITE_RESOURCE_GROUP, + WEBSITE_SITE_NAME, + WEBSITE_SLOT_NAME, + CLOUD_RESOURCE_ID_RESOURCE_ATTRIBUTE, +} from '../types'; +import { + CloudProviderValues, + CloudPlatformValues, + SemanticResourceAttributes, +} from '@opentelemetry/semantic-conventions'; + +const APP_SERVICE_ATTRIBUTE_ENV_VARS = { + [SemanticResourceAttributes.CLOUD_REGION]: REGION_NAME, + [SemanticResourceAttributes.DEPLOYMENT_ENVIRONMENT]: WEBSITE_SLOT_NAME, + [SemanticResourceAttributes.HOST_ID]: WEBSITE_HOSTNAME, + [SemanticResourceAttributes.SERVICE_INSTANCE_ID]: WEBSITE_INSTANCE_ID, + [AZURE_APP_SERVICE_STAMP_RESOURCE_ATTRIBUTE]: WEBSITE_HOME_STAMPNAME, +}; + +/** + * The AzureAppServiceDetector can be used to detect if a process is running in an Azure App Service + * @returns a {@link Resource} populated with data about the environment or an empty Resource if detection fails. + */ +class AzureAppServiceDetector implements DetectorSync { + detect(): IResource { + let attributes = {}; + const websiteSiteName = process.env[WEBSITE_SITE_NAME]; + if (websiteSiteName) { + attributes = { + ...attributes, + [SemanticResourceAttributes.SERVICE_NAME]: websiteSiteName, + }; + attributes = { + ...attributes, + [SemanticResourceAttributes.CLOUD_PROVIDER]: CloudProviderValues.AZURE, + }; + attributes = { + ...attributes, + [SemanticResourceAttributes.CLOUD_PLATFORM]: + CloudPlatformValues.AZURE_APP_SERVICE, + }; + + const azureResourceUri = this.getAzureResourceUri(websiteSiteName); + if (azureResourceUri) { + attributes = { + ...attributes, + ...{ [CLOUD_RESOURCE_ID_RESOURCE_ATTRIBUTE]: azureResourceUri }, + }; + } + + for (const [key, value] of Object.entries( + APP_SERVICE_ATTRIBUTE_ENV_VARS + )) { + const envVar = process.env[value]; + if (envVar) { + attributes = { ...attributes, ...{ [key]: envVar } }; + } + } + } + return new Resource(attributes); + } + + private getAzureResourceUri(websiteSiteName: string): string | undefined { + const websiteResourceGroup = process.env[WEBSITE_RESOURCE_GROUP]; + const websiteOwnerName = process.env[WEBSITE_OWNER_NAME]; + + let subscriptionId = websiteOwnerName; + if (websiteOwnerName && websiteOwnerName.indexOf('+') !== -1) { + subscriptionId = websiteOwnerName.split('+')[0]; + } + + if (!subscriptionId && !websiteOwnerName) { + return undefined; + } + + return `/subscriptions/${subscriptionId}/resourceGroups/${websiteResourceGroup}/providers/Microsoft.Web/sites/${websiteSiteName}`; + } +} + +export const azureAppServiceDetector = new AzureAppServiceDetector(); diff --git a/detectors/node/opentelemetry-resource-detector-azure/src/detectors/AzureFunctionsDetector.ts b/detectors/node/opentelemetry-resource-detector-azure/src/detectors/AzureFunctionsDetector.ts new file mode 100644 index 0000000000..8cd601edb3 --- /dev/null +++ b/detectors/node/opentelemetry-resource-detector-azure/src/detectors/AzureFunctionsDetector.ts @@ -0,0 +1,97 @@ +/* + * 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 { DetectorSync, IResource, Resource } from '@opentelemetry/resources'; + +import { + CloudProviderValues, + CloudPlatformValues, + SemanticResourceAttributes, +} from '@opentelemetry/semantic-conventions'; +import { + WEBSITE_SITE_NAME, + FUNCTIONS_VERSION, + WEBSITE_INSTANCE_ID, + FUNCTIONS_MEM_LIMIT, + REGION_NAME, +} from '../types'; + +const AZURE_FUNCTIONS_ATTRIBUTE_ENV_VARS = { + [SemanticResourceAttributes.FAAS_NAME]: WEBSITE_SITE_NAME, + [SemanticResourceAttributes.FAAS_VERSION]: FUNCTIONS_VERSION, + [SemanticResourceAttributes.FAAS_INSTANCE]: WEBSITE_INSTANCE_ID, + [SemanticResourceAttributes.FAAS_MAX_MEMORY]: FUNCTIONS_MEM_LIMIT, +}; + +/** + * The AzureFunctionsDetector can be used to detect if a process is running in Azure Functions + * @returns a {@link Resource} populated with data about the environment or an empty Resource if detection fails. + */ +class AzureFunctionsDetector implements DetectorSync { + detect(): IResource { + let attributes = {}; + const functionName = process.env[WEBSITE_SITE_NAME]; + if (functionName) { + const functionVersion = process.env[FUNCTIONS_VERSION]; + const functionInstance = process.env[WEBSITE_INSTANCE_ID]; + const functionMemLimit = process.env[FUNCTIONS_MEM_LIMIT]; + + attributes = { + [SemanticResourceAttributes.CLOUD_PROVIDER]: CloudProviderValues.AZURE, + [SemanticResourceAttributes.CLOUD_PLATFORM]: + CloudPlatformValues.AZURE_FUNCTIONS, + [SemanticResourceAttributes.CLOUD_REGION]: process.env[REGION_NAME], + }; + + if (functionName) { + attributes = { + ...attributes, + [SemanticResourceAttributes.FAAS_NAME]: functionName, + }; + } + if (functionVersion) { + attributes = { + ...attributes, + [SemanticResourceAttributes.FAAS_VERSION]: functionVersion, + }; + } + if (functionInstance) { + attributes = { + ...attributes, + [SemanticResourceAttributes.FAAS_INSTANCE]: functionInstance, + }; + } + if (functionMemLimit) { + attributes = { + ...attributes, + [SemanticResourceAttributes.FAAS_MAX_MEMORY]: functionMemLimit, + }; + } + + for (const [key, value] of Object.entries( + AZURE_FUNCTIONS_ATTRIBUTE_ENV_VARS + )) { + const envVar = process.env[value]; + if (envVar) { + attributes = { ...attributes, ...{ [key]: envVar } }; + } + } + } + return new Resource(attributes); + } +} + +export const azureFunctionsDetector = new AzureFunctionsDetector(); diff --git a/detectors/node/opentelemetry-resource-detector-azure/src/detectors/AzureVmDetector.ts b/detectors/node/opentelemetry-resource-detector-azure/src/detectors/AzureVmDetector.ts new file mode 100644 index 0000000000..9de9bc330b --- /dev/null +++ b/detectors/node/opentelemetry-resource-detector-azure/src/detectors/AzureVmDetector.ts @@ -0,0 +1,106 @@ +/* + * 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 http from 'http'; +import { + DetectorSync, + IResource, + Resource, + ResourceAttributes, +} from '@opentelemetry/resources'; +import { + CloudPlatformValues, + CloudProviderValues, + SemanticResourceAttributes, +} from '@opentelemetry/semantic-conventions'; +import { + CLOUD_RESOURCE_ID_RESOURCE_ATTRIBUTE, + AZURE_VM_METADATA_HOST, + AZURE_VM_METADATA_PATH, + AZURE_VM_SCALE_SET_NAME_ATTRIBUTE, + AZURE_VM_SKU_ATTRIBUTE, + AzureVmMetadata, +} from '../types'; + +/** + * The AzureVmDetector can be used to detect if a process is running in an Azure VM. + * @returns a {@link Resource} populated with data about the environment or an empty Resource if detection fails. + */ +class AzureVmResourceDetector implements DetectorSync { + detect(): IResource { + return new Resource({}, this.getAzureVmMetadata()); + } + + async getAzureVmMetadata(): Promise { + const options = { + host: AZURE_VM_METADATA_HOST, + path: AZURE_VM_METADATA_PATH, + method: 'GET', + timeout: 5000, + headers: { + Metadata: 'True', + }, + }; + const metadata: AzureVmMetadata = await new Promise((resolve, reject) => { + const timeoutId = setTimeout(() => { + req.destroy(); + reject(new Error('Azure metadata service request timed out.')); + }, 1000); + + const req = http.request(options, res => { + clearTimeout(timeoutId); + const { statusCode } = res; + res.setEncoding('utf8'); + let rawData = ''; + res.on('data', chunk => (rawData += chunk)); + res.on('end', () => { + if (statusCode && statusCode >= 200 && statusCode < 300) { + try { + resolve(JSON.parse(rawData)); + } catch (error) { + reject(error); + } + } else { + reject( + new Error('Failed to load page, status code: ' + statusCode) + ); + } + }); + }); + req.on('error', err => { + clearTimeout(timeoutId); + reject(err); + }); + req.end(); + }); + + const attributes = { + [AZURE_VM_SCALE_SET_NAME_ATTRIBUTE]: metadata['vmScaleSetName'], + [AZURE_VM_SKU_ATTRIBUTE]: metadata['sku'], + [SemanticResourceAttributes.CLOUD_PLATFORM]: CloudPlatformValues.AZURE_VM, + [SemanticResourceAttributes.CLOUD_PROVIDER]: CloudProviderValues.AZURE, + [SemanticResourceAttributes.CLOUD_REGION]: metadata['location'], + [CLOUD_RESOURCE_ID_RESOURCE_ATTRIBUTE]: metadata['resourceId'], + [SemanticResourceAttributes.HOST_ID]: metadata['vmId'], + [SemanticResourceAttributes.HOST_NAME]: metadata['name'], + [SemanticResourceAttributes.HOST_TYPE]: metadata['vmSize'], + [SemanticResourceAttributes.OS_VERSION]: metadata['version'], + }; + return attributes; + } +} + +export const azureVmDetector = new AzureVmResourceDetector(); diff --git a/detectors/node/opentelemetry-resource-detector-azure/src/detectors/index.ts b/detectors/node/opentelemetry-resource-detector-azure/src/detectors/index.ts new file mode 100644 index 0000000000..be8f84fa2c --- /dev/null +++ b/detectors/node/opentelemetry-resource-detector-azure/src/detectors/index.ts @@ -0,0 +1,17 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export * from './AzureAppServiceDetector'; diff --git a/detectors/node/opentelemetry-resource-detector-azure/src/index.ts b/detectors/node/opentelemetry-resource-detector-azure/src/index.ts new file mode 100644 index 0000000000..0acba8788c --- /dev/null +++ b/detectors/node/opentelemetry-resource-detector-azure/src/index.ts @@ -0,0 +1,17 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export * from './detectors'; diff --git a/detectors/node/opentelemetry-resource-detector-azure/src/types.ts b/detectors/node/opentelemetry-resource-detector-azure/src/types.ts new file mode 100644 index 0000000000..645b4b7073 --- /dev/null +++ b/detectors/node/opentelemetry-resource-detector-azure/src/types.ts @@ -0,0 +1,182 @@ +/* + * 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 const AZURE_APP_SERVICE_STAMP_RESOURCE_ATTRIBUTE = + 'azure.app.service.stamp'; +export const CLOUD_RESOURCE_ID_RESOURCE_ATTRIBUTE = 'cloud.resource_id'; +export const REGION_NAME = 'REGION_NAME'; +export const WEBSITE_HOME_STAMPNAME = 'WEBSITE_HOME_STAMPNAME'; +export const WEBSITE_HOSTNAME = 'WEBSITE_HOSTNAME'; +export const WEBSITE_INSTANCE_ID = 'WEBSITE_INSTANCE_ID'; +export const WEBSITE_OWNER_NAME = 'WEBSITE_OWNER_NAME'; +export const WEBSITE_RESOURCE_GROUP = 'WEBSITE_RESOURCE_GROUP'; +export const WEBSITE_SITE_NAME = 'WEBSITE_SITE_NAME'; +export const WEBSITE_SLOT_NAME = 'WEBSITE_SLOT_NAME'; + +export const FUNCTIONS_VERSION = 'FUNCTIONS_EXTENSION_VERSION'; +export const FUNCTIONS_MEM_LIMIT = 'WEBSITE_MEMORY_LIMIT_MB'; + +export const AZURE_VM_METADATA_HOST = '169.254.169.254'; +export const AZURE_VM_METADATA_PATH = + '/metadata/instance/compute?api-version=2021-12-13&format=json'; +export const AZURE_VM_SCALE_SET_NAME_ATTRIBUTE = 'azure.vm.scaleset.name'; +export const AZURE_VM_SKU_ATTRIBUTE = 'azure.vm.sku'; + +export interface AzureVmMetadata { + azEnvironment?: string; + additionalCapabilities?: { + hibernationEnabled?: string; + }; + hostGroup?: { + id?: string; + }; + host?: { + id?: string; + }; + extendedLocation?: { + type?: string; + name?: string; + }; + evictionPolicy?: string; + isHostCompatibilityLayerVm?: string; + licenseType?: string; + location: string; + name: string; + offer?: string; + osProfile?: { + adminUsername?: string; + computerName?: string; + disablePasswordAuthentication?: string; + }; + osType?: string; + placementGroupId?: string; + plan?: { + name?: string; + product?: string; + publisher?: string; + }; + platformFaultDomain?: string; + platformSubFaultDomain?: string; + platformUpdateDomain?: string; + priority?: string; + provider?: string; + publicKeys?: [ + { + keyData?: string; + path?: string; + }, + { + keyData?: string; + path?: string; + } + ]; + publisher?: string; + resourceGroupName?: string; + resourceId: string; + securityProfile?: { + secureBootEnabled?: string; + virtualTpmEnabled?: string; + encryptionAtHost?: string; + securityType?: string; + }; + sku: string; + storageProfile?: { + dataDisks?: [ + { + bytesPerSecondThrottle?: string; + caching?: string; + createOption?: string; + diskCapacityBytes?: string; + diskSizeGB?: string; + image?: { + uri?: string; + }; + isSharedDisk?: string; + isUltraDisk?: string; + lun?: string; + managedDisk?: { + id?: string; + storageAccountType?: string; + }; + name: string; + opsPerSecondThrottle?: string; + vhd?: { + uri?: string; + }; + writeAcceleratorEnabled?: string; + } + ]; + imageReference?: { + id?: string; + offer?: string; + publisher?: string; + sku?: string; + version?: string; + }; + osDisk?: { + caching?: string; + createOption?: string; + diskSizeGB?: string; + diffDiskSettings?: { + option?: string; + }; + encryptionSettings?: { + enabled?: string; + diskEncryptionKey?: { + sourceVault?: { + id?: string; + }; + secretUrl?: string; + }; + keyEncryptionKey?: { + sourceVault?: { + id?: string; + }; + keyUrl?: string; + }; + }; + image?: { + uri?: string; + }; + managedDisk?: { + id?: string; + storageAccountType?: string; + }; + name?: string; + osType?: string; + vhd?: { + uri?: string; + }; + writeAcceleratorEnabled?: string; + }; + resourceDisk?: { + size?: string; + }; + }; + subscriptionId?: string; + tags?: string; + tagsList?: object[]; + customData?: string; + userData?: string; + version: string; + virtualMachineScaleSet?: { + id?: string; + }; + vmId: string; + vmScaleSetName: string; + vmSize: string; + zone?: string; +} diff --git a/detectors/node/opentelemetry-resource-detector-azure/test/detectors/AzureAppServiceDetector.test.ts b/detectors/node/opentelemetry-resource-detector-azure/test/detectors/AzureAppServiceDetector.test.ts new file mode 100644 index 0000000000..9c74ecf7d4 --- /dev/null +++ b/detectors/node/opentelemetry-resource-detector-azure/test/detectors/AzureAppServiceDetector.test.ts @@ -0,0 +1,151 @@ +/* + * 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 { azureAppServiceDetector } from '../../src/detectors/AzureAppServiceDetector'; +import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions'; + +describe('AzureAppServiceDetector', () => { + let originalEnv: NodeJS.ProcessEnv; + beforeEach(() => { + originalEnv = process.env; + }); + + afterEach(() => { + process.env = originalEnv; + }); + + it('should test on appService', () => { + process.env.WEBSITE_SITE_NAME = 'test-site'; + process.env.REGION_NAME = 'test-region'; + process.env.WEBSITE_SLOT_NAME = 'test-slot'; + process.env.WEBSITE_HOSTNAME = 'test-hostname'; + process.env.WEBSITE_INSTANCE_ID = 'test-instance-id'; + process.env.WEBSITE_HOME_STAMPNAME = 'test-home-stamp'; + process.env.WEBSITE_RESOURCE_GROUP = 'test-resource-group'; + process.env.WEBSITE_OWNER_NAME = 'test-owner-name'; + + const resource = azureAppServiceDetector.detect(); + assert.ok(resource); + const attributes = resource.attributes; + assert.strictEqual( + attributes[SemanticResourceAttributes.SERVICE_NAME], + 'test-site' + ); + assert.strictEqual( + attributes[SemanticResourceAttributes.CLOUD_PROVIDER], + 'azure' + ); + assert.strictEqual( + attributes[SemanticResourceAttributes.CLOUD_PLATFORM], + 'azure_app_service' + ); + assert.strictEqual( + attributes['cloud.resource_id'], + `/subscriptions/${process.env.WEBSITE_OWNER_NAME}/resourceGroups/${process.env.WEBSITE_RESOURCE_GROUP}/providers/Microsoft.Web/sites/${process.env.WEBSITE_SITE_NAME}` + ); + assert.strictEqual( + attributes[SemanticResourceAttributes.CLOUD_REGION], + 'test-region' + ); + assert.strictEqual( + attributes[SemanticResourceAttributes.DEPLOYMENT_ENVIRONMENT], + 'test-slot' + ); + assert.strictEqual( + attributes[SemanticResourceAttributes.HOST_ID], + 'test-hostname' + ); + assert.strictEqual( + attributes[SemanticResourceAttributes.SERVICE_INSTANCE_ID], + 'test-instance-id' + ); + assert.strictEqual( + attributes['azure.app.service.stamp'], + 'test-home-stamp' + ); + }); + + it('should test with no resource group', () => { + process.env.WEBSITE_SITE_NAME = 'test-site'; + process.env.REGION_NAME = 'test-region'; + process.env.WEBSITE_SLOT_NAME = 'test-slot'; + process.env.WEBSITE_HOSTNAME = 'test-hostname'; + process.env.WEBSITE_INSTANCE_ID = 'test-instance-id'; + process.env.WEBSITE_HOME_STAMPNAME = 'test-home-stamp'; + process.env.WEBSITE_OWNER_NAME = 'test-owner-name'; + + const resource = azureAppServiceDetector.detect(); + assert.ok(resource); + const attributes = resource.attributes; + assert.strictEqual( + attributes[SemanticResourceAttributes.CLOUD_REGION], + 'test-region' + ); + assert.strictEqual( + attributes[SemanticResourceAttributes.DEPLOYMENT_ENVIRONMENT], + 'test-slot' + ); + assert.strictEqual( + attributes[SemanticResourceAttributes.HOST_ID], + 'test-hostname' + ); + assert.strictEqual( + attributes[SemanticResourceAttributes.SERVICE_INSTANCE_ID], + 'test-instance-id' + ); + assert.strictEqual( + attributes['azure.app.service.stamp'], + 'test-home-stamp' + ); + }); + + it('should test with no owner name', () => { + process.env.WEBSITE_SITE_NAME = 'test-site'; + process.env.REGION_NAME = 'test-region'; + process.env.WEBSITE_SLOT_NAME = 'test-slot'; + process.env.WEBSITE_HOSTNAME = 'test-hostname'; + process.env.WEBSITE_INSTANCE_ID = 'test-instance-id'; + process.env.WEBSITE_HOME_STAMPNAME = 'test-home-stamp'; + process.env.WEBSITE_RESOURCE_GROUP = 'test-resource-group'; + delete process.env.WEBSITE_OWNER_NAME; + + const resource = azureAppServiceDetector.detect(); + assert.ok(resource); + const attributes = resource.attributes; + assert.strictEqual( + attributes[SemanticResourceAttributes.CLOUD_REGION], + 'test-region' + ); + assert.strictEqual( + attributes[SemanticResourceAttributes.DEPLOYMENT_ENVIRONMENT], + 'test-slot' + ); + assert.strictEqual( + attributes[SemanticResourceAttributes.HOST_ID], + 'test-hostname' + ); + assert.strictEqual( + attributes[SemanticResourceAttributes.SERVICE_INSTANCE_ID], + 'test-instance-id' + ); + assert.strictEqual( + attributes['azure.app.service.stamp'], + 'test-home-stamp' + ); + assert.strictEqual(attributes['cloud.resource_id'], undefined); + }); +}); diff --git a/detectors/node/opentelemetry-resource-detector-azure/test/detectors/AzureFunctionsDetector.test.ts b/detectors/node/opentelemetry-resource-detector-azure/test/detectors/AzureFunctionsDetector.test.ts new file mode 100644 index 0000000000..9e14426090 --- /dev/null +++ b/detectors/node/opentelemetry-resource-detector-azure/test/detectors/AzureFunctionsDetector.test.ts @@ -0,0 +1,70 @@ +/* + * 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 { azureFunctionsDetector } from '../../src/detectors/AzureFunctionsDetector'; +import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions'; + +describe('AzureFunctionsDetector', () => { + let originalEnv: NodeJS.ProcessEnv; + beforeEach(() => { + originalEnv = process.env; + }); + + afterEach(() => { + process.env = originalEnv; + }); + + it('should test functions values', () => { + process.env.WEBSITE_SITE_NAME = 'test-function'; + process.env.REGION_NAME = 'test-region'; + process.env.WEBSITE_INSTANCE_ID = 'test-instance-id'; + process.env.FUNCTIONS_EXTENSION_VERSION = '~4'; + process.env.WEBSITE_MEMORY_LIMIT_MB = '1000'; + + const resource = azureFunctionsDetector.detect(); + assert.ok(resource); + const attributes = resource.attributes; + assert.strictEqual( + attributes[SemanticResourceAttributes.FAAS_NAME], + 'test-function' + ); + assert.strictEqual( + attributes[SemanticResourceAttributes.CLOUD_PROVIDER], + 'azure' + ); + assert.strictEqual( + attributes[SemanticResourceAttributes.CLOUD_PLATFORM], + 'azure_functions' + ); + assert.strictEqual( + attributes[SemanticResourceAttributes.CLOUD_REGION], + 'test-region' + ); + assert.strictEqual( + attributes[SemanticResourceAttributes.FAAS_INSTANCE], + 'test-instance-id' + ); + assert.strictEqual( + attributes[SemanticResourceAttributes.FAAS_MAX_MEMORY], + '1000' + ); + assert.strictEqual( + attributes[SemanticResourceAttributes.FAAS_VERSION], + '~4' + ); + }); +}); diff --git a/detectors/node/opentelemetry-resource-detector-azure/test/detectors/AzureVmDetector.test.ts b/detectors/node/opentelemetry-resource-detector-azure/test/detectors/AzureVmDetector.test.ts new file mode 100644 index 0000000000..a795adb27f --- /dev/null +++ b/detectors/node/opentelemetry-resource-detector-azure/test/detectors/AzureVmDetector.test.ts @@ -0,0 +1,418 @@ +/* + * 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 * as nock from 'nock'; +import { azureVmDetector } from '../../src/detectors/AzureVmDetector'; +import { IResource } from '@opentelemetry/resources'; +import { AzureVmMetadata } from '../../src/types'; + +const linuxTestResponse: AzureVmMetadata = { + additionalCapabilities: { + hibernationEnabled: 'false', + }, + azEnvironment: 'AzurePublicCloud', + customData: '', + evictionPolicy: '', + extendedLocation: { + name: '', + type: '', + }, + host: { + id: '', + }, + hostGroup: { + id: '', + }, + isHostCompatibilityLayerVm: 'true', + licenseType: '', + location: 'westus', + name: 'examplevmname', + offer: '0001-com-ubuntu-server-focal', + osProfile: { + adminUsername: 'azureuser', + computerName: 'examplevmname', + disablePasswordAuthentication: 'true', + }, + osType: 'Linux', + placementGroupId: '', + plan: { + name: '', + product: '', + publisher: '', + }, + platformFaultDomain: '0', + platformSubFaultDomain: '', + platformUpdateDomain: '0', + priority: '', + provider: 'Microsoft.Compute', + publicKeys: [ + { + keyData: 'ssh-rsa 0', + path: '/home/user/.ssh/authorized_keys0', + }, + { + keyData: 'ssh-rsa 1', + path: '/home/user/.ssh/authorized_keys1', + }, + ], + publisher: 'canonical', + resourceGroupName: 'macikgo-test-may-23', + resourceId: + '/subscriptions/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/resourceGroups/macikgo-test-may-23/providers/Microsoft.Compute/virtualMachines/examplevmname', + securityProfile: { + encryptionAtHost: 'false', + secureBootEnabled: 'true', + securityType: 'TrustedLaunch', + virtualTpmEnabled: 'true', + }, + sku: '20_04-lts-gen2', + storageProfile: { + dataDisks: [ + { + bytesPerSecondThrottle: '979202048', + caching: 'None', + createOption: 'Empty', + diskCapacityBytes: '274877906944', + diskSizeGB: '1024', + image: { + uri: '', + }, + isSharedDisk: 'false', + isUltraDisk: 'true', + lun: '0', + managedDisk: { + id: '/subscriptions/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/resourceGroups/macikgo-test-may-23/providers/Microsoft.Compute/disks/exampledatadiskname', + storageAccountType: 'StandardSSD_LRS', + }, + name: 'exampledatadiskname', + opsPerSecondThrottle: '65280', + vhd: { + uri: '', + }, + writeAcceleratorEnabled: 'false', + }, + ], + imageReference: { + id: '', + offer: '0001-com-ubuntu-server-focal', + publisher: 'canonical', + sku: '20_04-lts-gen2', + version: 'latest', + }, + osDisk: { + caching: 'ReadWrite', + createOption: 'FromImage', + diffDiskSettings: { + option: '', + }, + diskSizeGB: '30', + encryptionSettings: { + enabled: 'false', + diskEncryptionKey: { + sourceVault: { + id: '/subscriptions/test-source-guid/resourceGroups/testrg/providers/Microsoft.KeyVault/vaults/test-kv', + }, + secretUrl: + 'https://test-disk.vault.azure.net/secrets/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx', + }, + keyEncryptionKey: { + sourceVault: { + id: '/subscriptions/test-key-guid/resourceGroups/testrg/providers/Microsoft.KeyVault/vaults/test-kv', + }, + keyUrl: + 'https://test-key.vault.azure.net/secrets/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx', + }, + }, + image: { + uri: '', + }, + managedDisk: { + id: '/subscriptions/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/resourceGroups/macikgo-test-may-23/providers/Microsoft.Compute/disks/exampleosdiskname', + storageAccountType: 'StandardSSD_LRS', + }, + name: 'exampledatadiskname', + osType: 'Linux', + vhd: { + uri: '', + }, + writeAcceleratorEnabled: 'false', + }, + resourceDisk: { + size: '16384', + }, + }, + subscriptionId: 'xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx', + tags: 'azsecpack:nonprod;platformsettings.host_environment.service.platform_optedin_for_rootcerts:true', + tagsList: [ + { + name: 'azsecpack', + value: 'nonprod', + }, + { + name: 'platformsettings.host_environment.service.platform_optedin_for_rootcerts', + value: 'true', + }, + ], + userData: '', + version: '20.04.202307240', + virtualMachineScaleSet: { + id: '/subscriptions/xxxxxxxx-xxxxx-xxx-xxx-xxxx/resourceGroups/resource-group-name/providers/Microsoft.Compute/virtualMachineScaleSets/virtual-machine-scale-set-name', + }, + vmId: '02aab8a4-74ef-476e-8182-f6d2ba4166a6', + vmScaleSetName: 'crpteste9vflji9', + vmSize: 'Standard_A3', + zone: '1', +}; + +const windowsTestResponse: AzureVmMetadata = { + additionalCapabilities: { + hibernationEnabled: 'false', + }, + azEnvironment: 'AzurePublicCloud', + customData: '', + evictionPolicy: '', + extendedLocation: { + name: '', + type: '', + }, + host: { + id: '', + }, + hostGroup: { + id: '', + }, + isHostCompatibilityLayerVm: 'true', + licenseType: 'Windows_Client', + location: 'westus', + name: 'examplevmname', + offer: 'WindowsServer', + osProfile: { + adminUsername: 'azureuser', + computerName: 'examplevmname', + disablePasswordAuthentication: 'true', + }, + osType: 'Windows', + placementGroupId: '', + plan: { + name: '', + product: '', + publisher: '', + }, + platformFaultDomain: '0', + platformSubFaultDomain: '', + platformUpdateDomain: '0', + priority: '', + provider: 'Microsoft.Compute', + publicKeys: [ + { + keyData: 'ssh-rsa 0', + path: '/home/user/.ssh/authorized_keys0', + }, + { + keyData: 'ssh-rsa 1', + path: '/home/user/.ssh/authorized_keys1', + }, + ], + publisher: 'RDFE-Test-Microsoft-Windows-Server-Group', + resourceGroupName: 'macikgo-test-may-23', + resourceId: + '/subscriptions/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/resourceGroups/macikgo-test-may-23/providers/Microsoft.Compute/virtualMachines/examplevmname', + securityProfile: { + encryptionAtHost: 'false', + secureBootEnabled: 'true', + securityType: 'TrustedLaunch', + virtualTpmEnabled: 'true', + }, + sku: '2019-Datacenter', + storageProfile: { + dataDisks: [ + { + bytesPerSecondThrottle: '979202048', + caching: 'None', + createOption: 'Empty', + diskCapacityBytes: '274877906944', + diskSizeGB: '1024', + image: { + uri: '', + }, + isSharedDisk: 'false', + isUltraDisk: 'true', + lun: '0', + managedDisk: { + id: '/subscriptions/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/resourceGroups/macikgo-test-may-23/providers/Microsoft.Compute/disks/exampledatadiskname', + storageAccountType: 'StandardSSD_LRS', + }, + name: 'exampledatadiskname', + opsPerSecondThrottle: '65280', + vhd: { + uri: '', + }, + writeAcceleratorEnabled: 'false', + }, + ], + imageReference: { + id: '', + offer: 'WindowsServer', + publisher: 'MicrosoftWindowsServer', + sku: '2019-Datacenter', + version: 'latest', + }, + osDisk: { + caching: 'ReadWrite', + createOption: 'FromImage', + diffDiskSettings: { + option: '', + }, + diskSizeGB: '30', + encryptionSettings: { + enabled: 'false', + diskEncryptionKey: { + sourceVault: { + id: '/subscriptions/test-source-guid/resourceGroups/testrg/providers/Microsoft.KeyVault/vaults/test-kv', + }, + secretUrl: + 'https://test-disk.vault.azure.net/secrets/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx', + }, + keyEncryptionKey: { + sourceVault: { + id: '/subscriptions/test-key-guid/resourceGroups/testrg/providers/Microsoft.KeyVault/vaults/test-kv', + }, + keyUrl: + 'https://test-key.vault.azure.net/secrets/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx', + }, + }, + image: { + uri: '', + }, + managedDisk: { + id: '/subscriptions/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/resourceGroups/macikgo-test-may-23/providers/Microsoft.Compute/disks/exampleosdiskname', + storageAccountType: 'StandardSSD_LRS', + }, + name: 'exampledatadiskname', + osType: 'Windows', + vhd: { + uri: '', + }, + writeAcceleratorEnabled: 'false', + }, + resourceDisk: { + size: '16384', + }, + }, + subscriptionId: 'xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx', + tags: 'azsecpack:nonprod;platformsettings.host_environment.service.platform_optedin_for_rootcerts:true', + userData: 'Zm9vYmFy', + tagsList: [ + { + name: 'azsecpack', + value: 'nonprod', + }, + { + name: 'platformsettings.host_environment.service.platform_optedin_for_rootcerts', + value: 'true', + }, + ], + version: '20.04.202307240', + virtualMachineScaleSet: { + id: '/subscriptions/xxxxxxxx-xxxxx-xxx-xxx-xxxx/resourceGroups/resource-group-name/providers/Microsoft.Compute/virtualMachineScaleSets/virtual-machine-scale-set-name', + }, + vmId: '02aab8a4-74ef-476e-8182-f6d2ba4166a6', + vmScaleSetName: 'crpteste9vflji9', + vmSize: 'Standard_A3', + zone: '1', +}; + +const linuxAttributes: any = { + 'azure.vm.scaleset.name': 'crpteste9vflji9', + 'azure.vm.sku': '20_04-lts-gen2', + 'cloud.platform': 'azure_vm', + 'cloud.provider': 'azure', + 'cloud.region': 'westus', + 'cloud.resource_id': + '/subscriptions/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/resourceGroups/macikgo-test-may-23/providers/Microsoft.Compute/virtualMachines/examplevmname', + 'host.id': '02aab8a4-74ef-476e-8182-f6d2ba4166a6', + 'host.name': 'examplevmname', + 'host.type': 'Standard_A3', + 'os.type': 'Linux', + 'os.version': '20.04.202307240', + 'service.instance.id': '02aab8a4-74ef-476e-8182-f6d2ba4166a6', +}; + +const windowsAttributes: any = { + 'azure.vm.scaleset.name': 'crpteste9vflji9', + 'azure.vm.sku': '2019-Datacenter', + 'cloud.platform': 'azure_vm', + 'cloud.provider': 'azure', + 'cloud.region': 'westus', + 'cloud.resource_id': + '/subscriptions/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/resourceGroups/macikgo-test-may-23/providers/Microsoft.Compute/virtualMachines/examplevmname', + 'host.id': '02aab8a4-74ef-476e-8182-f6d2ba4166a6', + 'host.name': 'examplevmname', + 'host.type': 'Standard_A3', + 'os.type': 'Windows', + 'os.version': '20.04.202307240', + 'service.instance.id': '02aab8a4-74ef-476e-8182-f6d2ba4166a6', +}; + +const AZURE_VM_METADATA_HOST = 'http://169.254.169.254'; +const AZURE_VM_METADATA_PATH = + '/metadata/instance/compute?api-version=2021-12-13&format=json'; + +describe('AzureAppServiceDetector', () => { + beforeEach(() => { + nock.disableNetConnect(); + nock.cleanAll(); + }); + + afterEach(() => { + nock.enableNetConnect(); + }); + + it('should get linux virtual machine attributes', async () => { + const scope = nock(AZURE_VM_METADATA_HOST) + .get(AZURE_VM_METADATA_PATH) + .reply(200, linuxTestResponse); + + const resource: IResource = azureVmDetector.detect(); + if (resource.waitForAsyncAttributes) { + await resource.waitForAsyncAttributes(); + } + const attributes = resource.attributes; + for (let i = 0; i < Object.keys(attributes).length; i++) { + const key = Object.keys(attributes)[i]; + assert.strictEqual(attributes[key], linuxAttributes[key]); + } + scope.done(); + }); + + it('should get windows virtual machine attributes', async () => { + const scope = nock(AZURE_VM_METADATA_HOST) + .get(AZURE_VM_METADATA_PATH) + .reply(200, windowsTestResponse); + + const resource: IResource = azureVmDetector.detect(); + if (resource.waitForAsyncAttributes) { + await resource.waitForAsyncAttributes(); + } + const attributes = resource.attributes; + for (let i = 0; i < Object.keys(attributes).length; i++) { + const key = Object.keys(attributes)[i]; + assert.strictEqual(attributes[key], windowsAttributes[key]); + } + scope.done(); + }); +}); diff --git a/detectors/node/opentelemetry-resource-detector-azure/tsconfig.json b/detectors/node/opentelemetry-resource-detector-azure/tsconfig.json new file mode 100644 index 0000000000..3f6ea3378e --- /dev/null +++ b/detectors/node/opentelemetry-resource-detector-azure/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../../../tsconfig.base", + "compilerOptions": { + "rootDir": ".", + "outDir": "build" + }, + "include": [ + "src/**/*.ts", + "test/**/*.ts" + ] +} diff --git a/detectors/node/opentelemetry-resource-detector-gcp/package.json b/detectors/node/opentelemetry-resource-detector-gcp/package.json index e4b529b531..edcc8bdf01 100644 --- a/detectors/node/opentelemetry-resource-detector-gcp/package.json +++ b/detectors/node/opentelemetry-resource-detector-gcp/package.json @@ -60,7 +60,7 @@ "@opentelemetry/core": "^1.0.0", "@opentelemetry/resources": "^1.0.0", "@opentelemetry/semantic-conventions": "^1.0.0", - "gcp-metadata": "^5.0.0" + "gcp-metadata": "^6.0.0" }, "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/detectors/node/opentelemetry-resource-detector-gcp#readme" } diff --git a/detectors/node/opentelemetry-resource-detector-instana/package.json b/detectors/node/opentelemetry-resource-detector-instana/package.json index 1e9e571ccc..ac5add56b6 100644 --- a/detectors/node/opentelemetry-resource-detector-instana/package.json +++ b/detectors/node/opentelemetry-resource-detector-instana/package.json @@ -41,7 +41,7 @@ "devDependencies": { "@opentelemetry/api": "^1.3.0", "@opentelemetry/contrib-test-utils": "^0.34.2", - "@opentelemetry/sdk-node": "^0.44.0", + "@opentelemetry/sdk-node": "^0.45.0", "@types/mocha": "8.2.3", "@types/node": "18.6.5", "@types/semver": "7.5.3", diff --git a/metapackages/auto-instrumentations-node/CHANGELOG.md b/metapackages/auto-instrumentations-node/CHANGELOG.md index 7208997324..5bcc883c1e 100644 --- a/metapackages/auto-instrumentations-node/CHANGELOG.md +++ b/metapackages/auto-instrumentations-node/CHANGELOG.md @@ -101,6 +101,12 @@ * @opentelemetry/instrumentation-fastify bumped from ^0.32.1 to ^0.32.2 * @opentelemetry/instrumentation-mongodb bumped from ^0.36.1 to ^0.37.0 +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * @opentelemetry/instrumentation-redis-4 bumped from ^0.35.2 to ^0.35.3 + ## [0.39.3](https://github.com/open-telemetry/opentelemetry-js-contrib/compare/auto-instrumentations-node-v0.39.2...auto-instrumentations-node-v0.39.3) (2023-10-10) diff --git a/metapackages/auto-instrumentations-node/package.json b/metapackages/auto-instrumentations-node/package.json index 8776846109..992f282e26 100644 --- a/metapackages/auto-instrumentations-node/package.json +++ b/metapackages/auto-instrumentations-node/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/auto-instrumentations-node", - "version": "0.39.3", + "version": "0.39.4", "description": "Metapackage which bundles opentelemetry node core and contrib instrumentations", "author": "OpenTelemetry Authors", "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/metapackages/auto-instrumentations-node#readme", @@ -49,7 +49,7 @@ "typescript": "4.4.4" }, "dependencies": { - "@opentelemetry/instrumentation": "^0.44.0", + "@opentelemetry/instrumentation": "^0.45.0", "@opentelemetry/instrumentation-amqplib": "^0.33.2", "@opentelemetry/instrumentation-aws-lambda": "^0.37.1", "@opentelemetry/instrumentation-aws-sdk": "^0.36.1", @@ -64,9 +64,9 @@ "@opentelemetry/instrumentation-fastify": "^0.32.3", "@opentelemetry/instrumentation-generic-pool": "^0.32.3", "@opentelemetry/instrumentation-graphql": "^0.35.2", - "@opentelemetry/instrumentation-grpc": "^0.44.0", + "@opentelemetry/instrumentation-grpc": "^0.45.0", "@opentelemetry/instrumentation-hapi": "^0.33.1", - "@opentelemetry/instrumentation-http": "^0.44.0", + "@opentelemetry/instrumentation-http": "^0.45.0", "@opentelemetry/instrumentation-ioredis": "^0.35.2", "@opentelemetry/instrumentation-knex": "^0.32.2", "@opentelemetry/instrumentation-koa": "^0.36.1", @@ -81,7 +81,7 @@ "@opentelemetry/instrumentation-pg": "^0.36.2", "@opentelemetry/instrumentation-pino": "^0.34.2", "@opentelemetry/instrumentation-redis": "^0.35.2", - "@opentelemetry/instrumentation-redis-4": "^0.35.2", + "@opentelemetry/instrumentation-redis-4": "^0.35.3", "@opentelemetry/instrumentation-restify": "^0.34.1", "@opentelemetry/instrumentation-router": "^0.33.2", "@opentelemetry/instrumentation-socket.io": "^0.34.2", @@ -92,6 +92,6 @@ "@opentelemetry/resource-detector-container": "^0.3.2", "@opentelemetry/resource-detector-gcp": "^0.29.2", "@opentelemetry/resources": "^1.12.0", - "@opentelemetry/sdk-node": "^0.44.0" + "@opentelemetry/sdk-node": "^0.45.0" } } diff --git a/metapackages/auto-instrumentations-node/src/index.ts b/metapackages/auto-instrumentations-node/src/index.ts index 3c0c688a05..6224f95413 100644 --- a/metapackages/auto-instrumentations-node/src/index.ts +++ b/metapackages/auto-instrumentations-node/src/index.ts @@ -14,4 +14,8 @@ * limitations under the License. */ -export { getNodeAutoInstrumentations, InstrumentationConfigMap } from './utils'; +export { + getNodeAutoInstrumentations, + getResourceDetectorsFromEnv, + InstrumentationConfigMap, +} from './utils'; diff --git a/metapackages/auto-instrumentations-web/package.json b/metapackages/auto-instrumentations-web/package.json index d951c334eb..852bb0711a 100644 --- a/metapackages/auto-instrumentations-web/package.json +++ b/metapackages/auto-instrumentations-web/package.json @@ -59,10 +59,10 @@ "webpack-merge": "5.8.0" }, "dependencies": { - "@opentelemetry/instrumentation": "^0.44.0", + "@opentelemetry/instrumentation": "^0.45.0", "@opentelemetry/instrumentation-document-load": "^0.33.2", - "@opentelemetry/instrumentation-fetch": "^0.44.0", + "@opentelemetry/instrumentation-fetch": "^0.45.0", "@opentelemetry/instrumentation-user-interaction": "^0.33.2", - "@opentelemetry/instrumentation-xml-http-request": "^0.44.0" + "@opentelemetry/instrumentation-xml-http-request": "^0.45.0" } } diff --git a/packages/opentelemetry-host-metrics/src/enum.ts b/packages/opentelemetry-host-metrics/src/enum.ts index a4ed9a637b..c23bc57587 100644 --- a/packages/opentelemetry-host-metrics/src/enum.ts +++ b/packages/opentelemetry-host-metrics/src/enum.ts @@ -27,6 +27,11 @@ export enum METRIC_NAMES { PROCESS_MEMORY_USAGE = 'process.memory.usage', } +export enum METRIC_ATTRIBUTES { + SYSTEM_CPU_LOGICAL_NUMBER = 'system.cpu.logical_number', + SYSTEM_CPU_STATE = 'system.cpu.state', +} + export enum CPU_LABELS { USER = 'user', SYSTEM = 'system', diff --git a/packages/opentelemetry-host-metrics/src/metric.ts b/packages/opentelemetry-host-metrics/src/metric.ts index e89b69887b..022ba8d051 100644 --- a/packages/opentelemetry-host-metrics/src/metric.ts +++ b/packages/opentelemetry-host-metrics/src/metric.ts @@ -40,48 +40,51 @@ export class HostMetrics extends BaseMetrics { observableResult: api.BatchObservableResult, cpuUsages: CpuUsageData[] ): void { + const stateAttr = enums.METRIC_ATTRIBUTES.SYSTEM_CPU_STATE; + const cpuAttr = enums.METRIC_ATTRIBUTES.SYSTEM_CPU_LOGICAL_NUMBER; + for (let i = 0, j = cpuUsages.length; i < j; i++) { const cpuUsage = cpuUsages[i]; observableResult.observe(this._cpuTime, cpuUsage.user, { - state: enums.CPU_LABELS.USER, - cpu: cpuUsage.cpuNumber, + [stateAttr]: enums.CPU_LABELS.USER, + [cpuAttr]: cpuUsage.cpuNumber, }); observableResult.observe(this._cpuTime, cpuUsage.system, { - state: enums.CPU_LABELS.SYSTEM, - cpu: cpuUsage.cpuNumber, + [stateAttr]: enums.CPU_LABELS.SYSTEM, + [cpuAttr]: cpuUsage.cpuNumber, }); observableResult.observe(this._cpuTime, cpuUsage.idle, { - state: enums.CPU_LABELS.IDLE, - cpu: cpuUsage.cpuNumber, + [stateAttr]: enums.CPU_LABELS.IDLE, + [cpuAttr]: cpuUsage.cpuNumber, }); observableResult.observe(this._cpuTime, cpuUsage.interrupt, { - state: enums.CPU_LABELS.INTERRUPT, - cpu: cpuUsage.cpuNumber, + [stateAttr]: enums.CPU_LABELS.INTERRUPT, + [cpuAttr]: cpuUsage.cpuNumber, }); observableResult.observe(this._cpuTime, cpuUsage.nice, { - state: enums.CPU_LABELS.NICE, - cpu: cpuUsage.cpuNumber, + [stateAttr]: enums.CPU_LABELS.NICE, + [cpuAttr]: cpuUsage.cpuNumber, }); observableResult.observe(this._cpuUtilization, cpuUsage.userP, { - state: enums.CPU_LABELS.USER, - cpu: cpuUsage.cpuNumber, + [stateAttr]: enums.CPU_LABELS.USER, + [cpuAttr]: cpuUsage.cpuNumber, }); observableResult.observe(this._cpuUtilization, cpuUsage.systemP, { - state: enums.CPU_LABELS.SYSTEM, - cpu: cpuUsage.cpuNumber, + [stateAttr]: enums.CPU_LABELS.SYSTEM, + [cpuAttr]: cpuUsage.cpuNumber, }); observableResult.observe(this._cpuUtilization, cpuUsage.idleP, { - state: enums.CPU_LABELS.IDLE, - cpu: cpuUsage.cpuNumber, + [stateAttr]: enums.CPU_LABELS.IDLE, + [cpuAttr]: cpuUsage.cpuNumber, }); observableResult.observe(this._cpuUtilization, cpuUsage.interruptP, { - state: enums.CPU_LABELS.INTERRUPT, - cpu: cpuUsage.cpuNumber, + [stateAttr]: enums.CPU_LABELS.INTERRUPT, + [cpuAttr]: cpuUsage.cpuNumber, }); observableResult.observe(this._cpuUtilization, cpuUsage.niceP, { - state: enums.CPU_LABELS.NICE, - cpu: cpuUsage.cpuNumber, + [stateAttr]: enums.CPU_LABELS.NICE, + [cpuAttr]: cpuUsage.cpuNumber, }); } } diff --git a/packages/opentelemetry-host-metrics/src/stats/common.ts b/packages/opentelemetry-host-metrics/src/stats/common.ts index b74522ae0d..520dc2cd2b 100644 --- a/packages/opentelemetry-host-metrics/src/stats/common.ts +++ b/packages/opentelemetry-host-metrics/src/stats/common.ts @@ -22,28 +22,39 @@ const MILLISECOND = 1 / 1e3; let cpuUsageTime: number | undefined = undefined; /** - * It returns cpu load delta from last time - to be used with SumObservers. - * When called first time it will return 0 and then delta will be calculated + * We get data as soon as we load the module so the 1st collect + * of the metric already has valuable data to be sent. + */ +let prevOsData: { time: number; cpus: os.CpuInfo[] } = { + time: Date.now(), + cpus: os.cpus(), +}; + +/** + * For each CPU returned by `os.cpus()` it returns + * - the CPU times in each state (user, sys, ...) in seconds + * - the % of time the CPU was in each state since last measurement */ export function getCpuUsageData(): CpuUsageData[] { - if (typeof cpuUsageTime !== 'number') { - cpuUsageTime = new Date().getTime() - process.uptime() * 1000; - } + const currentTime = Date.now(); + const timeElapsed = currentTime - prevOsData.time; + const currentOsData = { time: currentTime, cpus: os.cpus() }; - const timeElapsed = (new Date().getTime() - cpuUsageTime) / 1000; + const usageData = currentOsData.cpus.map((cpu, cpuNumber) => { + const prevTimes = prevOsData.cpus[cpuNumber].times; + const currTimes = cpu.times; - return os.cpus().map((cpu, cpuNumber) => { - const idle = cpu.times.idle * MILLISECOND; - const user = cpu.times.user * MILLISECOND; - const system = cpu.times.sys * MILLISECOND; - const interrupt = cpu.times.irq * MILLISECOND; - const nice = cpu.times.nice * MILLISECOND; + const idle = currTimes.idle * MILLISECOND; + const user = currTimes.user * MILLISECOND; + const system = currTimes.sys * MILLISECOND; + const interrupt = currTimes.irq * MILLISECOND; + const nice = currTimes.nice * MILLISECOND; - const idleP = idle / timeElapsed; - const userP = user / timeElapsed; - const systemP = system / timeElapsed; - const interruptP = interrupt / timeElapsed; - const niceP = nice / timeElapsed; + const idleP = (currTimes.idle - prevTimes.idle) / timeElapsed; + const userP = (currTimes.user - prevTimes.user) / timeElapsed; + const systemP = (currTimes.sys - prevTimes.sys) / timeElapsed; + const interruptP = (currTimes.irq - prevTimes.irq) / timeElapsed; + const niceP = (currTimes.nice - prevTimes.nice) / timeElapsed; return { cpuNumber: String(cpuNumber), @@ -59,6 +70,10 @@ export function getCpuUsageData(): CpuUsageData[] { niceP, }; }); + + prevOsData = currentOsData; + + return usageData; } /** diff --git a/packages/opentelemetry-host-metrics/test/metric.test.ts b/packages/opentelemetry-host-metrics/test/metric.test.ts index 39b4fdb8eb..57251aaba2 100644 --- a/packages/opentelemetry-host-metrics/test/metric.test.ts +++ b/packages/opentelemetry-host-metrics/test/metric.test.ts @@ -27,6 +27,7 @@ import { import * as assert from 'assert'; import * as os from 'os'; import * as sinon from 'sinon'; +import { METRIC_ATTRIBUTES } from '../src/enum'; import { HostMetrics } from '../src'; const cpuJson = require('./mocks/cpu.json'); @@ -68,6 +69,10 @@ const mockedOS = { totalmem: function () { return 1024 * 1024; }, + cpusIdx: 0, + cpus: function () { + return cpuJson[this.cpusIdx++ % 2]; + }, }; const INTERVAL = 3000; @@ -112,7 +117,7 @@ describe('Host Metrics', () => { return mockedOS.freemem(); }); sandbox.stub(os, 'totalmem').returns(mockedOS.totalmem()); - sandbox.stub(os, 'cpus').returns(cpuJson); + sandbox.stub(os, 'cpus').callsFake(() => mockedOS.cpus()); sandbox.stub(process, 'uptime').returns(0); sandbox.stub(SI, 'networkStats').callsFake(() => { return mockedSI.networkStats(); @@ -146,6 +151,9 @@ describe('Host Metrics', () => { await reader.collect(); dateStub.returns(process.uptime() * 1000 + INTERVAL); + // advance the clock for the next collection + sandbox.clock.tick(1000); + // invalidates throttles countSI = 0; }); @@ -153,36 +161,119 @@ describe('Host Metrics', () => { sandbox.restore(); }); + const sysCpuStateAttr = METRIC_ATTRIBUTES.SYSTEM_CPU_STATE; + const sysCpuNumAttr = METRIC_ATTRIBUTES.SYSTEM_CPU_LOGICAL_NUMBER; + it('should export CPU time metrics', async () => { const metric = await getRecords(reader, 'system.cpu.time'); - ensureValue(metric, { state: 'user', cpu: '0' }, 90713.56); - ensureValue(metric, { state: 'system', cpu: '0' }, 63192.630000000005); - ensureValue(metric, { state: 'idle', cpu: '0' }, 374870.7); - ensureValue(metric, { state: 'interrupt', cpu: '0' }, 0); - ensureValue(metric, { state: 'nice', cpu: '0' }, 0); - - ensureValue(metric, { state: 'user', cpu: '1' }, 11005.42); - ensureValue(metric, { state: 'system', cpu: '1' }, 7678.12); - ensureValue(metric, { state: 'idle', cpu: '1' }, 510034.8); - ensureValue(metric, { state: 'interrupt', cpu: '1' }, 0); - ensureValue(metric, { state: 'nice', cpu: '1' }, 0); + ensureValue( + metric, + { [sysCpuStateAttr]: 'user', [sysCpuNumAttr]: '0' }, + 90714.26 + ); + ensureValue( + metric, + { [sysCpuStateAttr]: 'system', [sysCpuNumAttr]: '0' }, + 63192.83 + ); + ensureValue( + metric, + { [sysCpuStateAttr]: 'idle', [sysCpuNumAttr]: '0' }, + 374870.8 + ); + ensureValue( + metric, + { [sysCpuStateAttr]: 'interrupt', [sysCpuNumAttr]: '0' }, + 0 + ); + ensureValue( + metric, + { [sysCpuStateAttr]: 'nice', [sysCpuNumAttr]: '0' }, + 0 + ); + + ensureValue( + metric, + { [sysCpuStateAttr]: 'user', [sysCpuNumAttr]: '1' }, + 11005.72 + ); + ensureValue( + metric, + { [sysCpuStateAttr]: 'system', [sysCpuNumAttr]: '1' }, + 7678.62 + ); + ensureValue( + metric, + { [sysCpuStateAttr]: 'idle', [sysCpuNumAttr]: '1' }, + 510035 + ); + ensureValue( + metric, + { [sysCpuStateAttr]: 'interrupt', [sysCpuNumAttr]: '1' }, + 0 + ); + ensureValue( + metric, + { [sysCpuStateAttr]: 'nice', [sysCpuNumAttr]: '1' }, + 0 + ); }); it('should export CPU utilization metrics', async () => { const metric = await getRecords(reader, 'system.cpu.utilization'); - ensureValue(metric, { state: 'user', cpu: '0' }, 30247.935978659552); - ensureValue(metric, { state: 'system', cpu: '0' }, 21071.23374458153); - ensureValue(metric, { state: 'idle', cpu: '0' }, 124998.56618872957); - ensureValue(metric, { state: 'interrupt', cpu: '0' }, 0); - ensureValue(metric, { state: 'nice', cpu: '0' }, 0); - - ensureValue(metric, { state: 'user', cpu: '1' }, 3669.6965655218405); - ensureValue(metric, { state: 'system', cpu: '1' }, 2560.2267422474156); - ensureValue(metric, { state: 'idle', cpu: '1' }, 170068.28942980993); - ensureValue(metric, { state: 'interrupt', cpu: '1' }, 0); - ensureValue(metric, { state: 'nice', cpu: '1' }, 0); + ensureValue( + metric, + { [sysCpuStateAttr]: 'user', [sysCpuNumAttr]: '0' }, + 0.7 + ); + ensureValue( + metric, + { [sysCpuStateAttr]: 'system', [sysCpuNumAttr]: '0' }, + 0.2 + ); + ensureValue( + metric, + { [sysCpuStateAttr]: 'idle', [sysCpuNumAttr]: '0' }, + 0.1 + ); + ensureValue( + metric, + { [sysCpuStateAttr]: 'interrupt', [sysCpuNumAttr]: '0' }, + 0 + ); + ensureValue( + metric, + { [sysCpuStateAttr]: 'nice', [sysCpuNumAttr]: '0' }, + 0 + ); + + ensureValue( + metric, + { [sysCpuStateAttr]: 'user', [sysCpuNumAttr]: '1' }, + 0.3 + ); + ensureValue( + metric, + { [sysCpuStateAttr]: 'system', [sysCpuNumAttr]: '1' }, + 0.5 + ); + ensureValue( + metric, + { [sysCpuStateAttr]: 'idle', [sysCpuNumAttr]: '1' }, + 0.2 + ); + ensureValue( + metric, + { [sysCpuStateAttr]: 'interrupt', [sysCpuNumAttr]: '1' }, + 0 + ); + ensureValue( + metric, + { [sysCpuStateAttr]: 'nice', [sysCpuNumAttr]: '1' }, + 0 + ); }); it('should export Memory usage metrics', async () => { diff --git a/packages/opentelemetry-host-metrics/test/mocks/cpu.json b/packages/opentelemetry-host-metrics/test/mocks/cpu.json index d9831b12a1..bb8beec726 100644 --- a/packages/opentelemetry-host-metrics/test/mocks/cpu.json +++ b/packages/opentelemetry-host-metrics/test/mocks/cpu.json @@ -1,22 +1,54 @@ -[{ - "model": "CPU @ 2.60GHz", - "speed": 2600, - "times": { - "user": 90713560, - "nice": 0, - "sys": 63192630, - "idle": 374870700, - "irq": 0 - } -}, { - "model": "CPU @ 2.60GHz", - "speed": 2600, - "times": { - "user": 11005420, - "nice": 0, - "sys": 7678120, - "idle": 510034800, - "irq": 0 - } -} -] +[ + [ + { + "model": "CPU @ 2.60GHz", + "speed": 2600, + "// times": "this is the 1st collect of CPU data which will be used to calc utilization", + "times": { + "user": 90713560, + "nice": 0, + "sys": 63192630, + "idle": 374870700, + "irq": 0 + } + }, + { + "model": "CPU @ 2.60GHz", + "speed": 2600, + "// times": "this is the 1st collect of CPU data which will be used to calc utilization", + "times": { + "user": 11005420, + "nice": 0, + "sys": 7678120, + "idle": 510034800, + "irq": 0 + } + } + ], + [ + { + "model": "CPU @ 2.60GHz", + "speed": 2600, + "// times": "assuming a time delta of 1000ms we distribute 70% to user, 20% to sys and 10% to idle", + "times": { + "user": 90714260, + "nice": 0, + "sys": 63192830, + "idle": 374870800, + "irq": 0 + } + }, + { + "model": "CPU @ 2.60GHz", + "speed": 2600, + "// times": "assuming a time delta of 1000ms we distribute 30% to user, 50% to sys and 20% to idle", + "times": { + "user": 11005720, + "nice": 0, + "sys": 7678620, + "idle": 510035000, + "irq": 0 + } + } + ] +] \ No newline at end of file diff --git a/packages/opentelemetry-test-utils/package.json b/packages/opentelemetry-test-utils/package.json index 5f90d25167..90bc34fa36 100644 --- a/packages/opentelemetry-test-utils/package.json +++ b/packages/opentelemetry-test-utils/package.json @@ -48,7 +48,7 @@ "dependencies": { "@opentelemetry/core": "^1.0.0", "@opentelemetry/exporter-jaeger": "^1.3.1", - "@opentelemetry/instrumentation": "^0.44.0", + "@opentelemetry/instrumentation": "^0.45.0", "@opentelemetry/sdk-trace-node": "^1.8.0", "@opentelemetry/resources": "^1.8.0", "@opentelemetry/sdk-trace-base": "^1.8.0", diff --git a/plugins/node/instrumentation-amqplib/package.json b/plugins/node/instrumentation-amqplib/package.json index 5c603dcec5..6c0988134a 100644 --- a/plugins/node/instrumentation-amqplib/package.json +++ b/plugins/node/instrumentation-amqplib/package.json @@ -47,7 +47,7 @@ }, "dependencies": { "@opentelemetry/core": "^1.8.0", - "@opentelemetry/instrumentation": "^0.44.0", + "@opentelemetry/instrumentation": "^0.45.0", "@opentelemetry/semantic-conventions": "^1.0.0" }, "devDependencies": { diff --git a/plugins/node/instrumentation-cucumber/package.json b/plugins/node/instrumentation-cucumber/package.json index 75428285f1..959164580b 100644 --- a/plugins/node/instrumentation-cucumber/package.json +++ b/plugins/node/instrumentation-cucumber/package.json @@ -65,7 +65,7 @@ "typescript": "4.4.4" }, "dependencies": { - "@opentelemetry/instrumentation": "^0.44.0", + "@opentelemetry/instrumentation": "^0.45.0", "@opentelemetry/semantic-conventions": "^1.0.0" }, "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/instrumentation-cucumber#readme" diff --git a/plugins/node/instrumentation-dataloader/package.json b/plugins/node/instrumentation-dataloader/package.json index 96e4978993..21149df54d 100644 --- a/plugins/node/instrumentation-dataloader/package.json +++ b/plugins/node/instrumentation-dataloader/package.json @@ -61,7 +61,7 @@ "typescript": "4.4.4" }, "dependencies": { - "@opentelemetry/instrumentation": "^0.44.0" + "@opentelemetry/instrumentation": "^0.45.0" }, "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/instrumentation-dataloader#readme" } diff --git a/plugins/node/instrumentation-fs/package.json b/plugins/node/instrumentation-fs/package.json index 707283d857..fd2bd87c08 100644 --- a/plugins/node/instrumentation-fs/package.json +++ b/plugins/node/instrumentation-fs/package.json @@ -59,7 +59,7 @@ }, "dependencies": { "@opentelemetry/core": "^1.8.0", - "@opentelemetry/instrumentation": "^0.44.0", + "@opentelemetry/instrumentation": "^0.45.0", "@opentelemetry/semantic-conventions": "^1.0.0" }, "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/instrumentation-fs#readme" diff --git a/plugins/node/instrumentation-lru-memoizer/package.json b/plugins/node/instrumentation-lru-memoizer/package.json index 8a3aca6765..a9b129e8ce 100644 --- a/plugins/node/instrumentation-lru-memoizer/package.json +++ b/plugins/node/instrumentation-lru-memoizer/package.json @@ -57,7 +57,7 @@ "typescript": "4.4.4" }, "dependencies": { - "@opentelemetry/instrumentation": "^0.44.0" + "@opentelemetry/instrumentation": "^0.45.0" }, "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/instrumentation-lru-memoizer#readme" } diff --git a/plugins/node/instrumentation-mongoose/package.json b/plugins/node/instrumentation-mongoose/package.json index ada722c74e..db1235d446 100644 --- a/plugins/node/instrumentation-mongoose/package.json +++ b/plugins/node/instrumentation-mongoose/package.json @@ -61,7 +61,7 @@ }, "dependencies": { "@opentelemetry/core": "^1.8.0", - "@opentelemetry/instrumentation": "^0.44.0", + "@opentelemetry/instrumentation": "^0.45.0", "@opentelemetry/semantic-conventions": "^1.0.0" }, "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/instrumentation-mongoose#readme" diff --git a/plugins/node/instrumentation-socket.io/package.json b/plugins/node/instrumentation-socket.io/package.json index 352fba531b..b229fb9136 100644 --- a/plugins/node/instrumentation-socket.io/package.json +++ b/plugins/node/instrumentation-socket.io/package.json @@ -58,7 +58,7 @@ "typescript": "4.4.4" }, "dependencies": { - "@opentelemetry/instrumentation": "^0.44.0", + "@opentelemetry/instrumentation": "^0.45.0", "@opentelemetry/semantic-conventions": "^1.0.0" }, "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/instrumentation-socket.io#readme" diff --git a/plugins/node/instrumentation-tedious/package.json b/plugins/node/instrumentation-tedious/package.json index 06d0ac09bf..dfbf22059d 100644 --- a/plugins/node/instrumentation-tedious/package.json +++ b/plugins/node/instrumentation-tedious/package.json @@ -62,7 +62,7 @@ "typescript": "4.4.4" }, "dependencies": { - "@opentelemetry/instrumentation": "^0.44.0", + "@opentelemetry/instrumentation": "^0.45.0", "@opentelemetry/semantic-conventions": "^1.0.0", "@types/tedious": "^4.0.10" }, diff --git a/plugins/node/opentelemetry-instrumentation-aws-lambda/package.json b/plugins/node/opentelemetry-instrumentation-aws-lambda/package.json index c30158eb51..4a785aa4fa 100644 --- a/plugins/node/opentelemetry-instrumentation-aws-lambda/package.json +++ b/plugins/node/opentelemetry-instrumentation-aws-lambda/package.json @@ -59,7 +59,7 @@ "typescript": "4.4.4" }, "dependencies": { - "@opentelemetry/instrumentation": "^0.44.0", + "@opentelemetry/instrumentation": "^0.45.0", "@opentelemetry/propagator-aws-xray": "^1.3.1", "@opentelemetry/resources": "^1.8.0", "@opentelemetry/semantic-conventions": "^1.0.0", diff --git a/plugins/node/opentelemetry-instrumentation-aws-sdk/package.json b/plugins/node/opentelemetry-instrumentation-aws-sdk/package.json index 09d0ee663e..c00721cd47 100644 --- a/plugins/node/opentelemetry-instrumentation-aws-sdk/package.json +++ b/plugins/node/opentelemetry-instrumentation-aws-sdk/package.json @@ -47,7 +47,7 @@ }, "dependencies": { "@opentelemetry/core": "^1.8.0", - "@opentelemetry/instrumentation": "^0.44.0", + "@opentelemetry/instrumentation": "^0.45.0", "@opentelemetry/semantic-conventions": "^1.0.0", "@opentelemetry/propagation-utils": "^0.30.2" }, diff --git a/plugins/node/opentelemetry-instrumentation-bunyan/package.json b/plugins/node/opentelemetry-instrumentation-bunyan/package.json index 0d0dff3244..f9c834b9aa 100644 --- a/plugins/node/opentelemetry-instrumentation-bunyan/package.json +++ b/plugins/node/opentelemetry-instrumentation-bunyan/package.json @@ -66,8 +66,8 @@ "typescript": "4.4.4" }, "dependencies": { - "@opentelemetry/api-logs": "^0.44.0", - "@opentelemetry/instrumentation": "^0.44.0", + "@opentelemetry/api-logs": "^0.45.0", + "@opentelemetry/instrumentation": "^0.45.0", "@types/bunyan": "1.8.9" }, "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-bunyan#readme" diff --git a/plugins/node/opentelemetry-instrumentation-cassandra/package.json b/plugins/node/opentelemetry-instrumentation-cassandra/package.json index 722a7fa6da..851ff608eb 100644 --- a/plugins/node/opentelemetry-instrumentation-cassandra/package.json +++ b/plugins/node/opentelemetry-instrumentation-cassandra/package.json @@ -64,7 +64,7 @@ "typescript": "4.4.4" }, "dependencies": { - "@opentelemetry/instrumentation": "^0.44.0", + "@opentelemetry/instrumentation": "^0.45.0", "@opentelemetry/semantic-conventions": "^1.0.0" }, "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-cassandra#readme" diff --git a/plugins/node/opentelemetry-instrumentation-cassandra/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-cassandra/src/instrumentation.ts index 68f8975ece..fe2f9718e5 100644 --- a/plugins/node/opentelemetry-instrumentation-cassandra/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-cassandra/src/instrumentation.ts @@ -51,7 +51,10 @@ export class CassandraDriverInstrumentation extends InstrumentationBase { return new InstrumentationNodeModuleDefinition( 'cassandra-driver', supportedVersions, - driverModule => { + (driverModule, moduleVersion) => { + this._diag.debug( + `Applying patch for cassandra-driver@${moduleVersion}` + ); // eslint-disable-next-line @typescript-eslint/no-explicit-any const Client = driverModule.Client.prototype as any; @@ -73,7 +76,10 @@ export class CassandraDriverInstrumentation extends InstrumentationBase { return driverModule; }, - driverModule => { + (driverModule, moduleVersion) => { + this._diag.debug( + `Removing patch for cassandra-driver@${moduleVersion}` + ); // eslint-disable-next-line @typescript-eslint/no-explicit-any const Client = driverModule.Client.prototype as any; diff --git a/plugins/node/opentelemetry-instrumentation-connect/package.json b/plugins/node/opentelemetry-instrumentation-connect/package.json index 07b64fbbf5..65b6205061 100644 --- a/plugins/node/opentelemetry-instrumentation-connect/package.json +++ b/plugins/node/opentelemetry-instrumentation-connect/package.json @@ -59,7 +59,7 @@ }, "dependencies": { "@opentelemetry/core": "^1.8.0", - "@opentelemetry/instrumentation": "^0.44.0", + "@opentelemetry/instrumentation": "^0.45.0", "@opentelemetry/semantic-conventions": "^1.0.0", "@types/connect": "3.4.36" }, diff --git a/plugins/node/opentelemetry-instrumentation-dns/package.json b/plugins/node/opentelemetry-instrumentation-dns/package.json index 6ba9c4793f..390cd17f19 100644 --- a/plugins/node/opentelemetry-instrumentation-dns/package.json +++ b/plugins/node/opentelemetry-instrumentation-dns/package.json @@ -62,7 +62,7 @@ "typescript": "4.4.4" }, "dependencies": { - "@opentelemetry/instrumentation": "^0.44.0", + "@opentelemetry/instrumentation": "^0.45.0", "@opentelemetry/semantic-conventions": "^1.0.0", "semver": "^7.5.4" }, diff --git a/plugins/node/opentelemetry-instrumentation-express/examples/package.json b/plugins/node/opentelemetry-instrumentation-express/examples/package.json index 9452aab585..02be274477 100644 --- a/plugins/node/opentelemetry-instrumentation-express/examples/package.json +++ b/plugins/node/opentelemetry-instrumentation-express/examples/package.json @@ -32,9 +32,9 @@ "@opentelemetry/api": "^1.0.0", "@opentelemetry/exporter-jaeger": "^1.0.0", "@opentelemetry/exporter-zipkin": "^1.0.0", - "@opentelemetry/instrumentation": "^0.44.0", + "@opentelemetry/instrumentation": "^0.45.0", "@opentelemetry/instrumentation-express": "0.28.0", - "@opentelemetry/instrumentation-http": "^0.44.0", + "@opentelemetry/instrumentation-http": "^0.45.0", "@opentelemetry/resources": "^1.0.0", "@opentelemetry/sdk-trace-base": "^1.0.0", "@opentelemetry/sdk-trace-node": "^1.0.0", diff --git a/plugins/node/opentelemetry-instrumentation-express/package.json b/plugins/node/opentelemetry-instrumentation-express/package.json index a1c45723df..260ebd85cf 100644 --- a/plugins/node/opentelemetry-instrumentation-express/package.json +++ b/plugins/node/opentelemetry-instrumentation-express/package.json @@ -66,7 +66,7 @@ }, "dependencies": { "@opentelemetry/core": "^1.8.0", - "@opentelemetry/instrumentation": "^0.44.0", + "@opentelemetry/instrumentation": "^0.45.0", "@opentelemetry/semantic-conventions": "^1.0.0", "@types/express": "4.17.18" }, diff --git a/plugins/node/opentelemetry-instrumentation-fastify/package.json b/plugins/node/opentelemetry-instrumentation-fastify/package.json index 9d110cccc1..f3f051ef80 100644 --- a/plugins/node/opentelemetry-instrumentation-fastify/package.json +++ b/plugins/node/opentelemetry-instrumentation-fastify/package.json @@ -49,7 +49,7 @@ "@fastify/express": "^2.0.2", "@opentelemetry/api": "^1.3.0", "@opentelemetry/context-async-hooks": "^1.8.0", - "@opentelemetry/instrumentation-http": "0.44.0", + "@opentelemetry/instrumentation-http": "0.45.0", "@opentelemetry/sdk-trace-base": "^1.8.0", "@opentelemetry/sdk-trace-node": "^1.8.0", "@types/express": "4.17.18", @@ -65,7 +65,7 @@ }, "dependencies": { "@opentelemetry/core": "^1.8.0", - "@opentelemetry/instrumentation": "^0.44.0", + "@opentelemetry/instrumentation": "^0.45.0", "@opentelemetry/semantic-conventions": "^1.0.0" }, "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-fastify#readme" diff --git a/plugins/node/opentelemetry-instrumentation-fastify/src/constants.ts b/plugins/node/opentelemetry-instrumentation-fastify/src/constants.ts index e6e0ebedae..4f2efd02d5 100644 --- a/plugins/node/opentelemetry-instrumentation-fastify/src/constants.ts +++ b/plugins/node/opentelemetry-instrumentation-fastify/src/constants.ts @@ -18,9 +18,18 @@ export const spanRequestSymbol = Symbol( 'opentelemetry.instrumentation.fastify.request_active_span' ); -export const applicationHookNames = [ - 'onRegister', - 'onRoute', - 'onReady', - 'onClose', -]; +// The instrumentation creates a span for invocations of lifecycle hook handlers +// that take `(request, reply, ...[, done])` arguments. Currently this is all +// lifecycle hooks except `onRequestAbort`. +// https://fastify.dev/docs/latest/Reference/Hooks +export const hooksNamesToWrap = new Set([ + 'onTimeout', + 'onRequest', + 'preParsing', + 'preValidation', + 'preSerialization', + 'preHandler', + 'onSend', + 'onResponse', + 'onError', +]); diff --git a/plugins/node/opentelemetry-instrumentation-fastify/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-fastify/src/instrumentation.ts index ba96a020dd..e410b93bad 100644 --- a/plugins/node/opentelemetry-instrumentation-fastify/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-fastify/src/instrumentation.ts @@ -33,7 +33,7 @@ import type { FastifyRequest, FastifyReply, } from 'fastify'; -import { applicationHookNames } from './constants'; +import { hooksNamesToWrap } from './constants'; import { AttributeNames, FastifyNames, @@ -178,8 +178,8 @@ export class FastifyInstrumentation extends InstrumentationBase { const name = args[0] as string; const handler = args[1] as HandlerOriginal; const pluginName = this.pluginName; - if (applicationHookNames.includes(name)) { - return original.apply(this, [name, handler] as never); + if (!hooksNamesToWrap.has(name)) { + return original.apply(this, args); } const syncFunctionWithDone = diff --git a/plugins/node/opentelemetry-instrumentation-fastify/test/instrumentation.test.ts b/plugins/node/opentelemetry-instrumentation-fastify/test/instrumentation.test.ts index 90a881a321..2efccaf724 100644 --- a/plugins/node/opentelemetry-instrumentation-fastify/test/instrumentation.test.ts +++ b/plugins/node/opentelemetry-instrumentation-fastify/test/instrumentation.test.ts @@ -424,6 +424,14 @@ describe('fastify', () => { await startServer(); }); + it('preClose is not instrumented', async () => { + app.addHook('preClose', () => { + assertRootContextActive(); + }); + + await startServer(); + }); + it('onClose is not instrumented', async () => { app.addHook('onClose', () => { assertRootContextActive(); diff --git a/plugins/node/opentelemetry-instrumentation-generic-pool/package.json b/plugins/node/opentelemetry-instrumentation-generic-pool/package.json index 63dc4730f5..66a064b80c 100644 --- a/plugins/node/opentelemetry-instrumentation-generic-pool/package.json +++ b/plugins/node/opentelemetry-instrumentation-generic-pool/package.json @@ -62,7 +62,7 @@ "typescript": "4.4.4" }, "dependencies": { - "@opentelemetry/instrumentation": "^0.44.0", + "@opentelemetry/instrumentation": "^0.45.0", "@opentelemetry/semantic-conventions": "^1.0.0" }, "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-generic-pool#readme" diff --git a/plugins/node/opentelemetry-instrumentation-graphql/package.json b/plugins/node/opentelemetry-instrumentation-graphql/package.json index fd9c769bd6..5eb3031eb7 100644 --- a/plugins/node/opentelemetry-instrumentation-graphql/package.json +++ b/plugins/node/opentelemetry-instrumentation-graphql/package.json @@ -61,7 +61,7 @@ "typescript": "4.4.4" }, "dependencies": { - "@opentelemetry/instrumentation": "^0.44.0" + "@opentelemetry/instrumentation": "^0.45.0" }, "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-graphql#readme" } diff --git a/plugins/node/opentelemetry-instrumentation-graphql/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-graphql/src/instrumentation.ts index 5872fb8df6..217744e3da 100644 --- a/plugins/node/opentelemetry-instrumentation-graphql/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-graphql/src/instrumentation.ts @@ -102,7 +102,8 @@ export class GraphQLInstrumentation extends InstrumentationBase { supportedVersions, // cannot make it work with appropriate type as execute function has 2 //types and/cannot import function but only types - (moduleExports: any) => { + (moduleExports: any, moduleVersion) => { + this._diag.debug(`Applying patch for graphql@${moduleVersion} execute`); if (isWrapped(moduleExports.execute)) { this._unwrap(moduleExports, 'execute'); } @@ -113,8 +114,11 @@ export class GraphQLInstrumentation extends InstrumentationBase { ); return moduleExports; }, - moduleExports => { + (moduleExports, moduleVersion) => { if (moduleExports) { + this._diag.debug( + `Removing patch for graphql@${moduleVersion} execute` + ); this._unwrap(moduleExports, 'execute'); } } @@ -127,15 +131,17 @@ export class GraphQLInstrumentation extends InstrumentationBase { return new InstrumentationNodeModuleFile( 'graphql/language/parser.js', supportedVersions, - moduleExports => { - if (isWrapped(moduleExports.execute)) { + (moduleExports, moduleVersion) => { + this._diag.debug(`Applying patch for graphql@${moduleVersion} parse`); + if (isWrapped(moduleExports.parse)) { this._unwrap(moduleExports, 'parse'); } this._wrap(moduleExports, 'parse', this._patchParse()); return moduleExports; }, - moduleExports => { + (moduleExports, moduleVersion) => { if (moduleExports) { + this._diag.debug(`Removing patch for graphql@${moduleVersion} parse`); this._unwrap(moduleExports, 'parse'); } } @@ -148,15 +154,21 @@ export class GraphQLInstrumentation extends InstrumentationBase { return new InstrumentationNodeModuleFile( 'graphql/validation/validate.js', supportedVersions, - moduleExports => { - if (isWrapped(moduleExports.execute)) { + (moduleExports, moduleVersion) => { + this._diag.debug( + `Applying patch for graphql@${moduleVersion} validate` + ); + if (isWrapped(moduleExports.validate)) { this._unwrap(moduleExports, 'validate'); } this._wrap(moduleExports, 'validate', this._patchValidate()); return moduleExports; }, - moduleExports => { + (moduleExports, moduleVersion) => { if (moduleExports) { + this._diag.debug( + `Removing patch for graphql@${moduleVersion} validate` + ); this._unwrap(moduleExports, 'validate'); } } @@ -285,7 +297,7 @@ export class GraphQLInstrumentation extends InstrumentationBase { }, err => { if (err) { - api.diag.error('Error running response hook', err); + this._diag.error('Error running response hook', err); } endSpan(span, undefined); diff --git a/plugins/node/opentelemetry-instrumentation-hapi/package.json b/plugins/node/opentelemetry-instrumentation-hapi/package.json index 6661a1db31..840a51d272 100644 --- a/plugins/node/opentelemetry-instrumentation-hapi/package.json +++ b/plugins/node/opentelemetry-instrumentation-hapi/package.json @@ -60,7 +60,7 @@ }, "dependencies": { "@opentelemetry/core": "^1.8.0", - "@opentelemetry/instrumentation": "^0.44.0", + "@opentelemetry/instrumentation": "^0.45.0", "@opentelemetry/semantic-conventions": "^1.0.0", "@types/hapi__hapi": "20.0.13" }, diff --git a/plugins/node/opentelemetry-instrumentation-ioredis/package.json b/plugins/node/opentelemetry-instrumentation-ioredis/package.json index cfbad0dc28..5983ab4093 100644 --- a/plugins/node/opentelemetry-instrumentation-ioredis/package.json +++ b/plugins/node/opentelemetry-instrumentation-ioredis/package.json @@ -69,7 +69,7 @@ "typescript": "4.4.4" }, "dependencies": { - "@opentelemetry/instrumentation": "^0.44.0", + "@opentelemetry/instrumentation": "^0.45.0", "@opentelemetry/redis-common": "^0.36.1", "@opentelemetry/semantic-conventions": "^1.0.0", "@types/ioredis4": "npm:@types/ioredis@^4.28.10" diff --git a/plugins/node/opentelemetry-instrumentation-ioredis/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-ioredis/src/instrumentation.ts index 94f8b850ed..0753518de3 100644 --- a/plugins/node/opentelemetry-instrumentation-ioredis/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-ioredis/src/instrumentation.ts @@ -49,7 +49,11 @@ export class IORedisInstrumentation extends InstrumentationBase { new InstrumentationNodeModuleDefinition( 'ioredis', ['>1', '<6'], - (moduleExports, moduleVersion?: string) => { + (module, moduleVersion?: string) => { + const moduleExports = + module[Symbol.toStringTag] === 'Module' + ? module.default // ESM + : module; // CommonJS diag.debug('Applying patch for ioredis'); if (isWrapped(moduleExports.prototype.sendCommand)) { this._unwrap(moduleExports.prototype, 'sendCommand'); @@ -67,10 +71,14 @@ export class IORedisInstrumentation extends InstrumentationBase { 'connect', this._patchConnection() ); - return moduleExports; + return module; }, - moduleExports => { - if (moduleExports === undefined) return; + module => { + if (module === undefined) return; + const moduleExports = + module[Symbol.toStringTag] === 'Module' + ? module.default // ESM + : module; // CommonJS diag.debug('Removing patch for ioredis'); this._unwrap(moduleExports.prototype, 'sendCommand'); this._unwrap(moduleExports.prototype, 'connect'); @@ -84,17 +92,17 @@ export class IORedisInstrumentation extends InstrumentationBase { */ private _patchSendCommand(moduleVersion?: string) { return (original: Function) => { - return this.traceSendCommand(original, moduleVersion); + return this._traceSendCommand(original, moduleVersion); }; } private _patchConnection() { return (original: Function) => { - return this.traceConnection(original); + return this._traceConnection(original); }; } - private traceSendCommand = (original: Function, moduleVersion?: string) => { + private _traceSendCommand(original: Function, moduleVersion?: string) { const instrumentation = this; return function (this: RedisInterface, cmd?: IORedisCommand) { if (arguments.length < 1 || typeof cmd !== 'object') { @@ -178,9 +186,9 @@ export class IORedisInstrumentation extends InstrumentationBase { throw error; } }; - }; + } - private traceConnection = (original: Function) => { + private _traceConnection(original: Function) { const instrumentation = this; return function (this: RedisInterface) { const config = @@ -213,5 +221,5 @@ export class IORedisInstrumentation extends InstrumentationBase { throw error; } }; - }; + } } diff --git a/plugins/node/opentelemetry-instrumentation-knex/package.json b/plugins/node/opentelemetry-instrumentation-knex/package.json index 10b5b8073c..3c5d9434a3 100644 --- a/plugins/node/opentelemetry-instrumentation-knex/package.json +++ b/plugins/node/opentelemetry-instrumentation-knex/package.json @@ -60,7 +60,7 @@ "typescript": "4.4.4" }, "dependencies": { - "@opentelemetry/instrumentation": "^0.44.0", + "@opentelemetry/instrumentation": "^0.45.0", "@opentelemetry/semantic-conventions": "^1.0.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-koa/examples/package.json b/plugins/node/opentelemetry-instrumentation-koa/examples/package.json index 04b1de66d7..4a07cf8f3e 100644 --- a/plugins/node/opentelemetry-instrumentation-koa/examples/package.json +++ b/plugins/node/opentelemetry-instrumentation-koa/examples/package.json @@ -34,8 +34,8 @@ "@opentelemetry/api": "^1.0.0", "@opentelemetry/exporter-jaeger": "^1.0.0", "@opentelemetry/exporter-zipkin": "^1.0.0", - "@opentelemetry/instrumentation": "^0.44.0", - "@opentelemetry/instrumentation-http": "^0.44.0", + "@opentelemetry/instrumentation": "^0.45.0", + "@opentelemetry/instrumentation-http": "^0.45.0", "@opentelemetry/instrumentation-koa": "^0.31.0", "@opentelemetry/sdk-trace-node": "^1.0.0", "@opentelemetry/sdk-trace-base": "^1.0.0", diff --git a/plugins/node/opentelemetry-instrumentation-koa/package.json b/plugins/node/opentelemetry-instrumentation-koa/package.json index 2ff2337966..a2fc2a8b0d 100644 --- a/plugins/node/opentelemetry-instrumentation-koa/package.json +++ b/plugins/node/opentelemetry-instrumentation-koa/package.json @@ -68,7 +68,7 @@ }, "dependencies": { "@opentelemetry/core": "^1.8.0", - "@opentelemetry/instrumentation": "^0.44.0", + "@opentelemetry/instrumentation": "^0.45.0", "@opentelemetry/semantic-conventions": "^1.0.0", "@types/koa": "2.13.9", "@types/koa__router": "12.0.1" diff --git a/plugins/node/opentelemetry-instrumentation-memcached/package.json b/plugins/node/opentelemetry-instrumentation-memcached/package.json index d560fb6890..62fc1dddd3 100644 --- a/plugins/node/opentelemetry-instrumentation-memcached/package.json +++ b/plugins/node/opentelemetry-instrumentation-memcached/package.json @@ -63,7 +63,7 @@ "typescript": "4.4.4" }, "dependencies": { - "@opentelemetry/instrumentation": "^0.44.0", + "@opentelemetry/instrumentation": "^0.45.0", "@opentelemetry/semantic-conventions": "^1.0.0", "@types/memcached": "^2.2.6" }, diff --git a/plugins/node/opentelemetry-instrumentation-mongodb/examples/package.json b/plugins/node/opentelemetry-instrumentation-mongodb/examples/package.json index 124776ff49..f2b5a42c37 100644 --- a/plugins/node/opentelemetry-instrumentation-mongodb/examples/package.json +++ b/plugins/node/opentelemetry-instrumentation-mongodb/examples/package.json @@ -33,8 +33,8 @@ "@opentelemetry/api": "^1.0.0", "@opentelemetry/exporter-jaeger": "^1.0.0", "@opentelemetry/exporter-zipkin": "^1.0.0", - "@opentelemetry/instrumentation": "^0.44.0", - "@opentelemetry/instrumentation-http": "^0.44.0", + "@opentelemetry/instrumentation": "^0.45.0", + "@opentelemetry/instrumentation-http": "^0.45.0", "@opentelemetry/instrumentation-mongodb": "^0.32.0", "@opentelemetry/sdk-trace-node": "^1.0.0", "@opentelemetry/sdk-trace-base": "^1.0.0", diff --git a/plugins/node/opentelemetry-instrumentation-mongodb/package.json b/plugins/node/opentelemetry-instrumentation-mongodb/package.json index 374ced0202..96781260ed 100644 --- a/plugins/node/opentelemetry-instrumentation-mongodb/package.json +++ b/plugins/node/opentelemetry-instrumentation-mongodb/package.json @@ -71,7 +71,7 @@ }, "dependencies": { "@opentelemetry/sdk-metrics": "^1.9.1", - "@opentelemetry/instrumentation": "^0.44.0", + "@opentelemetry/instrumentation": "^0.45.0", "@opentelemetry/semantic-conventions": "^1.0.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 587c0fe185..f44e0df2b2 100644 --- a/plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - import { context, diag, @@ -42,6 +41,7 @@ import { MongoInternalTopology, WireProtocolInternal, V4Connection, + V4ConnectionPool, } from './internal-types'; import { V4Connect, V4Session } from './internal-types'; import { VERSION } from './version'; @@ -76,6 +76,8 @@ export class MongoDBInstrumentation extends InstrumentationBase { const { v4PatchConnect, v4UnpatchConnect } = this._getV4ConnectPatches(); const { v4PatchConnection, v4UnpatchConnection } = this._getV4ConnectionPatches(); + const { v4PatchConnectionPool, v4UnpatchConnectionPool } = + this._getV4ConnectionPoolPatches(); const { v4PatchSessions, v4UnpatchSessions } = this._getV4SessionsPatches(); return [ @@ -105,6 +107,12 @@ export class MongoDBInstrumentation extends InstrumentationBase { v4PatchConnection, v4UnpatchConnection ), + new InstrumentationNodeModuleFile( + 'mongodb/lib/cmap/connection_pool.js', + ['4.*', '5.*'], + v4PatchConnectionPool, + v4UnpatchConnectionPool + ), new InstrumentationNodeModuleFile( 'mongodb/lib/cmap/connect.js', ['4.*', '5.*'], @@ -268,6 +276,35 @@ export class MongoDBInstrumentation extends InstrumentationBase { }; } + private _getV4ConnectionPoolPatches() { + return { + v4PatchConnectionPool: (moduleExports: any, moduleVersion?: string) => { + diag.debug(`Applying patch for mongodb@${moduleVersion}`); + const poolPrototype = moduleExports.ConnectionPool.prototype; + + if (isWrapped(poolPrototype.checkOut)) { + this._unwrap(poolPrototype, 'checkOut'); + } + + this._wrap( + poolPrototype, + 'checkOut', + this._getV4ConnectionPoolCheckOut() + ); + return moduleExports; + }, + v4UnpatchConnectionPool: ( + moduleExports?: any, + moduleVersion?: string + ) => { + diag.debug(`Removing internal patch for mongodb@${moduleVersion}`); + if (moduleExports === undefined) return; + + this._unwrap(moduleExports.ConnectionPool.prototype, 'checkOut'); + }, + }; + } + private _getV4ConnectPatches() { return { v4PatchConnect: (moduleExports: any, moduleVersion?: string) => { @@ -288,6 +325,17 @@ export class MongoDBInstrumentation extends InstrumentationBase { }; } + // This patch will become unnecessary once + // https://jira.mongodb.org/browse/NODE-5639 is done. + private _getV4ConnectionPoolCheckOut() { + return (original: V4ConnectionPool['checkOut']) => { + return function patchedCheckout(this: unknown, callback: any) { + const patchedCallback = context.bind(context.active(), callback); + return original.call(this, patchedCallback); + }; + }; + } + private _getV4ConnectCommand() { const instrumentation = this; diff --git a/plugins/node/opentelemetry-instrumentation-mongodb/src/internal-types.ts b/plugins/node/opentelemetry-instrumentation-mongodb/src/internal-types.ts index 03131aa12a..5cb4119de5 100644 --- a/plugins/node/opentelemetry-instrumentation-mongodb/src/internal-types.ts +++ b/plugins/node/opentelemetry-instrumentation-mongodb/src/internal-types.ts @@ -184,6 +184,13 @@ export type V4Connection = { ): void; }; +// https://github.com/mongodb/node-mongodb-native/blob/v4.2.2/src/cmap/connection_pool.ts +export type V4ConnectionPool = { + // Instrumentation just cares about carrying the async context so + // types of callback params are not needed + checkOut: (callback: (error: any, connection: any) => void) => void; +}; + // https://github.com/mongodb/node-mongodb-native/blob/v4.2.2/src/cmap/connect.ts export type V4Connect = { connect: (options: any, callback: any) => void; diff --git a/plugins/node/opentelemetry-instrumentation-mongodb/test/mongodb-v4.test.ts b/plugins/node/opentelemetry-instrumentation-mongodb/test/mongodb-v4.test.ts index 18ba6bc9ef..724e33cffd 100644 --- a/plugins/node/opentelemetry-instrumentation-mongodb/test/mongodb-v4.test.ts +++ b/plugins/node/opentelemetry-instrumentation-mongodb/test/mongodb-v4.test.ts @@ -237,6 +237,44 @@ describe('MongoDBInstrumentation-Tracing-v4', () => { }); }); }); + + it('should create child spans for concurrent cursor operations', done => { + const queries = [{ a: 1 }, { a: 2 }, { a: 3 }]; + const tasks = queries.map((query, idx) => { + return new Promise((resolve, reject) => { + process.nextTick(() => { + const span = trace + .getTracer('default') + .startSpan(`findRootSpan ${idx}`); + context.with(trace.setSpan(context.active(), span), () => { + collection + .find(query) + .toArray() + .then(() => { + resolve(span.end()); + }) + .catch(reject); + }); + }); + }); + }); + + Promise.all(tasks) + .then(() => { + const spans = getTestSpans(); + const roots = spans.filter(s => s.name.startsWith('findRootSpan')); + + roots.forEach(root => { + const rootId = root.spanContext().spanId; + const children = spans.filter(s => s.parentSpanId === rootId); + assert.strictEqual(children.length, 1); + }); + done(); + }) + .catch(err => { + done(err); + }); + }); }); /** Should intercept command */ diff --git a/plugins/node/opentelemetry-instrumentation-mongodb/test/mongodb-v5.test.ts b/plugins/node/opentelemetry-instrumentation-mongodb/test/mongodb-v5.test.ts index bd8271cb8d..e9f80ad6c5 100644 --- a/plugins/node/opentelemetry-instrumentation-mongodb/test/mongodb-v5.test.ts +++ b/plugins/node/opentelemetry-instrumentation-mongodb/test/mongodb-v5.test.ts @@ -243,6 +243,44 @@ describe('MongoDBInstrumentation-Tracing-v5', () => { }); }); }); + + it('should create child spans for concurrent cursor operations', done => { + const queries = [{ a: 1 }, { a: 2 }, { a: 3 }]; + const tasks = queries.map((query, idx) => { + return new Promise((resolve, reject) => { + process.nextTick(() => { + const span = trace + .getTracer('default') + .startSpan(`findRootSpan ${idx}`); + context.with(trace.setSpan(context.active(), span), () => { + collection + .find(query) + .toArray() + .then(() => { + resolve(span.end()); + }) + .catch(reject); + }); + }); + }); + }); + + Promise.all(tasks) + .then(() => { + const spans = getTestSpans(); + const roots = spans.filter(s => s.name.startsWith('findRootSpan')); + + roots.forEach(root => { + const rootId = root.spanContext().spanId; + const children = spans.filter(s => s.parentSpanId === rootId); + assert.strictEqual(children.length, 1); + }); + done(); + }) + .catch(err => { + done(err); + }); + }); }); /** Should intercept command */ diff --git a/plugins/node/opentelemetry-instrumentation-mysql/examples/package.json b/plugins/node/opentelemetry-instrumentation-mysql/examples/package.json index b257832c73..0bc5b8038c 100644 --- a/plugins/node/opentelemetry-instrumentation-mysql/examples/package.json +++ b/plugins/node/opentelemetry-instrumentation-mysql/examples/package.json @@ -34,12 +34,12 @@ "@opentelemetry/api": "^1.0.0", "@opentelemetry/exporter-jaeger": "^1.0.0", "@opentelemetry/exporter-zipkin": "^1.0.0", - "@opentelemetry/instrumentation": "^0.44.0", - "@opentelemetry/instrumentation-http": "^0.44.0", + "@opentelemetry/instrumentation": "^0.45.0", + "@opentelemetry/instrumentation-http": "^0.45.0", "@opentelemetry/instrumentation-mysql": "^0.31.0", "@opentelemetry/sdk-trace-base": "^1.0.0", "@opentelemetry/sdk-trace-node": "^1.0.0", - "@opentelemetry/exporter-metrics-otlp-grpc": "0.44.0", + "@opentelemetry/exporter-metrics-otlp-grpc": "0.45.0", "mysql": "^2.18.1" }, "homepage": "https://github.com/open-telemetry/opentelemetry-js#readme", diff --git a/plugins/node/opentelemetry-instrumentation-mysql/package.json b/plugins/node/opentelemetry-instrumentation-mysql/package.json index 18b7b9add3..75cd16ab95 100644 --- a/plugins/node/opentelemetry-instrumentation-mysql/package.json +++ b/plugins/node/opentelemetry-instrumentation-mysql/package.json @@ -63,7 +63,7 @@ "typescript": "4.4.4" }, "dependencies": { - "@opentelemetry/instrumentation": "^0.44.0", + "@opentelemetry/instrumentation": "^0.45.0", "@opentelemetry/semantic-conventions": "^1.0.0", "@types/mysql": "2.15.22" }, diff --git a/plugins/node/opentelemetry-instrumentation-mysql2/package.json b/plugins/node/opentelemetry-instrumentation-mysql2/package.json index dec0a017e7..3d3f3ff1c0 100644 --- a/plugins/node/opentelemetry-instrumentation-mysql2/package.json +++ b/plugins/node/opentelemetry-instrumentation-mysql2/package.json @@ -65,7 +65,7 @@ "typescript": "4.4.4" }, "dependencies": { - "@opentelemetry/instrumentation": "^0.44.0", + "@opentelemetry/instrumentation": "^0.45.0", "@opentelemetry/semantic-conventions": "^1.0.0", "@opentelemetry/sql-common": "^0.40.0" }, diff --git a/plugins/node/opentelemetry-instrumentation-nestjs-core/package.json b/plugins/node/opentelemetry-instrumentation-nestjs-core/package.json index f04ef44559..935b5c2aa2 100644 --- a/plugins/node/opentelemetry-instrumentation-nestjs-core/package.json +++ b/plugins/node/opentelemetry-instrumentation-nestjs-core/package.json @@ -73,7 +73,7 @@ "typescript": "4.4.4" }, "dependencies": { - "@opentelemetry/instrumentation": "^0.44.0", + "@opentelemetry/instrumentation": "^0.45.0", "@opentelemetry/semantic-conventions": "^1.0.0" }, "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-nestjs-core#readme" diff --git a/plugins/node/opentelemetry-instrumentation-net/package.json b/plugins/node/opentelemetry-instrumentation-net/package.json index 5af5a30bf5..f451982d55 100644 --- a/plugins/node/opentelemetry-instrumentation-net/package.json +++ b/plugins/node/opentelemetry-instrumentation-net/package.json @@ -61,7 +61,7 @@ "typescript": "4.4.4" }, "dependencies": { - "@opentelemetry/instrumentation": "^0.44.0", + "@opentelemetry/instrumentation": "^0.45.0", "@opentelemetry/semantic-conventions": "^1.0.0" }, "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-net#readme" diff --git a/plugins/node/opentelemetry-instrumentation-pg/package.json b/plugins/node/opentelemetry-instrumentation-pg/package.json index 28eebe4a23..2d6c461d5a 100644 --- a/plugins/node/opentelemetry-instrumentation-pg/package.json +++ b/plugins/node/opentelemetry-instrumentation-pg/package.json @@ -75,7 +75,7 @@ }, "dependencies": { "@opentelemetry/core": "^1.8.0", - "@opentelemetry/instrumentation": "^0.44.0", + "@opentelemetry/instrumentation": "^0.45.0", "@opentelemetry/semantic-conventions": "^1.0.0", "@opentelemetry/sql-common": "^0.40.0", "@types/pg": "8.6.1", diff --git a/plugins/node/opentelemetry-instrumentation-pg/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-pg/src/instrumentation.ts index f47b1e81b0..1fa8f58d3d 100644 --- a/plugins/node/opentelemetry-instrumentation-pg/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-pg/src/instrumentation.ts @@ -22,7 +22,6 @@ import { import { context, - diag, trace, Span, SpanStatusCode, @@ -66,7 +65,12 @@ export class PgInstrumentation extends InstrumentationBase { const modulePG = new InstrumentationNodeModuleDefinition( 'pg', ['8.*'], - moduleExports => { + (module: any, moduleVersion) => { + this._diag.debug(`Applying patch for pg@${moduleVersion}`); + const moduleExports: typeof pgTypes = + module[Symbol.toStringTag] === 'Module' + ? module.default // ESM + : module; // CommonJS if (isWrapped(moduleExports.Client.prototype.query)) { this._unwrap(moduleExports.Client.prototype, 'query'); } @@ -87,9 +91,14 @@ export class PgInstrumentation extends InstrumentationBase { this._getClientConnectPatch() as any ); - return moduleExports; + return module; }, - moduleExports => { + (module: any, moduleVersion) => { + const moduleExports: typeof pgTypes = + module[Symbol.toStringTag] === 'Module' + ? module.default // ESM + : module; // CommonJS + this._diag.debug(`Removing patch for pg@${moduleVersion}`); if (isWrapped(moduleExports.Client.prototype.query)) { this._unwrap(moduleExports.Client.prototype, 'query'); } @@ -101,7 +110,8 @@ export class PgInstrumentation extends InstrumentationBase { >( 'pg-pool', ['2.*', '3.*'], - moduleExports => { + (moduleExports, moduleVersion) => { + this._diag.debug(`Applying patch for pg-pool@${moduleVersion}`); if (isWrapped(moduleExports.prototype.connect)) { this._unwrap(moduleExports.prototype, 'connect'); } @@ -112,7 +122,8 @@ export class PgInstrumentation extends InstrumentationBase { ); return moduleExports; }, - moduleExports => { + (moduleExports, moduleVersion) => { + this._diag.debug(`Removing patch for pg-pool@${moduleVersion}`); if (isWrapped(moduleExports.prototype.connect)) { this._unwrap(moduleExports.prototype, 'connect'); } @@ -172,7 +183,7 @@ export class PgInstrumentation extends InstrumentationBase { private _getClientQueryPatch() { const plugin = this; return (original: typeof pgTypes.Client.prototype.query) => { - diag.debug( + this._diag.debug( `Patching ${PgInstrumentation.COMPONENT}.Client.prototype.query` ); return function query(this: PgClientExtended, ...args: unknown[]) { diff --git a/plugins/node/opentelemetry-instrumentation-pino/package.json b/plugins/node/opentelemetry-instrumentation-pino/package.json index f46c9ffa2c..5e19818c83 100644 --- a/plugins/node/opentelemetry-instrumentation-pino/package.json +++ b/plugins/node/opentelemetry-instrumentation-pino/package.json @@ -66,7 +66,7 @@ "typescript": "4.4.4" }, "dependencies": { - "@opentelemetry/instrumentation": "^0.44.0" + "@opentelemetry/instrumentation": "^0.45.0" }, "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-pino#readme" } diff --git a/plugins/node/opentelemetry-instrumentation-redis-4/CHANGELOG.md b/plugins/node/opentelemetry-instrumentation-redis-4/CHANGELOG.md index 047e6f0f85..ceb7e0693f 100644 --- a/plugins/node/opentelemetry-instrumentation-redis-4/CHANGELOG.md +++ b/plugins/node/opentelemetry-instrumentation-redis-4/CHANGELOG.md @@ -6,6 +6,14 @@ * dependencies * @opentelemetry/redis-common bumped from ^0.34.0 to ^0.35.0 +## [0.35.3](https://github.com/open-telemetry/opentelemetry-js-contrib/compare/instrumentation-redis-4-v0.35.2...instrumentation-redis-4-v0.35.3) (2023-10-13) + + +### Bug Fixes + +* **instrumentation-redis-4:** avoid shimmer warning by only wrapping multi/MULTI if they exist ([#1729](https://github.com/open-telemetry/opentelemetry-js-contrib/issues/1729)) ([247a81c](https://github.com/open-telemetry/opentelemetry-js-contrib/commit/247a81c047264ba638abb9a2ef2ca14801094040)) +* **instrumentation-redis-4:** fix unhandledRejection in client.multi(...) handling ([#1730](https://github.com/open-telemetry/opentelemetry-js-contrib/issues/1730)) ([d953531](https://github.com/open-telemetry/opentelemetry-js-contrib/commit/d95353179279e3cf35ec37b6ca18f1e920691e16)) + ## [0.35.2](https://github.com/open-telemetry/opentelemetry-js-contrib/compare/instrumentation-redis-4-v0.35.1...instrumentation-redis-4-v0.35.2) (2023-10-10) diff --git a/plugins/node/opentelemetry-instrumentation-redis-4/package.json b/plugins/node/opentelemetry-instrumentation-redis-4/package.json index b9baf790a9..fb649325a6 100644 --- a/plugins/node/opentelemetry-instrumentation-redis-4/package.json +++ b/plugins/node/opentelemetry-instrumentation-redis-4/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/instrumentation-redis-4", - "version": "0.35.2", + "version": "0.35.3", "description": "Automatic OpenTelemetry instrumentation for redis package version 4", "main": "build/src/index.js", "types": "build/src/index.d.ts", @@ -69,7 +69,7 @@ "typescript": "4.4.4" }, "dependencies": { - "@opentelemetry/instrumentation": "^0.44.0", + "@opentelemetry/instrumentation": "^0.45.0", "@opentelemetry/redis-common": "^0.36.1", "@opentelemetry/semantic-conventions": "^1.0.0" }, diff --git a/plugins/node/opentelemetry-instrumentation-redis/examples/package.json b/plugins/node/opentelemetry-instrumentation-redis/examples/package.json index c5c228182f..250184e651 100644 --- a/plugins/node/opentelemetry-instrumentation-redis/examples/package.json +++ b/plugins/node/opentelemetry-instrumentation-redis/examples/package.json @@ -34,8 +34,8 @@ "@opentelemetry/api": "^1.0.0", "@opentelemetry/exporter-jaeger": "^1.0.0", "@opentelemetry/exporter-zipkin": "^1.0.0", - "@opentelemetry/instrumentation": "^0.44.0", - "@opentelemetry/instrumentation-http": "^0.44.0", + "@opentelemetry/instrumentation": "^0.45.0", + "@opentelemetry/instrumentation-http": "^0.45.0", "@opentelemetry/instrumentation-redis": "^0.32.0", "@opentelemetry/sdk-trace-base": "^1.0.0", "@opentelemetry/sdk-trace-node": "^1.0.0", diff --git a/plugins/node/opentelemetry-instrumentation-redis/package.json b/plugins/node/opentelemetry-instrumentation-redis/package.json index e172524f48..26d35c5271 100644 --- a/plugins/node/opentelemetry-instrumentation-redis/package.json +++ b/plugins/node/opentelemetry-instrumentation-redis/package.json @@ -70,7 +70,7 @@ "@types/redis": "2.8.32" }, "dependencies": { - "@opentelemetry/instrumentation": "^0.44.0", + "@opentelemetry/instrumentation": "^0.45.0", "@opentelemetry/redis-common": "^0.36.1", "@opentelemetry/semantic-conventions": "^1.0.0" }, diff --git a/plugins/node/opentelemetry-instrumentation-restify/package.json b/plugins/node/opentelemetry-instrumentation-restify/package.json index b2f32efaf6..1bac675abc 100644 --- a/plugins/node/opentelemetry-instrumentation-restify/package.json +++ b/plugins/node/opentelemetry-instrumentation-restify/package.json @@ -65,7 +65,7 @@ }, "dependencies": { "@opentelemetry/core": "^1.8.0", - "@opentelemetry/instrumentation": "^0.44.0", + "@opentelemetry/instrumentation": "^0.45.0", "@opentelemetry/semantic-conventions": "^1.0.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-router/package.json b/plugins/node/opentelemetry-instrumentation-router/package.json index fe8f94537c..8191e93bb7 100644 --- a/plugins/node/opentelemetry-instrumentation-router/package.json +++ b/plugins/node/opentelemetry-instrumentation-router/package.json @@ -59,7 +59,7 @@ "typescript": "4.4.4" }, "dependencies": { - "@opentelemetry/instrumentation": "^0.44.0", + "@opentelemetry/instrumentation": "^0.45.0", "@opentelemetry/semantic-conventions": "^1.0.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-winston/package.json b/plugins/node/opentelemetry-instrumentation-winston/package.json index 1f7c27b7ee..27116281c8 100644 --- a/plugins/node/opentelemetry-instrumentation-winston/package.json +++ b/plugins/node/opentelemetry-instrumentation-winston/package.json @@ -66,7 +66,7 @@ "winston2": "npm:winston@2.4.7" }, "dependencies": { - "@opentelemetry/instrumentation": "^0.44.0" + "@opentelemetry/instrumentation": "^0.45.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 3db88c7921..6b4c8dbaa8 100644 --- a/plugins/node/opentelemetry-instrumentation-winston/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-winston/src/instrumentation.ts @@ -16,7 +16,6 @@ import { context, - diag, trace, isSpanContextValid, Span, @@ -57,7 +56,8 @@ export class WinstonInstrumentation extends InstrumentationBase { new InstrumentationNodeModuleFile( 'winston/lib/winston/logger.js', winston3Versions, - logger => { + (logger, moduleVersion) => { + this._diag.debug(`Applying patch for winston@${moduleVersion}`); if (isWrapped(logger.prototype['write'])) { this._unwrap(logger.prototype, 'write'); } @@ -65,8 +65,9 @@ export class WinstonInstrumentation extends InstrumentationBase { this._wrap(logger.prototype, 'write', this._getPatchedWrite()); return logger; }, - logger => { + (logger, moduleVersion) => { if (logger === undefined) return; + this._diag.debug(`Removing patch for winston@${moduleVersion}`); this._unwrap(logger.prototype, 'write'); } ), @@ -81,7 +82,8 @@ export class WinstonInstrumentation extends InstrumentationBase { new InstrumentationNodeModuleFile( 'winston/lib/winston/logger.js', winstonPre3Versions, - fileExports => { + (fileExports, moduleVersion) => { + this._diag.debug(`Applying patch for winston@${moduleVersion}`); const proto = fileExports.Logger.prototype; if (isWrapped(proto.log)) { @@ -92,8 +94,9 @@ export class WinstonInstrumentation extends InstrumentationBase { return fileExports; }, - fileExports => { + (fileExports, moduleVersion) => { if (fileExports === undefined) return; + this._diag.debug(`Removing patch for winston@${moduleVersion}`); this._unwrap(fileExports.Logger.prototype, 'log'); } ), @@ -121,7 +124,7 @@ export class WinstonInstrumentation extends InstrumentationBase { () => hook(span, record), err => { if (err) { - diag.error('winston instrumentation: error calling logHook', err); + this._diag.error('error calling logHook', err); } }, true diff --git a/plugins/web/opentelemetry-instrumentation-document-load/package.json b/plugins/web/opentelemetry-instrumentation-document-load/package.json index cd2498c386..24568a4ebd 100644 --- a/plugins/web/opentelemetry-instrumentation-document-load/package.json +++ b/plugins/web/opentelemetry-instrumentation-document-load/package.json @@ -77,7 +77,7 @@ }, "dependencies": { "@opentelemetry/core": "^1.8.0", - "@opentelemetry/instrumentation": "^0.44.0", + "@opentelemetry/instrumentation": "^0.45.0", "@opentelemetry/sdk-trace-base": "^1.0.0", "@opentelemetry/sdk-trace-web": "^1.15.0", "@opentelemetry/semantic-conventions": "^1.0.0" diff --git a/plugins/web/opentelemetry-instrumentation-long-task/package.json b/plugins/web/opentelemetry-instrumentation-long-task/package.json index 929f4131e4..5b80ffc948 100644 --- a/plugins/web/opentelemetry-instrumentation-long-task/package.json +++ b/plugins/web/opentelemetry-instrumentation-long-task/package.json @@ -78,7 +78,7 @@ }, "dependencies": { "@opentelemetry/core": "^1.8.0", - "@opentelemetry/instrumentation": "^0.44.0", + "@opentelemetry/instrumentation": "^0.45.0", "@opentelemetry/sdk-trace-web": "^1.8.0" }, "peerDependencies": { diff --git a/plugins/web/opentelemetry-instrumentation-user-interaction/package.json b/plugins/web/opentelemetry-instrumentation-user-interaction/package.json index bfefa05e9a..ff7777ec55 100644 --- a/plugins/web/opentelemetry-instrumentation-user-interaction/package.json +++ b/plugins/web/opentelemetry-instrumentation-user-interaction/package.json @@ -50,7 +50,7 @@ "@babel/core": "7.22.17", "@opentelemetry/api": "^1.3.0", "@opentelemetry/context-zone-peer-dep": "^1.8.0", - "@opentelemetry/instrumentation-xml-http-request": "^0.44.0", + "@opentelemetry/instrumentation-xml-http-request": "^0.45.0", "@opentelemetry/sdk-trace-base": "^1.8.0", "@types/jquery": "3.5.20", "@types/mocha": "7.0.2", @@ -80,7 +80,7 @@ }, "dependencies": { "@opentelemetry/core": "^1.8.0", - "@opentelemetry/instrumentation": "^0.44.0", + "@opentelemetry/instrumentation": "^0.45.0", "@opentelemetry/sdk-trace-web": "^1.8.0" }, "peerDependencies": { diff --git a/release-please-config.json b/release-please-config.json index be9ea170ab..e55af5702e 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -8,6 +8,7 @@ "packages": { "detectors/node/opentelemetry-resource-detector-alibaba-cloud": {}, "detectors/node/opentelemetry-resource-detector-aws": {}, + "detectors/node/opentelemetry-resource-detector-azure": {}, "detectors/node/opentelemetry-resource-detector-container": {}, "detectors/node/opentelemetry-resource-detector-gcp": {}, "detectors/node/opentelemetry-resource-detector-github": {},