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

fix: Fixed matching for ALB and API Gateway (v1 & v2) events for Lambda #2780

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

Conversation

mrickard
Copy link
Member

@mrickard mrickard commented Nov 21, 2024

Description

Filtering of API Gateway v1 vs v2 did not allow for Lambda functions triggered by ALB/ELB. Prior to our most recent change to that filtering, ALB events were traced without explicit filtering. This adds explicit checking for an ALB event type, and allows ALB-triggered web requests to be treated as web transactions.

How to Test

This adds a unit test at test/unit/server/ess/alb-event.test.js checking for the expected request properties.

Related Issues

Closes NR-341636
Closes #2779
Closes NR-342521
Closes #2753
Closes NR-341279

Comment on lines 163 to 164
}
const albKeys = [
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
}
const albKeys = [
}
const albKeys = [

Comment on lines 163 to 164
}
const albKeys = [
Copy link
Contributor

Choose a reason for hiding this comment

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

Please document this as our other event keys are documented.

'multiValueQueryStringParameters',
'pathParameters'
]
.sort()
Copy link
Contributor

Choose a reason for hiding this comment

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

I recommend listing them in sorted order to avoid the unnecessary sorting operation cost.

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'm dispensing with the sort and string conversion, as we're no longer looking for an exact match of all keys.

if (!event.multiValueQueryStringParameters) {
if (
!event.multiValueQueryStringParameters ||
Object.keys(event.multiValueQueryStringParameters).length === 0
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand. If we have multiValueQueryStringParameters defined at all, we should not have queryStringParameters defined. So why would we return queryStringParameters if the multi valued property is defined with zero elements?

Copy link
Member Author

Choose a reason for hiding this comment

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

In the sample event captured by the customer, both queryStringParameters and multiValueQueryStringParameters were defined, event though each had zero properties. I could see changing this to check for properties in each. The definition of one, though, doesn't exclude the definition of the other, based on the input they've captured.

@mrickard mrickard changed the title fix: Restored tracing of ALB event properties fix: Fixed matching for ALB and API Gateway (v1 & v2) events for Lambda Nov 26, 2024
…hing against known-unique keys for each type. Also added event example fixtures from users.

Signed-off-by: mrickard <[email protected]>
@mrickard mrickard force-pushed the NR-341636/restore-alb-lambda-proxy-properties branch from a3dcdcc to ebdfb27 Compare November 26, 2024 19:42
Copy link

codecov bot commented Nov 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.16%. Comparing base (a8eef8b) to head (ebdfb27).
Report is 24 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2780      +/-   ##
==========================================
- Coverage   97.26%   97.16%   -0.11%     
==========================================
  Files         294      294              
  Lines       46315    46345      +30     
==========================================
- Hits        45047    45029      -18     
- Misses       1268     1316      +48     
Flag Coverage Δ
integration-tests-cjs-18.x 73.34% <56.06%> (-0.93%) ⬇️
integration-tests-cjs-20.x 73.36% <56.06%> (-0.93%) ⬇️
integration-tests-cjs-22.x 73.40% <56.06%> (-0.93%) ⬇️
integration-tests-esm-18.x ?
integration-tests-esm-20.x ?
integration-tests-esm-22.x ?
unit-tests-18.x 89.00% <100.00%> (+0.02%) ⬆️
unit-tests-20.x 89.00% <100.00%> (+0.02%) ⬆️
unit-tests-22.x 89.01% <100.00%> (+0.02%) ⬆️
versioned-tests-18.x 78.98% <56.06%> (-0.20%) ⬇️
versioned-tests-20.x 78.96% <56.06%> (-0.23%) ⬇️
versioned-tests-22.x 78.97% <56.06%> (-0.23%) ⬇️

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Needs PR Review
2 participants