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(tracer): capture method throws errors correctly #1016

Merged
merged 4 commits into from Jul 13, 2022

Conversation

dreamorosi
Copy link
Contributor

Description of your changes

As reported by @saragerion, the Tracer method captureMethod was incorrectly catching errors thrown within the body/scope of a decorated Class method defined by users. This is not a desired behaviour as the utility should not catch customers' errors but should simply run the logic defined in the decorator function and then throw the error along for customers to handle/throw in their code.

We had this behaviour on the radar as shown by the TODO comment present in that part of the code (see diff) but up until now we hadn't noticed / it wasn't reported. Additionally this same change was made to the captureLambdaHandler at some point in the past.

This PR modifies the logic of the captureMethod decorator and updates the unit tests related to it so that they actually test a method that throws.

How to verify this change

See updated unit tests.

Related issues, RFCs

N/A

PR status

Is this ready for review?: YES
Is it a breaking change?: NO

Checklist

  • My changes meet the tenets criteria
  • I have performed a self-review of my own code
  • I have commented my code where necessary, particularly in areas that should be flagged with a TODO, or hard-to-understand areas
  • My changes generate no new warnings
  • The code coverage hasn't decreased
  • I have added tests that prove my change is effective and works
  • New and existing unit tests pass locally and in Github Actions
  • The PR title follows the conventional commit semantics

Breaking change checklist

N/A


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@dreamorosi dreamorosi self-assigned this Jul 12, 2022
@dreamorosi dreamorosi added tracer This item relates to the Tracer Utility fix labels Jul 12, 2022
@dreamorosi dreamorosi added this to Pull Requests - Work in progress in Pull Requests via automation Jul 12, 2022
@dreamorosi dreamorosi added this to the production-ready-release milestone Jul 12, 2022
@dreamorosi dreamorosi moved this from Pull Requests - Work in progress to Pull Requests - Review needed in Pull Requests Jul 12, 2022
@github-actions github-actions bot added the bug Something isn't working label Jul 12, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Jul 12, 2022

📊 Package size report   84%↑

File Before After
aws-lambda-powertools-tracer-0.11.1-rc.0.tgz 21.5 kB -0.51%↓21.4 kB
logger-bundle.zip 24.3 kB
metrics-bundle.zip 18.1 kB
tracer-bundle.zip 21.9 kB
Total (Includes all files) 76.5 kB 84%↑140.7 kB
Tarball size 76.5 kB 82%↑139.5 kB
Unchanged files
File Size
aws-lambda-powertools-commons-0.11.1-rc.0.tgz 6.5 kB
aws-lambda-powertools-logger-0.11.1-rc.0.tgz 23.8 kB
aws-lambda-powertools-metrics-0.11.1-rc.0.tgz 17.5 kB
commons-bundle.zip 7.1 kB

🤖 This report was automatically generated by pkg-size-action
(options hash: d7cdb5e84443c052afd25acb71e4a54e)

packages/tracer/tests/unit/Tracer.test.ts Outdated Show resolved Hide resolved
@dreamorosi dreamorosi requested a review from ijemmy July 13, 2022 08:54
@github-actions
Copy link
Contributor

github-actions bot commented Jul 13, 2022

📊 Package size report   -50.9%↓

File Before After
aws-lambda-powertools-tracer-0.11.1-rc.0.tgz 21.5 kB -0.51%↓21.4 kB
commons-bundle.zip 7.1 kB
logger-bundle.zip 24.3 kB
metrics-bundle.zip 18.1 kB
tracer-bundle.zip 22.1 kB
Total (Includes all files) 141.0 kB -50.9%↓69.3 kB
Tarball size 139.8 kB -50.3%↓69.6 kB
Unchanged files
File Size
aws-lambda-powertools-commons-0.11.1-rc.0.tgz 6.5 kB
aws-lambda-powertools-logger-0.11.1-rc.0.tgz 23.8 kB
aws-lambda-powertools-metrics-0.11.1-rc.0.tgz 17.5 kB

🤖 This report was automatically generated by pkg-size-action
(options hash: 73f92e6bac295b738b736fdbb2dc4355)

Pull Requests automation moved this from Pull Requests - Review needed to Pull Requests - Approved and ready to be merged Jul 13, 2022
@saragerion saragerion merged commit fb85238 into main Jul 13, 2022
@saragerion saragerion deleted the fix/tracer/capture_method branch July 13, 2022 15:03
Pull Requests automation moved this from Pull Requests - Approved and ready to be merged to Pull Requests - Merged or Closed Jul 13, 2022
dreamorosi added a commit that referenced this pull request Aug 2, 2022
* wip

* wip

* fix: captureMethod now throws

* chore: removed leftover comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working tracer This item relates to the Tracer Utility
Projects
No open projects
Pull Requests
Pull Requests - Merged or Closed
Development

Successfully merging this pull request may close these issues.

None yet

3 participants