Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: @aws-sdk/client-s3 instrumentation was broken with 3.363.0 release #3455

Merged
merged 4 commits into from
Jul 4, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/instrumentation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const nodeHasInstrumentableFetch = typeof (global.fetch) === 'function'

var MODULES = [
'@apollo/server',
'@aws-sdk/smithy-client', // Instrument the base client which all AWS-SDK v3 clients extends
['@aws-sdk/smithy-client', '@smithy/smithy-client'], // Instrument the base client which all AWS-SDK v3 clients extends.
['@elastic/elasticsearch', '@elastic/elasticsearch-canary'],
'@opentelemetry/api',
'@opentelemetry/sdk-metrics',
Expand Down Expand Up @@ -430,7 +430,7 @@ Instrumentation.prototype._patchModule = function (modExports, name, version, en
continue
}

modExports = patch(modExports, this._agent, { version, enabled, isImportMod })
modExports = patch(modExports, this._agent, { name, version, enabled, isImportMod })
}
}
return modExports
Expand Down
11 changes: 8 additions & 3 deletions lib/instrumentation/modules/@aws-sdk/smithy-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

'use strict'

const semver = require('semver')
const shimmer = require('../../shimmer')
const elasticAPMMiddlewares = Symbol('elasticAPMMiddlewares')
Expand Down Expand Up @@ -57,11 +58,15 @@ const clientsConfig = {
}
}

module.exports = function (mod, agent, { version, enabled }) {
module.exports = function (mod, agent, { name, version, enabled }) {
if (!enabled) return mod

// We have to do this check since npm view reveals RC versions below 3
if (!semver.satisfies(version, '>=3 <4')) {
// As of `@aws-sdk/*@3.363.0` the underlying smithy-client is under the
// `@smithy/` npm org and is 1.x.
if (name === '@smithy/smithy-client' && !semver.satisfies(version, '>=1 <2')) {
agent.logger.debug('cannot instrument @aws-sdk/client-*: @smithy/smithy-client version %s not supported', version)
return mod
} else if (name === '@aws-sdk/smithy-client' && !semver.satisfies(version, '>=3 <4')) {
agent.logger.debug('cannot instrument @aws-sdk/client-*: @aws-sdk/smithy-client version %s not supported', version)
return mod
}
Expand Down
Loading