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: Instrument Lambda invocations in AWS SDK #2901

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

Conversation

chynesNR
Copy link
Member

Instrument calls to Lambdas and Lambda Aliases from the AWS SDK, with span attributes to allow linking the calls to the actual Lambda (specifically the ARN is what's needed). Includes unit and integration tests. We are able to test without a making a successful call to a lambda, so no live testing resources are necessary.

Changes since the last PR:

  • Does not treat the segment as a Leaf, so we will get an additional HTTP span, which is now expected
  • Caps the size of the ARN cache
  • Limits most errors to log only once
  • Does not log the account ID, only if it is present or not

@chynesNR chynesNR requested a review from a team as a code owner November 25, 2024 22:54
@chynesNR chynesNR changed the title Feature/invoke lambda instrumentation feat: Instrument Lambda invocations in AWS SDK Nov 26, 2024
private string GetAccountId(IAgent agent)
{
string accountId = agent.Configuration.AwsAccountId;
if (accountId != null)
Copy link
Member

Choose a reason for hiding this comment

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

it would be more performant to check _reportBadAccountId here - if it's false, none of the rest of the validation needs to be done.

Copy link
Member

Choose a reason for hiding this comment

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

If that's the case, should the validation be done in the DefaultConfiguration class instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

I had planned on revisiting this after the ID decoding was done. There were a few things I wanted to consider:

  • Having the validation in a central place
  • We may want to fall back to the other ID method if one is invalid
  • The environment variable for the ID may be set after we've read the config
  • Depending on how we found the ID, it may be bad at first but good later

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 86.25954% with 18 lines in your changes missing coverage. Please review.

Project coverage is 81.46%. Comparing base (56c8165) to head (d107619).

Files with missing lines Patch % Lines
...gent/Core/Attributes/AttributeDefinitionService.cs 9.09% 10 Missing ⚠️
....Agent.Extensions/Collections/ConcurrentHashSet.cs 0.00% 5 Missing ⚠️
...nt/NewRelic/Agent/Core/Transactions/Transaction.cs 70.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2901      +/-   ##
==========================================
+ Coverage   81.42%   81.46%   +0.04%     
==========================================
  Files         465      466       +1     
  Lines       29563    29692     +129     
  Branches     3278     3305      +27     
==========================================
+ Hits        24071    24188     +117     
- Misses       4698     4712      +14     
+ Partials      794      792       -2     
Flag Coverage Δ
Agent 82.38% <86.25%> (+0.04%) ⬆️
Profiler 73.13% <ø> (ø)

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

Files with missing lines Coverage Δ
...elic/Agent/Core/AgentHealth/AgentHealthReporter.cs 87.40% <100.00%> (+0.17%) ⬆️
...c/Agent/NewRelic/Agent/Core/Metrics/MetricNames.cs 92.21% <ø> (ø)
...ons/NewRelic.Agent.Extensions/AwsSdk/ArnBuilder.cs 100.00% <100.00%> (ø)
...nt/NewRelic/Agent/Core/Transactions/Transaction.cs 80.54% <70.00%> (-0.19%) ⬇️
....Agent.Extensions/Collections/ConcurrentHashSet.cs 30.00% <0.00%> (-2.73%) ⬇️
...gent/Core/Attributes/AttributeDefinitionService.cs 94.36% <9.09%> (-1.28%) ⬇️

... and 3 files with indirect coverage changes

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.

4 participants