DataDog / datadog-lambda-js

The Datadog AWS Lambda Library for Node
Apache License 2.0
105 stars 35 forks source link

Favor parameterized routes for resource name. #513

Closed purple4reina closed 3 months ago

purple4reina commented 4 months ago

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.

functions:
  v1:
    handler: handler.handler
    events:
      - http:
          method: get
          path: /user/{id}
  v2:
    handler: handler.handler
    events:
      - httpApi:
          method: get
          path: /user/{id}

Additional Notes

This feature already worked for api gatewawy v1.

Types of Changes

Check all that apply

codecov-commenter commented 4 months ago

Codecov Report

Attention: Patch coverage is 81.67939% with 24 lines in your changes are missing coverage. Please review.

Project coverage is 81.86%. Comparing base (5d49414) to head (93be85b). Report is 12 commits behind head on main.

:exclamation: Current head 93be85b differs from pull request most recent head 5c1c24d. Consider uploading reports for the commit 5c1c24d to get more accurate results

Files Patch % Lines
src/index.ts 60.00% 6 Missing :warning:
src/metrics/extension.ts 70.58% 5 Missing :warning:
src/trace/context/extractors/sqs.ts 61.53% 3 Missing and 2 partials :warning:
src/trace/span-inferrer.ts 75.00% 1 Missing and 1 partial :warning:
src/trace/xray-service.ts 92.85% 2 Missing :warning:
src/utils/log.ts 60.00% 2 Missing :warning:
src/metrics/listener.ts 94.73% 0 Missing and 1 partial :warning:
src/trace/patch-http.ts 0.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ 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 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.