@newrelic/aws-sdk
Advanced tools
Comparing version 4.1.0 to 4.1.1
@@ -0,1 +1,5 @@ | ||
### v4.1.1 (2022-01-13) | ||
* Fixed issue where v3 instrumentation checks against agent version would result in a logged error and fail to apply instrumentation. | ||
### v4.1.0 (2022-01-06) | ||
@@ -2,0 +6,0 @@ |
101
nr-hooks.js
@@ -7,5 +7,2 @@ /* | ||
'use strict' | ||
const newrelic = require('newrelic') | ||
const semver = require('semver') | ||
const agentVersion = newrelic && newrelic.agent && newrelic.agent.version | ||
@@ -17,45 +14,69 @@ const instrumentations = [ | ||
onRequire: require('./lib/v2/instrumentation') | ||
}, | ||
{ | ||
type: 'generic', | ||
moduleName: '@aws-sdk/smithy-client', | ||
onResolved: require('./lib/v3/smithy-client') | ||
}, | ||
{ | ||
type: 'message', | ||
moduleName: '@aws-sdk/client-sns', | ||
onResolved: require('./lib/v3/sns') | ||
}, | ||
{ | ||
type: 'message', | ||
moduleName: '@aws-sdk/client-sqs', | ||
onResolved: require('./lib/v3/sqs') | ||
}, | ||
{ | ||
type: 'datastore', | ||
moduleName: '@aws-sdk/client-dynamodb', | ||
onResolved: require('./lib/v3/client-dynamodb') | ||
}, | ||
{ | ||
type: 'datastore', | ||
moduleName: '@aws-sdk/lib-dynamodb', | ||
onResolved: require('./lib/v3/lib-dynamodb') | ||
} | ||
] | ||
// TODO: Remove this semver check and semver module when we ship Node 18 support | ||
// A bug existed in 8.6.0 when we introduced the `onResolved` hook. | ||
// See: https://github.com/newrelic/node-newrelic/pull/986 | ||
// To avoid unnecessary support issues we will require agent version >= 8.7.0 to | ||
// register AWS SDK v3 instrumentation | ||
if (semver.satisfies(agentVersion, '>=8.7.0')) { | ||
instrumentations.push( | ||
{ | ||
type: 'generic', | ||
moduleName: '@aws-sdk/smithy-client', | ||
onResolved: require('./lib/v3/smithy-client') | ||
}, | ||
{ | ||
type: 'message', | ||
moduleName: '@aws-sdk/client-sns', | ||
onResolved: require('./lib/v3/sns') | ||
}, | ||
{ | ||
type: 'message', | ||
moduleName: '@aws-sdk/client-sqs', | ||
onResolved: require('./lib/v3/sqs') | ||
}, | ||
{ | ||
type: 'datastore', | ||
moduleName: '@aws-sdk/client-dynamodb', | ||
onResolved: require('./lib/v3/client-dynamodb') | ||
}, | ||
{ | ||
type: 'datastore', | ||
moduleName: '@aws-sdk/lib-dynamodb', | ||
onResolved: require('./lib/v3/lib-dynamodb') | ||
// TODO: Remove code block next major release of module by moving to a peer-dependency check. | ||
// See further comments in check-agent-compatible.js. | ||
const checkAgentCompatible = require('./lib/v3/check-agent-compatible') | ||
const NOOP_ON_REQUIRE = () => false | ||
instrumentations | ||
.filter((definition) => { | ||
return definition.onResolved | ||
}) | ||
.forEach(addCompatibleAgentCheck) | ||
/** | ||
* Adds a check on resolve to ensure on a version of the agent that does | ||
* not have the multiple invocation bug. If compatible, replaces onResolved | ||
* with original and returns value of invoked original. If not compatible, | ||
* sets onResolved to null so the related instrumentation gets skipped on each | ||
* resolve. | ||
* @param {object} definition Object definition instrumentation parameters | ||
*/ | ||
function addCompatibleAgentCheck(definition) { | ||
// Silence old agent versions from warning about missing require. | ||
definition.onRequire = NOOP_ON_REQUIRE | ||
const originalOnResolved = definition.onResolved | ||
definition.onResolved = function checkCompatibleOnResolved(shim, name) { | ||
if (!checkAgentCompatible(shim.agent.config.version, shim.logger, name)) { | ||
// Prevent future attempted execution which avoids allocating a shim each time. | ||
definition.onResolved = null | ||
return false | ||
} | ||
) | ||
} else { | ||
newrelic.shim.logger.warn( | ||
'The New Relic Node.js agent must be >= 8.7.0 to instrument AWS SDK v3, current version: %s', | ||
agentVersion | ||
) | ||
definition.onResolved = originalOnResolved | ||
return originalOnResolved.apply(this, arguments) | ||
} | ||
} | ||
// ------------------------------------------------------------------ | ||
module.exports = instrumentations |
{ | ||
"name": "@newrelic/aws-sdk", | ||
"version": "4.1.0", | ||
"version": "4.1.1", | ||
"description": "New Relic instrumentation of the aws-sdk package.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
151528
44
1331
0
2