Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@newrelic/aws-sdk

Package Overview
Dependencies
Maintainers
2
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@newrelic/aws-sdk - npm Package Compare versions

Comparing version 4.1.0 to 4.1.1

lib/v3/check-agent-compatible.js

4

CHANGELOG.md

@@ -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",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc