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

Newrelic demo #19

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Newrelic demo #19

wants to merge 6 commits into from

Conversation

huntharo
Copy link
Contributor

@huntharo huntharo commented Sep 14, 2023

Issue Demonstrated

  • newrelic@10.4.0 logs DynamoDB access on the Database tab in APM with actual operations like DynamoDB GetItemCommand, DynamoDB PutItemCommand, and DynamoDB UpdateItemCommand
  • newrelic@11.1.0 removes the DynamoDB access from the Database tab and instead logs access to the dynamodb HTTPS endpoint as an External Service without insight into which commands were run and how much time they took
  • It appears that this was broken in: feat: updated aws sdk v3 instrumentation to function with require-in-… newrelic/node-newrelic-aws-sdk#205
    • This PR completely removed the lib/v3/lib-dynamodb.js and lib/v3/client-dynamodb.js files from @newrelic/aws-sdk@7.0.0
    • This PR also changed the nr-hooks.js file, changing the type of the hooks for smithy-client and completely removing the hooks for lib-dynamodb and client-dynamod

Running the Demo

  • npm i to install modules
  • npm run build to compile the TypeScript
  • Allow the example to reference the local module by name
    • npm link
    • npm link @pwrdrvr/dynamodb-session-store
  • Bundle the example (running it with ts-node results in no data being sent to NR)
    • npm run build:example:express
  • Run the example with your NR license key
    • NEW_RELIC_LICENSE_KEY=my_license_key npm run example:express:newrelic
  • Hit the login route a few times
  • View dynamodb-session-store in NewRelic APM

Comparing newrelic 10.4.0 to newrelic 11.1.0

  • 10.4.0 logs DynamoDB under the Database tab
  • 11.1.0 logs DynamoDB calls as External Services not as Database

Run this command (with license key substituted) to test changed versions:

rm -rf node_modules package-lock.json && npm i && npm link && npm link @pwrdrvr/dynamodb-session-store && npm run build:example:express && NEW_RELIC_LICENSE_KEY=my_license_key npm run example:express:newrelic

Logs of Working Version 10.4.0

  • Instruments @smithy/smithy-client AND @aws-sdk/client-dynamodb
  • Logs Datastore metric names set
  • Logs Instrumenting @smithy/smithy-client with onResolved hook
  • Logs Instrumenting @aws-sdk/client-dynamodb with onResolved hook
{"v":0,"level":10,"name":"newrelic","hostname":"MacBook-Pro-2.local","pid":70700,"time":"2023-09-14T20:58:45.944Z","msg":"Instrumenting @aws-sdk/client-dynamodb with onResolved hook.","component":"shimmer"}
{"v":0,"level":10,"name":"newrelic","hostname":"MacBook-Pro-2.local","pid":70700,"time":"2023-09-14T20:58:46.089Z","msg":"Instrumenting @smithy/smithy-client with onResolved hook.","component":"shimmer"}
{"v":0,"level":10,"name":"newrelic","hostname":"MacBook-Pro-2.local","pid":70700,"time":"2023-09-14T20:58:46.092Z","msg":"Wrapping 1 properties on nodule.","component":"Shim","module":"@smithy/smithy-client"}
{"v":0,"level":10,"name":"newrelic","hostname":"MacBook-Pro-2.local","pid":70700,"time":"2023-09-14T20:58:46.092Z","msg":"Replacing \"Client\" with wrapped version","component":"Shim","module":"@smithy/smithy-client"}
{"v":0,"level":10,"name":"newrelic","hostname":"MacBook-Pro-2.local","pid":70700,"time":"2023-09-14T20:58:46.291Z","msg":"Datastore metric names set","component":"DatastoreShim","module":"@aws-sdk/client-dynamodb","datastore":"DynamoDB","metrics":{"PREFIX":"DynamoDB","STATEMENT":"Datastore/statement/DynamoDB/","OPERATION":"Datastore/operation/DynamoDB/","INSTANCE":"Datastore/instance/DynamoDB/","ALL":"Datastore/DynamoDB/all"}}

Logs of Failing Version 11.1.0

  • Instruments @smithy/smithy-client
  • Does NOT log that it instrumented @aws-sdk/client-dynamodb
  • Does NOT log Datastore metric names set
  • Notes Instrumenting @smithy/smithy-client with onRequire (module loaded) hook
{"v":0,"level":10,"name":"newrelic","hostname":"MacBook-Pro-2.local","pid":67211,"time":"2023-09-14T20:53:26.182Z","msg":"Instrumenting @smithy/smithy-client with onRequire (module loaded) hook.","component":"shimmer"}
{"v":0,"level":10,"name":"newrelic","hostname":"MacBook-Pro-2.local","pid":67211,"time":"2023-09-14T20:53:26.183Z","msg":"Wrapping 1 properties on nodule.","component":"ConglomerateShim","module":"@smithy/smithy-client"}
{"v":0,"level":10,"name":"newrelic","hostname":"MacBook-Pro-2.local","pid":67211,"time":"2023-09-14T20:53:26.183Z","msg":"Replacing \"send\" with wrapped version","component":"ConglomerateShim","module":"@smithy/smithy-client"}
{"v":0,"level":10,"name":"newrelic","hostname":"MacBook-Pro-2.local","pid":67211,"time":"2023-09-14T20:53:26.271Z","msg":"Instrumenting q with onRequire (module loaded) hook.","component":"shimmer"}
{"v":0,"level":10,"name":"newrelic","hostname":"MacBook-Pro-2.local","pid":67211,"time":"2023-09-14T20:53:26.271Z","msg":"Wrapping function nextTick (no segment)","component":"tracer"}
{"v":0,"level":10,"name":"newrelic","hostname":"MacBook-Pro-2.local","pid":67211,"time":"2023-09-14T20:53:26.271Z","msg":"Instrumented Q.nextTick.","component":"shimmer"}
{"v":0,"level":10,"name":"newrelic","hostname":"MacBook-Pro-2.local","pid":67211,"time":"2023-09-14T20:53:26.332Z","msg":"Instrumenting superagent with onRequire (module loaded) hook.","component":"shimmer"}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant