Skip to content
This repository was archived by the owner on Jun 5, 2024. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: newrelic/node-newrelic-aws-sdk
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: baa853b062608f2cdb46be0029d8b70388226447
Choose a base ref
...
head repository: newrelic/node-newrelic-aws-sdk
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: c6c6d70b53887d6edfda127414a01c24d5f413a9
Choose a head ref
  • 10 commits
  • 11 files changed
  • 6 contributors

Commits on Sep 20, 2022

  1. Copy the full SHA
    478760c View commit details

Commits on Sep 22, 2022

  1. Copy the full SHA
    b12d4fc View commit details
  2. Copy the full SHA
    23124cd View commit details

Commits on Sep 23, 2022

  1. Merge pull request #148 from newrelic/coreyarnold-patch-1

    add issue templates for jira linking NEWRELIC-3748
    jordigh authored Sep 23, 2022
    Copy the full SHA
    ce907cc View commit details

Commits on Oct 6, 2022

  1. Copy the full SHA
    fd1f5e3 View commit details

Commits on Oct 7, 2022

  1. Merge pull request #150 from bizob2828/fix-dynamo-port

    default dynamodb port to 443 when undefined on endpoint instance
    bizob2828 authored Oct 7, 2022
    Copy the full SHA
    eaf876a View commit details

Commits on Oct 10, 2022

  1. Copy the full SHA
    526e3f7 View commit details
  2. Copy the full SHA
    eb65ce5 View commit details
  3. Copy the full SHA
    1d0c5ef View commit details
  4. Merge pull request #151 from newrelic/release/v5.0.1

    Release v5.0.1
    jmartin4563 authored Oct 10, 2022
    Copy the full SHA
    c6c6d70 View commit details
27 changes: 0 additions & 27 deletions .github/ISSUE_TEMPLATE/enhancement.md

This file was deleted.

4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### v5.0.1 (2022-10-10)

* Updated DynamoDB instrumentation to default port to 443 when not specified from the endpoint.

### v5.0.0 (2022-07-28)

* **BREAKING** Removed support for Node 12.
20 changes: 19 additions & 1 deletion lib/util.js
Original file line number Diff line number Diff line change
@@ -4,6 +4,8 @@
*/

'use strict'
const UNKNOWN = 'Unknown'

