-
Notifications
You must be signed in to change notification settings - Fork 35
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
Favor parameterized routes for resource name. #513
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #513 +/- ##
==========================================
- Coverage 82.10% 81.86% -0.25%
==========================================
Files 54 55 +1
Lines 2191 2255 +64
Branches 511 521 +10
==========================================
+ Hits 1799 1846 +47
- Misses 329 344 +15
- Partials 63 65 +2 ☔ View full report in Codecov by Sentry. |
src/trace/span-inferrer.ts
Outdated
@@ -94,7 +94,15 @@ export class SpanInferrer { | |||
const options: SpanOptions = {}; | |||
const domain = event.requestContext.domainName || ""; | |||
const path = event.rawPath || event.requestContext.path || event.requestContext.routeKey; | |||
const resourcePath = event.rawPath || event.requestContext.resourcePath || event.requestContext.routeKey; | |||
var resourcePath = event.rawPath || event.requestContext.resourcePath || event.requestContext.routeKey; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest refactoring this line + 98 into a new method with your new conditional as the first path, and use early returns as control flow.
My concern would be that we shadow/overwrite resourcePath
conditionally here in 101, and that if we add new logic here then someone needs to modify the logic on 97 they may not realize that their change would be later overwritten if it's a parameterized route.
Is that helpful?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One note, everything else looks good
Co-authored-by: AJ Stuyvenberg <astuyve@gmail.com>
What does this PR do?
Set the resource name to the parameterized route key when using api gateway v2.
Motivation
A metric is created from each span made by the tracers. The metric name comes from the operation name. The resource name gets added as a tag. Therefore unbound values for resource name can cause a large increase in the number of metrics on an account.
Testing Guidelines
To test this, I created two apps and pulled the event payloads for each to use in the unit tests.
Additional Notes
This feature already worked for api gatewawy v1.
Types of Changes
Check all that apply