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/.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/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", 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]; +};