function grabLastUrlSegment(url = '/') {
// cast URL as string, and an empty
// string for null, undefined, NaN etc.
@@ -14,6 +16,22 @@ function grabLastUrlSegment(url = '/') {
return lastItem
}

/**
* Retrieves the db segment params from endpoint and command parameters
*
* @param {Object} endpoint instance of ddb endpoint
* @param {Object} params parameters passed to a ddb command
* @returns {Object}
*/
function setDynamoParameters(endpoint, params) {
return {
host: endpoint && (endpoint.host || endpoint.hostname),
port_path_or_id: (endpoint && endpoint.port) || 443,
collection: (params && params.TableName) || UNKNOWN
}
}

module.exports = {
grabLastUrlSegment
grabLastUrlSegment,
setDynamoParameters
}
8 changes: 3 additions & 5 deletions lib/v2/dynamodb.js
Original file line number Diff line number Diff line change
@@ -29,6 +29,8 @@ const DOC_CLIENT_OPERATIONS = [
'scan'
]

const { setDynamoParameters } = require('../util')

function instrument(shim, AWS) {
shim.setDatastore(shim.DYNAMODB)

@@ -43,11 +45,7 @@ function instrument(shim, AWS) {

return {
name: operationName,
parameters: {
host: this.endpoint && this.endpoint.host,
port_path_or_id: this.endpoint && this.endpoint.port,
collection: (params && params.TableName) || 'Unknown'
},
parameters: setDynamoParameters(this.endpoint, params),
callback: shim.LAST,
opaque: true
}
8 changes: 2 additions & 6 deletions lib/v3/dynamodb-util.js
Original file line number Diff line number Diff line change
@@ -4,8 +4,7 @@
*/

'use strict'

const UNKNOWN = 'Unknown'
const { setDynamoParameters } = require('../util')

/**
* Returns the spec for Dynamo commands
@@ -18,12 +17,9 @@ const UNKNOWN = 'Unknown'
*/
function getDynamoSpec(shim, original, name, args) {
const [{ input }] = args
const collection = (input && input.TableName) || UNKNOWN
const host = this.endpoint && this.endpoint.hostname
const portPathOrId = this.endpoint && this.endpoint.port
return {
name: this.commandName,
parameters: { host, port_path_or_id: portPathOrId, collection },
parameters: setDynamoParameters(this.endpoint, input),
callback: shim.LAST,
opaque: true,
promise: true
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@newrelic/aws-sdk",
"version": "5.0.0",
"version": "5.0.1",
"description": "New Relic instrumentation of the aws-sdk package.",
"main": "index.js",
"scripts": {
58 changes: 56 additions & 2 deletions tests/unit/util.tap.js
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@

'use strict'
const tap = require('tap')
const { grabLastUrlSegment } = require('../../lib/util')
const { grabLastUrlSegment, setDynamoParameters } = require('../../lib/util')
tap.test('Utility Functions', (t) => {
t.ok(grabLastUrlSegment, 'imported function successfully')

@@ -30,7 +30,61 @@ tap.test('Utility Functions', (t) => {

for (const [, fixture] of fixtures.entries()) {
const result = grabLastUrlSegment(fixture.input)
t.equals(result, fixture.output, `expecting ${result} to equal ${fixture.output}`)
t.equal(result, fixture.output, `expecting ${result} to equal ${fixture.output}`)
}
t.end()
})

tap.test('DB parameters', (t) => {
t.autoend()

t.test('default values', (t) => {
const input = {}
const endpoint = {}
const result = setDynamoParameters(endpoint, input)
t.same(
result,
{
host: undefined,
port_path_or_id: 443,
collection: 'Unknown'
},
'should set default values for parameters'
)
t.end()
})

// v2 uses host key
t.test('host, port, collection', (t) => {
const input = { TableName: 'unit-test' }
const endpoint = { host: 'unit-test-host', port: '123' }
const result = setDynamoParameters(endpoint, input)
t.same(
result,
{
host: endpoint.host,
port_path_or_id: endpoint.port,
collection: input.TableName
},
'should set appropriate parameters'
)
t.end()
})

// v3 uses hostname key
t.test('hostname, port, collection', (t) => {
const input = { TableName: 'unit-test' }
const endpoint = { hostname: 'unit-test-host', port: '123' }
const result = setDynamoParameters(endpoint, input)
t.same(
result,
{
host: endpoint.hostname,
port_path_or_id: endpoint.port,
collection: input.TableName
},
'should set appropriate parameters'
)
t.end()
})
})
3 changes: 2 additions & 1 deletion tests/versioned/v2/dynamodb.tap.js
Original file line number Diff line number Diff line change
@@ -128,11 +128,12 @@ function finish(t, tests, tx) {
'should have operation in segment name'
)
const attrs = segment.attributes.get(common.SEGMENT_DESTINATION)
attrs.port_path_or_id = parseInt(attrs.port_path_or_id, 10)
t.matches(
attrs,
{
'host': String,
'port_path_or_id': String,
'port_path_or_id': Number,
'product': 'DynamoDB',
'collection': String,
'aws.operation': operation,
4 changes: 3 additions & 1 deletion tests/versioned/v3/client-dynamodb.tap.js
Original file line number Diff line number Diff line change
@@ -202,11 +202,13 @@ tap.test('DynamoDB', (t) => {
'should have operation in segment name'
)
const attrs = segment.attributes.get(common.SEGMENT_DESTINATION)
attrs.port_path_or_id = parseInt(attrs.port_path_or_id, 10)

t.match(
attrs,
{
'host': String,
'port_path_or_id': String,
'port_path_or_id': Number,
'product': 'DynamoDB',
'collection': String,
'aws.operation': command.constructor.name,
3 changes: 2 additions & 1 deletion tests/versioned/v3/lib-dynamodb.tap.js
Original file line number Diff line number Diff line change
@@ -165,11 +165,12 @@ function finish(t, tests, tx) {
'should have operation in segment name'
)
const attrs = segment.attributes.get(common.SEGMENT_DESTINATION)
attrs.port_path_or_id = parseInt(attrs.port_path_or_id, 10)
t.match(
attrs,
{
'host': String,
'port_path_or_id': String,
'port_path_or_id': Number,
'product': 'DynamoDB',
'collection': String,
'aws.operation': operation,