From 78953064f8bd957649b8052b03debb200784b351 Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Mon, 5 Feb 2024 15:58:34 -0800 Subject: [PATCH 1/9] fix(instr-aws-sdk): @smithy/middleware-stack@2.1.0 change broke aws-sdk-v3 instrumentation (#1913) As of https://github.com/smithy-lang/smithy-typescript/pull/1146 (details at https://github.com/smithy-lang/smithy-typescript/pull/1113) the CommonJS export for many (all?) `@smithy/*` packages is now an esbuild bundle -- all in `dist-cjs/index.js`. That means that subfile patching like this no longer works: ```js const v3SmithyMiddlewareStackFile = new InstrumentationNodeModuleFile( '@smithy/middleware-stack/dist-cjs/MiddlewareStack.js', ['>=1.0.1'], this.patchV3ConstructStack.bind(this), this.unpatchV3ConstructStack.bind(this) ); ``` In our case this breaks as of `@smithy/middleware-stack@2.1.0` released 2024-01-17T22:26:42.432Z. This is considered a non-breaking change, so the dependency ranges for earlier released versions of `@smithy/smithy-client` will pick this up. A fix is to change the `@smithy/middleware-stack` patching to be on the top-level module exports. Because the `constructStack` field is only available as a getter we cannot use shimmer (InstrumentationBase._wrap). Instead this returns a new `moduleExports` object with a new getter that shims the call This PR also updates .tav.yml to reduce the number of aws-sdk package versions tested. --- .../.tav.yml | 6 +- .../src/aws-sdk.ts | 26 +-- .../src/propwrap.ts | 155 ++++++++++++++++++ 3 files changed, 174 insertions(+), 13 deletions(-) create mode 100644 plugins/node/opentelemetry-instrumentation-aws-sdk/src/propwrap.ts diff --git a/plugins/node/opentelemetry-instrumentation-aws-sdk/.tav.yml b/plugins/node/opentelemetry-instrumentation-aws-sdk/.tav.yml index b678e4b15c..0ad091fb0d 100644 --- a/plugins/node/opentelemetry-instrumentation-aws-sdk/.tav.yml +++ b/plugins/node/opentelemetry-instrumentation-aws-sdk/.tav.yml @@ -1,18 +1,18 @@ "aws-sdk": # A small subset of releases in the range [2.308.0, 3) to reduce testing time. - versions: "2.308.0 || 2.548.0 || 2.785.0 || 2.1025.0 || 2.1265.0 || 2.1506.0 || >=2.1508.0" + versions: "2.308.0 || 2.556.0 || 2.801.0 || 2.1049.0 || 2.1297.0 || 2.1546.0 || >=2.1548.0" commands: - npm run test "@aws-sdk/client-s3": # A small subset of releases in the range [3.6.1, 4) to reduce testing time. # - 3.377.0 was a bad release (see issue #1828). - versions: "3.6.1 || 3.53.0 || 3.163.0 || 3.266.0 || 3.354.0 || 3.458.0 || >=3.462.0" + versions: "3.6.1 || 3.55.0 || 3.180.0 || 3.289.0 || 3.385.0 || 3.498.0 || >=3.503.1" commands: - npm run test "@aws-sdk/client-sqs": # A small subset of releases in the range [3.24.0, 4) to reduce testing time. - versions: "3.24.0 || 3.85.0 || 3.194.0 || 3.278.0 || 3.357.0 || 3.461.0 || >=3.462.0" + versions: "3.24.0 || 3.94.0 || 3.202.0 || 3.296.0 || 3.388.0 || 3.496.0 || >=3.503.1" commands: - npm run test diff --git a/plugins/node/opentelemetry-instrumentation-aws-sdk/src/aws-sdk.ts b/plugins/node/opentelemetry-instrumentation-aws-sdk/src/aws-sdk.ts index f07a0795ac..349d2ff388 100644 --- a/plugins/node/opentelemetry-instrumentation-aws-sdk/src/aws-sdk.ts +++ b/plugins/node/opentelemetry-instrumentation-aws-sdk/src/aws-sdk.ts @@ -56,6 +56,7 @@ import { normalizeV3Request, removeSuffixFromStringIfExists, } from './utils'; +import { propwrap } from './propwrap'; import { RequestMetadata } from './services/ServiceExtension'; import { SemanticAttributes } from '@opentelemetry/semantic-conventions'; @@ -112,19 +113,24 @@ export class AwsInstrumentation extends InstrumentationBase { v3MiddlewareStackFileNewVersions, ]); - // patch for @smithy/middleware-stack for aws-sdk packages v3.363.0+ - const v3SmithyMiddlewareStackFile = new InstrumentationNodeModuleFile( - '@smithy/middleware-stack/dist-cjs/MiddlewareStack.js', - ['>=1.0.1'], - this.patchV3ConstructStack.bind(this), - this.unpatchV3ConstructStack.bind(this) - ); + // Patch for @smithy/middleware-stack for @aws-sdk/* packages v3.363.0+. + // As of @smithy/middleware-stack@2.1.0 `constructStack` is only available + // as a getter, so we cannot use `this._wrap()`. + const self = this; const v3SmithyMiddlewareStack = new InstrumentationNodeModuleDefinition( '@smithy/middleware-stack', ['>=2.0.0'], - undefined, - undefined, - [v3SmithyMiddlewareStackFile] + (moduleExports, moduleVersion) => { + const newExports = propwrap( + moduleExports, + 'constructStack', + (orig: any) => { + self._diag.debug('propwrapping aws-sdk v3 constructStack'); + return self._getV3ConstructStackPatch(moduleVersion, orig); + } + ); + return newExports; + } ); const v3SmithyClient = new InstrumentationNodeModuleDefinition( diff --git a/plugins/node/opentelemetry-instrumentation-aws-sdk/src/propwrap.ts b/plugins/node/opentelemetry-instrumentation-aws-sdk/src/propwrap.ts new file mode 100644 index 0000000000..ca59d52c54 --- /dev/null +++ b/plugins/node/opentelemetry-instrumentation-aws-sdk/src/propwrap.ts @@ -0,0 +1,155 @@ +/* + * 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. + */ + +/* + * This block is derived from esbuild's bundling support. + * https://github.com/evanw/esbuild/blob/v0.14.42/internal/runtime/runtime.go#L22 + * + * License: + * MIT License + * + * Copyright (c) 2020 Evan Wallace + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +const __defProp = Object.defineProperty; +const __getOwnPropDesc = Object.getOwnPropertyDescriptor; +const __hasOwnProp = Object.prototype.hasOwnProperty; +const __getOwnPropNames = Object.getOwnPropertyNames; +const __copyProps = ( + to: any, + from: any, + except: string, + desc?: PropertyDescriptor | undefined +) => { + if ((from && typeof from === 'object') || typeof from === 'function') { + for (const key of __getOwnPropNames(from)) { + if (!__hasOwnProp.call(to, key) && key !== except) { + __defProp(to, key, { + get: () => from[key] as any, + enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable, + }); + } + } + } + return to; +}; + +/** + * Return a new object that is a copy of `obj`, with its `subpath` property + * replaced with the return value of `wrapper(original)`. + * + * This is similar to shimmer (i.e. `InstrumentationBase.prototype._wrap`). + * However, it uses a different technique to support wrapping properties that + * are only available via a getter (i.e. their property descriptor is `.writable + * === false`). + * + * For example: + * var os = propwrap(require('os'), 'platform', (orig) => { + * return function wrappedPlatform () { + * return orig().toUpperCase() + * } + * }) + * console.log(os.platform()) // => DARWIN + * + * The subpath can indicate a nested property. Each property in that subpath, + * except the last, must identify an *Object*. + * + * Limitations: + * - This doesn't handle possible Symbol properties on the copied object(s). + * - This cannot wrap a property of a function, because we cannot create a + * copy of the function. + * + * @param {object} obj + * @param {string} subpath - The property subpath on `obj` to wrap. This may + * point to a nested property by using a '.' to separate levels. For example: + * var fs = wrap(fs, 'promises.sync', (orig) => { ... }) + * @param {Function} wrapper - A function of the form `function (orig)`, where + * `orig` is the original property value. This must synchronously return the + * new property value. + * @returns {object} A new object with the wrapped property. + * @throws {TypeError} if the subpath points to a non-existant property, or if + * any but the last subpath part points to a non-Object. + */ +export const propwrap = (obj: any, subpath: string, wrapper: Function): any => { + const parts = subpath.split('.'); + const namespaces = [obj]; + let namespace = obj; + let key; + let val; + + // 1. Traverse the subpath parts to sanity check and get references to the + // Objects that we will be copying. + for (let i = 0; i < parts.length; i++) { + key = parts[i]; + val = namespace[key]; + if (!val) { + throw new TypeError( + `cannot wrap "${subpath}": ".${parts + .slice(0, i) + .join('.')}" is ${typeof val}` + ); + } else if (i < parts.length - 1) { + if (typeof val !== 'object') { + throw new TypeError( + `cannot wrap "${subpath}": ".${parts + .slice(0, i) + .join('.')}" is not an Object` + ); + } + namespace = val; + namespaces.push(namespace); + } + } + + // 2. Now work backwards, wrapping each namespace with a new object that has a + // copy of all the properties, except the one that we've wrapped. + for (let i = parts.length - 1; i >= 0; i--) { + key = parts[i]; + namespace = namespaces[i]; + if (i === parts.length - 1) { + const orig = namespace[key]; + val = wrapper(orig); + } else { + val = namespaces[i + 1]; + } + const desc = __getOwnPropDesc(namespace, key); + const wrappedNamespace = __defProp({}, key, { + value: val, + enumerable: !desc || desc.enumerable, + }); + __copyProps(wrappedNamespace, namespace, key); + namespaces[i] = wrappedNamespace; + } + + return namespaces[0]; +}; From 39c34df61f0e60a93fc787dcfceca9782341b837 Mon Sep 17 00:00:00 2001 From: Daniel Dyla Date: Tue, 6 Feb 2024 08:28:00 -0500 Subject: [PATCH 2/9] chore: release main (#1924) * chore: release main * chore: sync package-lock.json --------- Co-authored-by: opentelemetrybot <107717825+opentelemetrybot@users.noreply.github.com> --- .release-please-manifest.json | 2 +- metapackages/auto-instrumentations-node/CHANGELOG.md | 6 ++++++ metapackages/auto-instrumentations-node/package.json | 4 ++-- package-lock.json | 8 ++++---- .../opentelemetry-instrumentation-aws-sdk/CHANGELOG.md | 7 +++++++ .../opentelemetry-instrumentation-aws-sdk/package.json | 2 +- 6 files changed, 21 insertions(+), 8 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index fb0eec407e..a032f6f827 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1 +1 @@ -{"detectors/node/opentelemetry-resource-detector-alibaba-cloud":"0.28.6","detectors/node/opentelemetry-resource-detector-aws":"1.3.6","detectors/node/opentelemetry-resource-detector-azure":"0.2.4","detectors/node/opentelemetry-resource-detector-container":"0.3.6","detectors/node/opentelemetry-resource-detector-gcp":"0.29.6","detectors/node/opentelemetry-resource-detector-github":"0.28.1","detectors/node/opentelemetry-resource-detector-instana":"0.6.0","metapackages/auto-instrumentations-node":"0.41.0","metapackages/auto-instrumentations-web":"0.36.0","packages/opentelemetry-host-metrics":"0.35.0","packages/opentelemetry-id-generator-aws-xray":"1.2.1","packages/opentelemetry-propagation-utils":"0.30.6","packages/opentelemetry-redis-common":"0.36.1","packages/opentelemetry-sql-common":"0.40.0","packages/opentelemetry-test-utils":"0.36.0","plugins/node/instrumentation-amqplib":"0.34.0","plugins/node/instrumentation-cucumber":"0.3.0","plugins/node/instrumentation-dataloader":"0.6.0","plugins/node/instrumentation-fs":"0.9.0","plugins/node/instrumentation-lru-memoizer":"0.34.0","plugins/node/instrumentation-mongoose":"0.35.0","plugins/node/instrumentation-socket.io":"0.36.0","plugins/node/instrumentation-tedious":"0.7.0","plugins/node/opentelemetry-instrumentation-aws-lambda":"0.38.0","plugins/node/opentelemetry-instrumentation-aws-sdk":"0.38.0","plugins/node/opentelemetry-instrumentation-bunyan":"0.35.0","plugins/node/opentelemetry-instrumentation-cassandra":"0.35.0","plugins/node/opentelemetry-instrumentation-connect":"0.33.0","plugins/node/opentelemetry-instrumentation-dns":"0.33.0","plugins/node/opentelemetry-instrumentation-express":"0.35.0","plugins/node/opentelemetry-instrumentation-fastify":"0.33.0","plugins/node/opentelemetry-instrumentation-generic-pool":"0.33.0","plugins/node/opentelemetry-instrumentation-graphql":"0.37.0","plugins/node/opentelemetry-instrumentation-hapi":"0.34.0","plugins/node/opentelemetry-instrumentation-ioredis":"0.37.0","plugins/node/opentelemetry-instrumentation-knex":"0.33.0","plugins/node/opentelemetry-instrumentation-koa":"0.37.0","plugins/node/opentelemetry-instrumentation-memcached":"0.33.0","plugins/node/opentelemetry-instrumentation-mongodb":"0.39.0","plugins/node/opentelemetry-instrumentation-mysql":"0.35.0","plugins/node/opentelemetry-instrumentation-mysql2":"0.35.0","plugins/node/opentelemetry-instrumentation-nestjs-core":"0.34.0","plugins/node/opentelemetry-instrumentation-net":"0.33.0","plugins/node/opentelemetry-instrumentation-pg":"0.38.0","plugins/node/opentelemetry-instrumentation-pino":"0.35.0","plugins/node/opentelemetry-instrumentation-redis":"0.36.0","plugins/node/opentelemetry-instrumentation-redis-4":"0.36.0","plugins/node/opentelemetry-instrumentation-restify":"0.35.0","plugins/node/opentelemetry-instrumentation-router":"0.34.0","plugins/node/opentelemetry-instrumentation-winston":"0.34.0","plugins/web/opentelemetry-instrumentation-document-load":"0.35.0","plugins/web/opentelemetry-instrumentation-long-task":"0.35.0","plugins/web/opentelemetry-instrumentation-user-interaction":"0.35.0","plugins/web/opentelemetry-plugin-react-load":"0.30.0","propagators/opentelemetry-propagator-aws-xray":"1.3.1","propagators/opentelemetry-propagator-grpc-census-binary":"0.27.1","propagators/opentelemetry-propagator-instana":"0.3.1","propagators/opentelemetry-propagator-ot-trace":"0.27.1"} +{"detectors/node/opentelemetry-resource-detector-alibaba-cloud":"0.28.6","detectors/node/opentelemetry-resource-detector-aws":"1.3.6","detectors/node/opentelemetry-resource-detector-azure":"0.2.4","detectors/node/opentelemetry-resource-detector-container":"0.3.6","detectors/node/opentelemetry-resource-detector-gcp":"0.29.6","detectors/node/opentelemetry-resource-detector-github":"0.28.1","detectors/node/opentelemetry-resource-detector-instana":"0.6.0","metapackages/auto-instrumentations-node":"0.41.1","metapackages/auto-instrumentations-web":"0.36.0","packages/opentelemetry-host-metrics":"0.35.0","packages/opentelemetry-id-generator-aws-xray":"1.2.1","packages/opentelemetry-propagation-utils":"0.30.6","packages/opentelemetry-redis-common":"0.36.1","packages/opentelemetry-sql-common":"0.40.0","packages/opentelemetry-test-utils":"0.36.0","plugins/node/instrumentation-amqplib":"0.34.0","plugins/node/instrumentation-cucumber":"0.3.0","plugins/node/instrumentation-dataloader":"0.6.0","plugins/node/instrumentation-fs":"0.9.0","plugins/node/instrumentation-lru-memoizer":"0.34.0","plugins/node/instrumentation-mongoose":"0.35.0","plugins/node/instrumentation-socket.io":"0.36.0","plugins/node/instrumentation-tedious":"0.7.0","plugins/node/opentelemetry-instrumentation-aws-lambda":"0.38.0","plugins/node/opentelemetry-instrumentation-aws-sdk":"0.38.1","plugins/node/opentelemetry-instrumentation-bunyan":"0.35.0","plugins/node/opentelemetry-instrumentation-cassandra":"0.35.0","plugins/node/opentelemetry-instrumentation-connect":"0.33.0","plugins/node/opentelemetry-instrumentation-dns":"0.33.0","plugins/node/opentelemetry-instrumentation-express":"0.35.0","plugins/node/opentelemetry-instrumentation-fastify":"0.33.0","plugins/node/opentelemetry-instrumentation-generic-pool":"0.33.0","plugins/node/opentelemetry-instrumentation-graphql":"0.37.0","plugins/node/opentelemetry-instrumentation-hapi":"0.34.0","plugins/node/opentelemetry-instrumentation-ioredis":"0.37.0","plugins/node/opentelemetry-instrumentation-knex":"0.33.0","plugins/node/opentelemetry-instrumentation-koa":"0.37.0","plugins/node/opentelemetry-instrumentation-memcached":"0.33.0","plugins/node/opentelemetry-instrumentation-mongodb":"0.39.0","plugins/node/opentelemetry-instrumentation-mysql":"0.35.0","plugins/node/opentelemetry-instrumentation-mysql2":"0.35.0","plugins/node/opentelemetry-instrumentation-nestjs-core":"0.34.0","plugins/node/opentelemetry-instrumentation-net":"0.33.0","plugins/node/opentelemetry-instrumentation-pg":"0.38.0","plugins/node/opentelemetry-instrumentation-pino":"0.35.0","plugins/node/opentelemetry-instrumentation-redis":"0.36.0","plugins/node/opentelemetry-instrumentation-redis-4":"0.36.0","plugins/node/opentelemetry-instrumentation-restify":"0.35.0","plugins/node/opentelemetry-instrumentation-router":"0.34.0","plugins/node/opentelemetry-instrumentation-winston":"0.34.0","plugins/web/opentelemetry-instrumentation-document-load":"0.35.0","plugins/web/opentelemetry-instrumentation-long-task":"0.35.0","plugins/web/opentelemetry-instrumentation-user-interaction":"0.35.0","plugins/web/opentelemetry-plugin-react-load":"0.30.0","propagators/opentelemetry-propagator-aws-xray":"1.3.1","propagators/opentelemetry-propagator-grpc-census-binary":"0.27.1","propagators/opentelemetry-propagator-instana":"0.3.1","propagators/opentelemetry-propagator-ot-trace":"0.27.1"} diff --git a/metapackages/auto-instrumentations-node/CHANGELOG.md b/metapackages/auto-instrumentations-node/CHANGELOG.md index 582aaa6ec5..1213b52c86 100644 --- a/metapackages/auto-instrumentations-node/CHANGELOG.md +++ b/metapackages/auto-instrumentations-node/CHANGELOG.md @@ -146,6 +146,12 @@ * @opentelemetry/instrumentation-net bumped from ^0.32.3 to ^0.32.4 * @opentelemetry/instrumentation-pino bumped from ^0.34.3 to ^0.34.4 +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * @opentelemetry/instrumentation-aws-sdk bumped from ^0.38.0 to ^0.38.1 + ## [0.41.0](https://github.com/open-telemetry/opentelemetry-js-contrib/compare/auto-instrumentations-node-v0.40.3...auto-instrumentations-node-v0.41.0) (2024-01-29) diff --git a/metapackages/auto-instrumentations-node/package.json b/metapackages/auto-instrumentations-node/package.json index ef6a6b8496..543972e5e7 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.41.0", + "version": "0.41.1", "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", @@ -52,7 +52,7 @@ "@opentelemetry/instrumentation": "^0.48.0", "@opentelemetry/instrumentation-amqplib": "^0.34.0", "@opentelemetry/instrumentation-aws-lambda": "^0.38.0", - "@opentelemetry/instrumentation-aws-sdk": "^0.38.0", + "@opentelemetry/instrumentation-aws-sdk": "^0.38.1", "@opentelemetry/instrumentation-bunyan": "^0.35.0", "@opentelemetry/instrumentation-cassandra-driver": "^0.35.0", "@opentelemetry/instrumentation-connect": "^0.33.0", diff --git a/package-lock.json b/package-lock.json index 32cfa670d2..2ae8e72eea 100644 --- a/package-lock.json +++ b/package-lock.json @@ -277,13 +277,13 @@ }, "metapackages/auto-instrumentations-node": { "name": "@opentelemetry/auto-instrumentations-node", - "version": "0.41.0", + "version": "0.41.1", "license": "Apache-2.0", "dependencies": { "@opentelemetry/instrumentation": "^0.48.0", "@opentelemetry/instrumentation-amqplib": "^0.34.0", "@opentelemetry/instrumentation-aws-lambda": "^0.38.0", - "@opentelemetry/instrumentation-aws-sdk": "^0.38.0", + "@opentelemetry/instrumentation-aws-sdk": "^0.38.1", "@opentelemetry/instrumentation-bunyan": "^0.35.0", "@opentelemetry/instrumentation-cassandra-driver": "^0.35.0", "@opentelemetry/instrumentation-connect": "^0.33.0", @@ -34634,7 +34634,7 @@ }, "plugins/node/opentelemetry-instrumentation-aws-sdk": { "name": "@opentelemetry/instrumentation-aws-sdk", - "version": "0.38.0", + "version": "0.38.1", "license": "Apache-2.0", "dependencies": { "@opentelemetry/core": "^1.8.0", @@ -43440,7 +43440,7 @@ "@opentelemetry/instrumentation": "^0.48.0", "@opentelemetry/instrumentation-amqplib": "^0.34.0", "@opentelemetry/instrumentation-aws-lambda": "^0.38.0", - "@opentelemetry/instrumentation-aws-sdk": "^0.38.0", + "@opentelemetry/instrumentation-aws-sdk": "^0.38.1", "@opentelemetry/instrumentation-bunyan": "^0.35.0", "@opentelemetry/instrumentation-cassandra-driver": "^0.35.0", "@opentelemetry/instrumentation-connect": "^0.33.0", diff --git a/plugins/node/opentelemetry-instrumentation-aws-sdk/CHANGELOG.md b/plugins/node/opentelemetry-instrumentation-aws-sdk/CHANGELOG.md index 5e63e8366c..d27cdbf6ce 100644 --- a/plugins/node/opentelemetry-instrumentation-aws-sdk/CHANGELOG.md +++ b/plugins/node/opentelemetry-instrumentation-aws-sdk/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [0.38.1](https://github.com/open-telemetry/opentelemetry-js-contrib/compare/instrumentation-aws-sdk-v0.38.0...instrumentation-aws-sdk-v0.38.1) (2024-02-06) + + +### Bug Fixes + +* **instr-aws-sdk:** @smithy/middleware-stack@2.1.0 change broke aws-sdk-v3 instrumentation ([#1913](https://github.com/open-telemetry/opentelemetry-js-contrib/issues/1913)) ([7895306](https://github.com/open-telemetry/opentelemetry-js-contrib/commit/78953064f8bd957649b8052b03debb200784b351)) + ## [0.38.0](https://github.com/open-telemetry/opentelemetry-js-contrib/compare/instrumentation-aws-sdk-v0.37.2...instrumentation-aws-sdk-v0.38.0) (2024-01-29) diff --git a/plugins/node/opentelemetry-instrumentation-aws-sdk/package.json b/plugins/node/opentelemetry-instrumentation-aws-sdk/package.json index 5328e01778..1cf2456f8a 100644 --- a/plugins/node/opentelemetry-instrumentation-aws-sdk/package.json +++ b/plugins/node/opentelemetry-instrumentation-aws-sdk/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/instrumentation-aws-sdk", - "version": "0.38.0", + "version": "0.38.1", "description": "OpenTelemetry automatic instrumentation for the `aws-sdk` package", "keywords": [ "aws", From cf034c8ab76e413dd3901d9f0e68693dbd18f496 Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Tue, 13 Feb 2024 04:27:16 -0800 Subject: [PATCH 3/9] chore: add non-releasing packages to release-please config so their local deps get bumped (#1928) * chore: add unreleasing packages to release-please config so their local deps get bumped This is option 1 from #1917. Refs: https://github.com/open-telemetry/opentelemetry-js-contrib/issues/1917 * drop commented out debug output --- release-please-config.json | 7 +++++ scripts/check-release-please.mjs | 49 +++++++++++++++++++------------- 2 files changed, 36 insertions(+), 20 deletions(-) diff --git a/release-please-config.json b/release-please-config.json index e55af5702e..344b719ca6 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -21,6 +21,7 @@ "packages/opentelemetry-redis-common": {}, "packages/opentelemetry-sql-common": {}, "packages/opentelemetry-test-utils": {}, + "packages/opentelemetry-sampler-aws-xray": { "skip-github-release": true }, "plugins/node/instrumentation-amqplib": {}, "plugins/node/instrumentation-cucumber": {}, "plugins/node/instrumentation-dataloader": {}, @@ -32,10 +33,12 @@ "plugins/node/opentelemetry-instrumentation-aws-lambda": {}, "plugins/node/opentelemetry-instrumentation-aws-sdk": {}, "plugins/node/opentelemetry-instrumentation-bunyan": {}, + "plugins/node/opentelemetry-instrumentation-bunyan/examples": { "skip-github-release": true }, "plugins/node/opentelemetry-instrumentation-cassandra": {}, "plugins/node/opentelemetry-instrumentation-connect": {}, "plugins/node/opentelemetry-instrumentation-dns": {}, "plugins/node/opentelemetry-instrumentation-express": {}, + "plugins/node/opentelemetry-instrumentation-express/examples": { "skip-github-release": true }, "plugins/node/opentelemetry-instrumentation-fastify": {}, "plugins/node/opentelemetry-instrumentation-generic-pool": {}, "plugins/node/opentelemetry-instrumentation-graphql": {}, @@ -43,15 +46,19 @@ "plugins/node/opentelemetry-instrumentation-ioredis": {}, "plugins/node/opentelemetry-instrumentation-knex": {}, "plugins/node/opentelemetry-instrumentation-koa": {}, + "plugins/node/opentelemetry-instrumentation-koa/examples": { "skip-github-release": true }, "plugins/node/opentelemetry-instrumentation-memcached": {}, "plugins/node/opentelemetry-instrumentation-mongodb": {}, + "plugins/node/opentelemetry-instrumentation-mongodb/examples": { "skip-github-release": true }, "plugins/node/opentelemetry-instrumentation-mysql": {}, + "plugins/node/opentelemetry-instrumentation-mysql/examples": { "skip-github-release": true }, "plugins/node/opentelemetry-instrumentation-mysql2": {}, "plugins/node/opentelemetry-instrumentation-nestjs-core": {}, "plugins/node/opentelemetry-instrumentation-net": {}, "plugins/node/opentelemetry-instrumentation-pg": {}, "plugins/node/opentelemetry-instrumentation-pino": {}, "plugins/node/opentelemetry-instrumentation-redis": {}, + "plugins/node/opentelemetry-instrumentation-redis/examples": { "skip-github-release": true }, "plugins/node/opentelemetry-instrumentation-redis-4": {}, "plugins/node/opentelemetry-instrumentation-restify": {}, "plugins/node/opentelemetry-instrumentation-router": {}, diff --git a/scripts/check-release-please.mjs b/scripts/check-release-please.mjs index 699133c35d..37c64f2e67 100644 --- a/scripts/check-release-please.mjs +++ b/scripts/check-release-please.mjs @@ -29,35 +29,44 @@ const getProcessOutput = (cmd, args) => { return result.stdout.toString('utf8'); } -const lernaList = JSON.parse( - getProcessOutput('npx', ['lerna', 'list', '--json']) -); +const lernaList = JSON + .parse(getProcessOutput('npx', ['lerna', 'list', '--json', '-a'])) + .map((pkgInfo) => { + pkgInfo.relativeLocation = path.relative(PROJECT_ROOT, pkgInfo.location); + return pkgInfo; + }); const manifest = readJson('.release-please-manifest.json'); const config = readJson('release-please-config.json'); const lernaPackages = new Set( - lernaList.map((pkg) => { - return path.relative(PROJECT_ROOT, pkg.location); - }) + lernaList.map((pkgInfo) => pkgInfo.relativeLocation) ); const manifestPackages = new Set(Object.keys(manifest)); const configPackages = new Set(Object.keys(config.packages)); -console.log('lerna packages', lernaPackages); -console.log('manifest packages', manifestPackages); -console.log('config packages', configPackages); - -lernaPackages.forEach((relativeLocation) => { - logErrorIf( - !manifestPackages.has(relativeLocation), - `Could not find ${relativeLocation} in .release-please-manifest.json. If you are adding a new package. Add following - "${relativeLocation}": "0.0.1",`); - - logErrorIf( - !configPackages.has(relativeLocation), - `Could not find ${relativeLocation} in release-please-config.json. If you are adding a new package. Add following to "packages" object - "${relativeLocation}": {},`); +lernaList.forEach((pkgInfo) => { + const relativeLocation = pkgInfo.relativeLocation + if (pkgInfo.private) { + // Should be in config, with `skip-github-release` option. + const configEntry = config.packages[relativeLocation] + if (!configEntry) { + errors.push(`Could not find "${relativeLocation}" entry in release-please-config.json. If you are adding a new package. Add following to "packages" object: + "${relativeLocation}": { "skip-github-release": true },`); + } else if (configEntry['skip-github-release'] !== true) { + errors.push(`The "${relativeLocation}" entry in release-please-config.json should have the '"skip-github-release": true' option`); + } + } else { + // Should be in manifest and config. + logErrorIf( + !manifestPackages.has(relativeLocation), + `Could not find "${relativeLocation}" entry in .release-please-manifest.json. If you are adding a new package. Add following + "${relativeLocation}": "0.0.1",`); + logErrorIf( + !configPackages.has(relativeLocation), + `Could not find "${relativeLocation}" entry in release-please-config.json. If you are adding a new package. Add following to "packages" object + "${relativeLocation}": {},`); + } }); manifestPackages.forEach((relativeLocation) => { From f4e6f11d0025e585a3f16b0ff0ba096e104debba Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Thu, 15 Feb 2024 01:09:32 -0800 Subject: [PATCH 4/9] chore: add trentm as a component owner of instr-bunyan (#1941) --- .github/component_owners.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/component_owners.yml b/.github/component_owners.yml index a9da78fd32..4ee43d769d 100644 --- a/.github/component_owners.yml +++ b/.github/component_owners.yml @@ -63,6 +63,7 @@ components: - blumamir plugins/node/opentelemetry-instrumentation-bunyan: - seemk + - trentm plugins/node/opentelemetry-instrumentation-cassandra: - seemk plugins/node/opentelemetry-instrumentation-connect: [] @@ -115,7 +116,7 @@ components: - seemk plugins/web/opentelemetry-instrumentation-document-load: - pkanal - - martinkuba + - martinkuba plugins/web/opentelemetry-instrumentation-long-task: - mhennoch - t2t2 From dbf2c96469cd4fadb5926144d5dfc3f0e1faa986 Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Thu, 15 Feb 2024 05:07:18 -0800 Subject: [PATCH 5/9] chore: attempt to prevent non-releasing packages from being included in release-please release PRs (#1939) This continues on from #1928. The non-releasing packages are being added to the release-please manifest in the hope that this prevents them from being listed in the set of released packages in a release-please PR. This is effectively Option 1b from #1917. Co-authored-by: Marc Pichler --- .release-please-manifest.json | 2 +- .../opentelemetry-instrumentation-bunyan/examples/package.json | 2 +- .../opentelemetry-instrumentation-express/examples/package.json | 2 +- .../opentelemetry-instrumentation-koa/examples/package.json | 2 +- .../opentelemetry-instrumentation-mongodb/examples/package.json | 2 +- .../opentelemetry-instrumentation-mysql/examples/package.json | 2 +- .../opentelemetry-instrumentation-redis/examples/package.json | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index a032f6f827..78f2d84c83 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1 +1 @@ -{"detectors/node/opentelemetry-resource-detector-alibaba-cloud":"0.28.6","detectors/node/opentelemetry-resource-detector-aws":"1.3.6","detectors/node/opentelemetry-resource-detector-azure":"0.2.4","detectors/node/opentelemetry-resource-detector-container":"0.3.6","detectors/node/opentelemetry-resource-detector-gcp":"0.29.6","detectors/node/opentelemetry-resource-detector-github":"0.28.1","detectors/node/opentelemetry-resource-detector-instana":"0.6.0","metapackages/auto-instrumentations-node":"0.41.1","metapackages/auto-instrumentations-web":"0.36.0","packages/opentelemetry-host-metrics":"0.35.0","packages/opentelemetry-id-generator-aws-xray":"1.2.1","packages/opentelemetry-propagation-utils":"0.30.6","packages/opentelemetry-redis-common":"0.36.1","packages/opentelemetry-sql-common":"0.40.0","packages/opentelemetry-test-utils":"0.36.0","plugins/node/instrumentation-amqplib":"0.34.0","plugins/node/instrumentation-cucumber":"0.3.0","plugins/node/instrumentation-dataloader":"0.6.0","plugins/node/instrumentation-fs":"0.9.0","plugins/node/instrumentation-lru-memoizer":"0.34.0","plugins/node/instrumentation-mongoose":"0.35.0","plugins/node/instrumentation-socket.io":"0.36.0","plugins/node/instrumentation-tedious":"0.7.0","plugins/node/opentelemetry-instrumentation-aws-lambda":"0.38.0","plugins/node/opentelemetry-instrumentation-aws-sdk":"0.38.1","plugins/node/opentelemetry-instrumentation-bunyan":"0.35.0","plugins/node/opentelemetry-instrumentation-cassandra":"0.35.0","plugins/node/opentelemetry-instrumentation-connect":"0.33.0","plugins/node/opentelemetry-instrumentation-dns":"0.33.0","plugins/node/opentelemetry-instrumentation-express":"0.35.0","plugins/node/opentelemetry-instrumentation-fastify":"0.33.0","plugins/node/opentelemetry-instrumentation-generic-pool":"0.33.0","plugins/node/opentelemetry-instrumentation-graphql":"0.37.0","plugins/node/opentelemetry-instrumentation-hapi":"0.34.0","plugins/node/opentelemetry-instrumentation-ioredis":"0.37.0","plugins/node/opentelemetry-instrumentation-knex":"0.33.0","plugins/node/opentelemetry-instrumentation-koa":"0.37.0","plugins/node/opentelemetry-instrumentation-memcached":"0.33.0","plugins/node/opentelemetry-instrumentation-mongodb":"0.39.0","plugins/node/opentelemetry-instrumentation-mysql":"0.35.0","plugins/node/opentelemetry-instrumentation-mysql2":"0.35.0","plugins/node/opentelemetry-instrumentation-nestjs-core":"0.34.0","plugins/node/opentelemetry-instrumentation-net":"0.33.0","plugins/node/opentelemetry-instrumentation-pg":"0.38.0","plugins/node/opentelemetry-instrumentation-pino":"0.35.0","plugins/node/opentelemetry-instrumentation-redis":"0.36.0","plugins/node/opentelemetry-instrumentation-redis-4":"0.36.0","plugins/node/opentelemetry-instrumentation-restify":"0.35.0","plugins/node/opentelemetry-instrumentation-router":"0.34.0","plugins/node/opentelemetry-instrumentation-winston":"0.34.0","plugins/web/opentelemetry-instrumentation-document-load":"0.35.0","plugins/web/opentelemetry-instrumentation-long-task":"0.35.0","plugins/web/opentelemetry-instrumentation-user-interaction":"0.35.0","plugins/web/opentelemetry-plugin-react-load":"0.30.0","propagators/opentelemetry-propagator-aws-xray":"1.3.1","propagators/opentelemetry-propagator-grpc-census-binary":"0.27.1","propagators/opentelemetry-propagator-instana":"0.3.1","propagators/opentelemetry-propagator-ot-trace":"0.27.1"} +{"detectors/node/opentelemetry-resource-detector-alibaba-cloud":"0.28.6","detectors/node/opentelemetry-resource-detector-aws":"1.3.6","detectors/node/opentelemetry-resource-detector-azure":"0.2.4","detectors/node/opentelemetry-resource-detector-container":"0.3.6","detectors/node/opentelemetry-resource-detector-gcp":"0.29.6","detectors/node/opentelemetry-resource-detector-github":"0.28.1","detectors/node/opentelemetry-resource-detector-instana":"0.6.0","metapackages/auto-instrumentations-node":"0.41.1","metapackages/auto-instrumentations-web":"0.36.0","packages/opentelemetry-host-metrics":"0.35.0","packages/opentelemetry-id-generator-aws-xray":"1.2.1","packages/opentelemetry-propagation-utils":"0.30.6","packages/opentelemetry-redis-common":"0.36.1","packages/opentelemetry-sampler-aws-xray":"0.34.0","packages/opentelemetry-sql-common":"0.40.0","packages/opentelemetry-test-utils":"0.36.0","plugins/node/instrumentation-amqplib":"0.34.0","plugins/node/instrumentation-cucumber":"0.3.0","plugins/node/instrumentation-dataloader":"0.6.0","plugins/node/instrumentation-fs":"0.9.0","plugins/node/instrumentation-lru-memoizer":"0.34.0","plugins/node/instrumentation-mongoose":"0.35.0","plugins/node/instrumentation-socket.io":"0.36.0","plugins/node/instrumentation-tedious":"0.7.0","plugins/node/opentelemetry-instrumentation-aws-lambda":"0.38.0","plugins/node/opentelemetry-instrumentation-aws-sdk":"0.38.1","plugins/node/opentelemetry-instrumentation-bunyan":"0.35.0","plugins/node/opentelemetry-instrumentation-bunyan/examples":"0.1.0","plugins/node/opentelemetry-instrumentation-cassandra":"0.35.0","plugins/node/opentelemetry-instrumentation-connect":"0.33.0","plugins/node/opentelemetry-instrumentation-dns":"0.33.0","plugins/node/opentelemetry-instrumentation-express":"0.35.0","plugins/node/opentelemetry-instrumentation-express/examples":"0.1.0","plugins/node/opentelemetry-instrumentation-fastify":"0.33.0","plugins/node/opentelemetry-instrumentation-generic-pool":"0.33.0","plugins/node/opentelemetry-instrumentation-graphql":"0.37.0","plugins/node/opentelemetry-instrumentation-hapi":"0.34.0","plugins/node/opentelemetry-instrumentation-ioredis":"0.37.0","plugins/node/opentelemetry-instrumentation-knex":"0.33.0","plugins/node/opentelemetry-instrumentation-koa":"0.37.0","plugins/node/opentelemetry-instrumentation-koa/examples":"0.1.0","plugins/node/opentelemetry-instrumentation-memcached":"0.33.0","plugins/node/opentelemetry-instrumentation-mongodb":"0.39.0","plugins/node/opentelemetry-instrumentation-mongodb/examples":"0.1.0","plugins/node/opentelemetry-instrumentation-mysql":"0.35.0","plugins/node/opentelemetry-instrumentation-mysql/examples":"0.1.0","plugins/node/opentelemetry-instrumentation-mysql2":"0.35.0","plugins/node/opentelemetry-instrumentation-nestjs-core":"0.34.0","plugins/node/opentelemetry-instrumentation-net":"0.33.0","plugins/node/opentelemetry-instrumentation-pg":"0.38.0","plugins/node/opentelemetry-instrumentation-pino":"0.35.0","plugins/node/opentelemetry-instrumentation-redis":"0.36.0","plugins/node/opentelemetry-instrumentation-redis/examples":"0.1.0","plugins/node/opentelemetry-instrumentation-redis-4":"0.36.0","plugins/node/opentelemetry-instrumentation-restify":"0.35.0","plugins/node/opentelemetry-instrumentation-router":"0.34.0","plugins/node/opentelemetry-instrumentation-winston":"0.34.0","plugins/web/opentelemetry-instrumentation-document-load":"0.35.0","plugins/web/opentelemetry-instrumentation-long-task":"0.35.0","plugins/web/opentelemetry-instrumentation-user-interaction":"0.35.0","plugins/web/opentelemetry-plugin-react-load":"0.30.0","propagators/opentelemetry-propagator-aws-xray":"1.3.1","propagators/opentelemetry-propagator-grpc-census-binary":"0.27.1","propagators/opentelemetry-propagator-instana":"0.3.1","propagators/opentelemetry-propagator-ot-trace":"0.27.1"} diff --git a/plugins/node/opentelemetry-instrumentation-bunyan/examples/package.json b/plugins/node/opentelemetry-instrumentation-bunyan/examples/package.json index 3d462127b7..f099d529cf 100644 --- a/plugins/node/opentelemetry-instrumentation-bunyan/examples/package.json +++ b/plugins/node/opentelemetry-instrumentation-bunyan/examples/package.json @@ -1,7 +1,7 @@ { "name": "bunyan-example", "private": true, - "version": "0.45.1", + "version": "0.1.0", "description": "Example of Bunyan integration with OpenTelemetry", "scripts": { "start": "node -r ./telemetry.js app.js" diff --git a/plugins/node/opentelemetry-instrumentation-express/examples/package.json b/plugins/node/opentelemetry-instrumentation-express/examples/package.json index ff8807f43e..bc98d21c86 100644 --- a/plugins/node/opentelemetry-instrumentation-express/examples/package.json +++ b/plugins/node/opentelemetry-instrumentation-express/examples/package.json @@ -1,7 +1,7 @@ { "name": "express-example", "private": true, - "version": "0.34.1", + "version": "0.1.0", "description": "Example of Express integration with OpenTelemetry", "scripts": { "zipkin:server": "cross-env EXPORTER=zipkin ts-node src/server.ts", diff --git a/plugins/node/opentelemetry-instrumentation-koa/examples/package.json b/plugins/node/opentelemetry-instrumentation-koa/examples/package.json index b7e6336291..4ae14fe391 100644 --- a/plugins/node/opentelemetry-instrumentation-koa/examples/package.json +++ b/plugins/node/opentelemetry-instrumentation-koa/examples/package.json @@ -1,7 +1,7 @@ { "name": "koa-example", "private": true, - "version": "0.23.0", + "version": "0.1.0", "description": "Example of Koa and @koa/router integration with OpenTelemetry", "main": "index.js", "scripts": { diff --git a/plugins/node/opentelemetry-instrumentation-mongodb/examples/package.json b/plugins/node/opentelemetry-instrumentation-mongodb/examples/package.json index a359d0798e..f96cd0feb2 100644 --- a/plugins/node/opentelemetry-instrumentation-mongodb/examples/package.json +++ b/plugins/node/opentelemetry-instrumentation-mongodb/examples/package.json @@ -1,7 +1,7 @@ { "name": "mongodb-example", "private": true, - "version": "0.28.0", + "version": "0.1.0", "description": "Example of mongodb integration with OpenTelemetry", "main": "index.js", "scripts": { diff --git a/plugins/node/opentelemetry-instrumentation-mysql/examples/package.json b/plugins/node/opentelemetry-instrumentation-mysql/examples/package.json index 7f6547db20..f71806034f 100644 --- a/plugins/node/opentelemetry-instrumentation-mysql/examples/package.json +++ b/plugins/node/opentelemetry-instrumentation-mysql/examples/package.json @@ -1,7 +1,7 @@ { "name": "mysql-example", "private": true, - "version": "0.23.0", + "version": "0.1.0", "description": "Example of mysql integration with OpenTelemetry", "main": "index.js", "scripts": { diff --git a/plugins/node/opentelemetry-instrumentation-redis/examples/package.json b/plugins/node/opentelemetry-instrumentation-redis/examples/package.json index e79802666e..dabe68618f 100644 --- a/plugins/node/opentelemetry-instrumentation-redis/examples/package.json +++ b/plugins/node/opentelemetry-instrumentation-redis/examples/package.json @@ -1,7 +1,7 @@ { "name": "redis-example", "private": true, - "version": "0.23.0", + "version": "0.1.0", "description": "Example of HTTP integration with OpenTelemetry", "main": "index.js", "scripts": { From 5b0b67feb9fec8c2a96010f24b27663e80ae2bb3 Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Thu, 15 Feb 2024 05:08:53 -0800 Subject: [PATCH 6/9] docs(instr-bunyan): fix bug in README example (#1940) Co-authored-by: Marc Pichler --- plugins/node/opentelemetry-instrumentation-bunyan/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/node/opentelemetry-instrumentation-bunyan/README.md b/plugins/node/opentelemetry-instrumentation-bunyan/README.md index c12b489658..5706fe8fe2 100644 --- a/plugins/node/opentelemetry-instrumentation-bunyan/README.md +++ b/plugins/node/opentelemetry-instrumentation-bunyan/README.md @@ -33,6 +33,7 @@ const sdk = new NodeSDK({ }), ] }) +sdk.start(); const bunyan = require('bunyan'); const logger = bunyan.createLogger({name: 'example'}); From 038e0bfda951055ce91724a3b4a3042a9f918700 Mon Sep 17 00:00:00 2001 From: Endre Sara Date: Mon, 19 Feb 2024 03:42:00 -0500 Subject: [PATCH 7/9] fix(net.peer.port): net.peer.port needs to be a number not a string (#1916) Signed-off-by: esara --- .../src/utils.ts | 16 ++++++++++++---- .../test/index.test.ts | 4 +++- .../src/instrumentation.ts | 9 +++++---- .../test/mongodb-v3.test.ts | 6 ++++-- .../test/mongodb-v4-v5-v6.metrics.test.ts | 2 +- .../test/mongodb-v4.test.ts | 2 +- .../test/mongodb-v5-v6.test.ts | 2 +- .../src/utils.ts | 16 ++++++++++++++-- .../src/utils.ts | 16 ++++++++++++++-- 9 files changed, 55 insertions(+), 18 deletions(-) diff --git a/plugins/node/opentelemetry-instrumentation-memcached/src/utils.ts b/plugins/node/opentelemetry-instrumentation-memcached/src/utils.ts index aa49f6c357..4cebd4112e 100644 --- a/plugins/node/opentelemetry-instrumentation-memcached/src/utils.ts +++ b/plugins/node/opentelemetry-instrumentation-memcached/src/utils.ts @@ -45,10 +45,18 @@ export const getPeerAttributes = ( if (typeof server === 'string') { const [host, port] = server && server.split(':'); - return { - [SemanticAttributes.NET_PEER_NAME]: host, - [SemanticAttributes.NET_PEER_PORT]: port, - }; + if (host && port) { + const portNumber = parseInt(port, 10); + if (!isNaN(portNumber)) { + return { + [SemanticAttributes.NET_PEER_NAME]: host, + [SemanticAttributes.NET_PEER_PORT]: portNumber, + }; + } + return { + [SemanticAttributes.NET_PEER_NAME]: host, + }; + } } return {}; }; diff --git a/plugins/node/opentelemetry-instrumentation-memcached/test/index.test.ts b/plugins/node/opentelemetry-instrumentation-memcached/test/index.test.ts index 01f116d0fc..bdff8e4279 100644 --- a/plugins/node/opentelemetry-instrumentation-memcached/test/index.test.ts +++ b/plugins/node/opentelemetry-instrumentation-memcached/test/index.test.ts @@ -36,7 +36,9 @@ const memoryExporter = new InMemorySpanExporter(); const CONFIG = { host: process.env.OPENTELEMETRY_MEMCACHED_HOST || 'localhost', - port: process.env.OPENTELEMETRY_MEMCACHED_PORT || '11211', + port: process.env.OPENTELEMETRY_MEMCACHED_PORT + ? parseInt(process.env.OPENTELEMETRY_MEMCACHED_PORT) + : 27017, }; const DEFAULT_ATTRIBUTES = { diff --git a/plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts index 3be3019848..02af814bf2 100644 --- a/plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts @@ -813,10 +813,11 @@ export class MongoDBInstrumentation extends InstrumentationBase { }); if (host && port) { - span.setAttributes({ - [SemanticAttributes.NET_PEER_NAME]: host, - [SemanticAttributes.NET_PEER_PORT]: port, - }); + span.setAttribute(SemanticAttributes.NET_PEER_NAME, host); + const portNumber = parseInt(port, 10); + if (!isNaN(portNumber)) { + span.setAttribute(SemanticAttributes.NET_PEER_PORT, portNumber); + } } if (!commandObj) return; const dbStatementSerializer = diff --git a/plugins/node/opentelemetry-instrumentation-mongodb/test/mongodb-v3.test.ts b/plugins/node/opentelemetry-instrumentation-mongodb/test/mongodb-v3.test.ts index a8f0444839..938c00875a 100644 --- a/plugins/node/opentelemetry-instrumentation-mongodb/test/mongodb-v3.test.ts +++ b/plugins/node/opentelemetry-instrumentation-mongodb/test/mongodb-v3.test.ts @@ -49,7 +49,7 @@ describe('MongoDBInstrumentation-Tracing-v3', () => { } const URL = `mongodb://${process.env.MONGODB_HOST || DEFAULT_MONGO_HOST}:${ - process.env.MONGODB_PORT || '27017' + process.env.MONGODB_PORT || 27017 }`; const DB_NAME = process.env.MONGODB_DB || 'opentelemetry-tests'; const COLLECTION_NAME = 'test'; @@ -585,7 +585,9 @@ describe('MongoDBInstrumentation-Tracing-v3', () => { ); assert.strictEqual( mongoSpan.attributes[SemanticAttributes.NET_PEER_PORT], - process.env.MONGODB_PORT || '27017' + process.env.MONGODB_PORT + ? parseInt(process.env.MONGODB_PORT) + : 27017 ); done(); } diff --git a/plugins/node/opentelemetry-instrumentation-mongodb/test/mongodb-v4-v5-v6.metrics.test.ts b/plugins/node/opentelemetry-instrumentation-mongodb/test/mongodb-v4-v5-v6.metrics.test.ts index 189ff458d6..eb8d3b3946 100644 --- a/plugins/node/opentelemetry-instrumentation-mongodb/test/mongodb-v4-v5-v6.metrics.test.ts +++ b/plugins/node/opentelemetry-instrumentation-mongodb/test/mongodb-v4-v5-v6.metrics.test.ts @@ -76,7 +76,7 @@ describe('MongoDBInstrumentation-Metrics', () => { } const HOST = process.env.MONGODB_HOST || DEFAULT_MONGO_HOST; - const PORT = process.env.MONGODB_PORT || '27017'; + const PORT = process.env.MONGODB_PORT || 27017; const DB_NAME = process.env.MONGODB_DB || 'opentelemetry-tests-metrics'; const COLLECTION_NAME = 'test-metrics'; const URL = `mongodb://${HOST}:${PORT}/${DB_NAME}`; 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 724e33cffd..7fb8dc4fca 100644 --- a/plugins/node/opentelemetry-instrumentation-mongodb/test/mongodb-v4.test.ts +++ b/plugins/node/opentelemetry-instrumentation-mongodb/test/mongodb-v4.test.ts @@ -51,7 +51,7 @@ describe('MongoDBInstrumentation-Tracing-v4', () => { } const HOST = process.env.MONGODB_HOST || DEFAULT_MONGO_HOST; - const PORT = process.env.MONGODB_PORT || '27017'; + const PORT = process.env.MONGODB_PORT || 27017; const DB_NAME = process.env.MONGODB_DB || 'opentelemetry-tests-traces'; const COLLECTION_NAME = 'test-traces'; const URL = `mongodb://${HOST}:${PORT}/${DB_NAME}`; diff --git a/plugins/node/opentelemetry-instrumentation-mongodb/test/mongodb-v5-v6.test.ts b/plugins/node/opentelemetry-instrumentation-mongodb/test/mongodb-v5-v6.test.ts index e9f80ad6c5..b264a44efe 100644 --- a/plugins/node/opentelemetry-instrumentation-mongodb/test/mongodb-v5-v6.test.ts +++ b/plugins/node/opentelemetry-instrumentation-mongodb/test/mongodb-v5-v6.test.ts @@ -60,7 +60,7 @@ describe('MongoDBInstrumentation-Tracing-v5', () => { } const HOST = process.env.MONGODB_HOST || DEFAULT_MONGO_HOST; - const PORT = process.env.MONGODB_PORT || '27017'; + const PORT = process.env.MONGODB_PORT || 27017; const DB_NAME = process.env.MONGODB_DB || 'opentelemetry-tests-traces'; const COLLECTION_NAME = 'test-traces'; const URL = `mongodb://${HOST}:${PORT}/${DB_NAME}`; diff --git a/plugins/node/opentelemetry-instrumentation-mysql/src/utils.ts b/plugins/node/opentelemetry-instrumentation-mysql/src/utils.ts index 9eb7e90827..05eb1d809f 100644 --- a/plugins/node/opentelemetry-instrumentation-mysql/src/utils.ts +++ b/plugins/node/opentelemetry-instrumentation-mysql/src/utils.ts @@ -33,10 +33,22 @@ export function getConnectionAttributes( config: ConnectionConfig | PoolActualConfig ): SpanAttributes { const { host, port, database, user } = getConfig(config); - + const portNumber = parseInt(port, 10); + if (!isNaN(portNumber)) { + return { + [SemanticAttributes.NET_PEER_NAME]: host, + [SemanticAttributes.NET_PEER_PORT]: portNumber, + [SemanticAttributes.DB_CONNECTION_STRING]: getJDBCString( + host, + port, + database + ), + [SemanticAttributes.DB_NAME]: database, + [SemanticAttributes.DB_USER]: user, + }; + } return { [SemanticAttributes.NET_PEER_NAME]: host, - [SemanticAttributes.NET_PEER_PORT]: port, [SemanticAttributes.DB_CONNECTION_STRING]: getJDBCString( host, port, diff --git a/plugins/node/opentelemetry-instrumentation-mysql2/src/utils.ts b/plugins/node/opentelemetry-instrumentation-mysql2/src/utils.ts index 3091569a40..c38f5ac683 100644 --- a/plugins/node/opentelemetry-instrumentation-mysql2/src/utils.ts +++ b/plugins/node/opentelemetry-instrumentation-mysql2/src/utils.ts @@ -48,10 +48,22 @@ interface Config { */ export function getConnectionAttributes(config: Config): SpanAttributes { const { host, port, database, user } = getConfig(config); - + const portNumber = parseInt(port, 10); + if (!isNaN(portNumber)) { + return { + [SemanticAttributes.NET_PEER_NAME]: host, + [SemanticAttributes.NET_PEER_PORT]: portNumber, + [SemanticAttributes.DB_CONNECTION_STRING]: getJDBCString( + host, + port, + database + ), + [SemanticAttributes.DB_NAME]: database, + [SemanticAttributes.DB_USER]: user, + }; + } return { [SemanticAttributes.NET_PEER_NAME]: host, - [SemanticAttributes.NET_PEER_PORT]: port, [SemanticAttributes.DB_CONNECTION_STRING]: getJDBCString( host, port, From d0fc194ace159bbcd56cf9c452348ab148fd09c4 Mon Sep 17 00:00:00 2001 From: Raphael Gaschignard Date: Fri, 23 Feb 2024 18:03:09 +0900 Subject: [PATCH 8/9] Fix the usage example (#1949) KnexInstrumentationConfig is just a type --- plugins/node/opentelemetry-instrumentation-knex/README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/plugins/node/opentelemetry-instrumentation-knex/README.md b/plugins/node/opentelemetry-instrumentation-knex/README.md index 189185be87..05537459cc 100644 --- a/plugins/node/opentelemetry-instrumentation-knex/README.md +++ b/plugins/node/opentelemetry-instrumentation-knex/README.md @@ -22,7 +22,7 @@ npm install --save @opentelemetry/instrumentation-knex ## Usage ```js -const { KnexInstrumentation, KnexInstrumentationConfig } = require('@opentelemetry/instrumentation-knex'); +const { KnexInstrumentation } = require('@opentelemetry/instrumentation-knex'); const { ConsoleSpanExporter, SimpleSpanProcessor } = require('@opentelemetry/sdk-trace-base'); const { NodeTracerProvider } = require('@opentelemetry/sdk-trace-node'); const { registerInstrumentations } = require('@opentelemetry/instrumentation'); @@ -34,11 +34,10 @@ provider.register(); registerInstrumentations({ instrumentations: [ - new KnexInstrumentation( - new KnexInstrumentationConfig({ + new KnexInstrumentation({ maxQueryLength: 100, }) - )], + ], tracerProvider: provider, }); ``` From a7861f6d23e07ab6f9e8d02378abd5e17d73bff3 Mon Sep 17 00:00:00 2001 From: Jamie King Date: Fri, 23 Feb 2024 05:46:05 -0700 Subject: [PATCH 9/9] feat(instrumentation-dns): allow ignoreHostnames to be only a single IgnoreMatcher (#1929) Co-authored-by: Marc Pichler --- plugins/node/opentelemetry-instrumentation-dns/README.md | 2 +- .../node/opentelemetry-instrumentation-dns/src/types.ts | 2 +- .../node/opentelemetry-instrumentation-dns/src/utils.ts | 5 ++++- .../test/functionals/utils.test.ts | 7 +++++++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/plugins/node/opentelemetry-instrumentation-dns/README.md b/plugins/node/opentelemetry-instrumentation-dns/README.md index c0aaaa1c98..72f5c9ba7b 100644 --- a/plugins/node/opentelemetry-instrumentation-dns/README.md +++ b/plugins/node/opentelemetry-instrumentation-dns/README.md @@ -44,7 +44,7 @@ Dns instrumentation has currently one option. You can set the following: | Options | Type | Description | | ------- | ---- | ----------- | -| [`ignoreHostnames`](https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/plugins/node/opentelemetry-instrumentation-dns/src/types.ts#L99) | `IgnoreMatcher[]` | Dns instrumentation will not trace all requests that match hostnames | +| [`ignoreHostnames`](https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/plugins/node/opentelemetry-instrumentation-dns/src/types.ts#L99) | `IgnoreMatcher | IgnoreMatcher[]` | Dns instrumentation will not trace all requests that match hostnames | ## Useful links diff --git a/plugins/node/opentelemetry-instrumentation-dns/src/types.ts b/plugins/node/opentelemetry-instrumentation-dns/src/types.ts index 10383813d1..21646bbae7 100644 --- a/plugins/node/opentelemetry-instrumentation-dns/src/types.ts +++ b/plugins/node/opentelemetry-instrumentation-dns/src/types.ts @@ -17,5 +17,5 @@ import { InstrumentationConfig } from '@opentelemetry/instrumentation'; export type IgnoreMatcher = string | RegExp | ((url: string) => boolean); export interface DnsInstrumentationConfig extends InstrumentationConfig { - ignoreHostnames?: IgnoreMatcher[]; + ignoreHostnames?: IgnoreMatcher | IgnoreMatcher[]; } diff --git a/plugins/node/opentelemetry-instrumentation-dns/src/utils.ts b/plugins/node/opentelemetry-instrumentation-dns/src/utils.ts index 9fae671bca..1b1d858052 100644 --- a/plugins/node/opentelemetry-instrumentation-dns/src/utils.ts +++ b/plugins/node/opentelemetry-instrumentation-dns/src/utils.ts @@ -124,13 +124,16 @@ export const satisfiesPattern = ( */ export const isIgnored = ( constant: string, - list?: IgnoreMatcher[], + list?: IgnoreMatcher | IgnoreMatcher[], onException?: (error: Error) => void ): boolean => { if (!list) { // No ignored urls - trace everything return false; } + if (!Array.isArray(list)) { + list = [list]; + } // Try/catch outside the loop for failing fast try { for (const pattern of list) { diff --git a/plugins/node/opentelemetry-instrumentation-dns/test/functionals/utils.test.ts b/plugins/node/opentelemetry-instrumentation-dns/test/functionals/utils.test.ts index c995ca0261..987e680575 100644 --- a/plugins/node/opentelemetry-instrumentation-dns/test/functionals/utils.test.ts +++ b/plugins/node/opentelemetry-instrumentation-dns/test/functionals/utils.test.ts @@ -88,6 +88,13 @@ describe('Utility', () => { assert.strictEqual(answer1, true); }); + it('should call isSatisfyPattern, match for a single mathcer', () => { + const answer1 = utils.isIgnored('api.montreal.ca', url => + url.endsWith('montreal.ca') + ); + assert.strictEqual(answer1, true); + }); + it('should not re-throw when function throws an exception', () => { satisfiesPatternStub.restore(); const onException = (e: Error) => {