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

feat: Added entity linking attributes to aws-sdk v3 Lambda segments #2845

Merged
merged 10 commits into from
Dec 18, 2024

Conversation

mrickard
Copy link
Member

Description

External Lambda functions invoked by a Node application result in external segments. In order for the entity to be linked, external segments need two additional attributes: cloud.resource_id and cloud.platform. This PR adds middleware at instrumentation/aws-sdk/v3/lambda.js (via instrumentation/aws-sdk/v3/smithy-client.js) to add these attributes. This middleware adds the attributes only if the agent's config includes an AWS account ID defined as cloud.aws.account_id. The account ID referenced here should be the same as the AWS account ID hosting Lambda functions that will be invoked by the instrumented Node application.

How to Test

There are two new tests in test/versioned/aws-sdk-v3/lambda.test.js: one to test for these new attributes when cloud.aws.account_id is set on the agent config, and one to test for their absence when cloud.aws.account_id is not set.

Related Issues

Closes #2829
Closes NR-348168

mrickard and others added 5 commits December 18, 2024 09:23
…egments recorded within a serverless context, as they're not required for linking the Lambda entity

Signed-off-by: mrickard <[email protected]>
Copy link
Member

@bizob2828 bizob2828 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks fine. Just some comments on the jsdoc

lib/instrumentation/aws-sdk/v3/lambda.js Outdated Show resolved Hide resolved
lib/instrumentation/aws-sdk/v3/lambda.js Outdated Show resolved Hide resolved
@mrickard mrickard requested a review from bizob2828 December 18, 2024 20:20
…e to differences in local and remote behavior

Signed-off-by: mrickard <[email protected]>
@mrickard mrickard merged commit 8820265 into newrelic:main Dec 18, 2024
25 checks passed
Copy link

codecov bot commented Dec 18, 2024

Codecov Report

Attention: Patch coverage is 98.33333% with 1 line in your changes missing coverage. Please review.

Project coverage is 97.20%. Comparing base (a3db8bd) to head (b8f0b4a).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
lib/instrumentation/aws-sdk/v3/lambda.js 98.24% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2845      +/-   ##
==========================================
- Coverage   97.26%   97.20%   -0.06%     
==========================================
  Files         294      295       +1     
  Lines       46405    46462      +57     
==========================================
+ Hits        45135    45164      +29     
- Misses       1270     1298      +28     
Flag Coverage Δ
integration-tests-cjs-18.x 73.14% <56.66%> (-0.04%) ⬇️
integration-tests-cjs-20.x 73.15% <56.66%> (-0.04%) ⬇️
integration-tests-cjs-22.x 73.19% <56.66%> (-0.02%) ⬇️
integration-tests-esm-18.x 49.92% <56.66%> (+0.01%) ⬆️
integration-tests-esm-20.x 49.93% <56.66%> (+0.01%) ⬆️
integration-tests-esm-22.x 49.97% <56.66%> (+0.01%) ⬆️
unit-tests-18.x 88.92% <58.33%> (-0.05%) ⬇️
unit-tests-20.x ?
unit-tests-22.x ?
versioned-tests-18.x 79.01% <96.66%> (-0.17%) ⬇️
versioned-tests-20.x 79.02% <96.66%> (-0.17%) ⬇️
versioned-tests-22.x 79.03% <96.66%> (-0.17%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@github-actions github-actions bot mentioned this pull request Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Instrument @aws-sdk/client-lambda to add ARN and provider to segments
2 participants