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

Bug: throws on empty metrics even if told not to in middy middleware #1088

Closed
kiesel opened this issue Sep 15, 2022 · 2 comments · Fixed by #1090
Closed

Bug: throws on empty metrics even if told not to in middy middleware #1088

kiesel opened this issue Sep 15, 2022 · 2 comments · Fixed by #1090
Assignees
Labels
bug Something isn't working completed This item is complete and has been merged/shipped metrics This item relates to the Metrics Utility

Comments

@kiesel
Copy link

kiesel commented Sep 15, 2022

Bug description

When constructing the middleware like:

middy(handler).use(logMetrics(metrics, { throwOnEmptyMetrics: false }));

... I would expect it to not throw an exception, but it does. It just doesn't on the value undefined. It is slightly confusing...

Expected Behavior

Not throw exception.

Current Behavior

Throws exception

Possible Solution

Explicitly test for undefined and false.

Steps to Reproduce

  1. Setup via middy(handler).use(logMetrics(metrics, { throwOnEmptyMetrics: false }));
  2. Do not emit metric
  3. Run handler

Environment

  • Powertools version used: 1.2.1
  • Packaging format (Layers, npm): npm
  • AWS Lambda function runtime: nodejs.16x
  • Debugging logs:

Related issues, RFCs

@kiesel kiesel added bug Something isn't working triage This item has not been triaged by a maintainer, please wait labels Sep 15, 2022
@flochaz flochaz self-assigned this Sep 16, 2022
@flochaz
Copy link
Contributor

flochaz commented Sep 16, 2022

Thanks for reporting this. A fix is on his way !

@dreamorosi dreamorosi added metrics This item relates to the Metrics Utility and removed triage This item has not been triaged by a maintainer, please wait labels Sep 19, 2022
@github-actions
Copy link
Contributor

⚠️ COMMENT VISIBILITY WARNING ⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@github-actions github-actions bot added the pending-release This item has been merged and will be released soon label Sep 29, 2022
@dreamorosi dreamorosi removed the pending-release This item has been merged and will be released soon label Oct 27, 2022
@dreamorosi dreamorosi changed the title Bug (metrics): throws on empty metrics even if told not to in middy middleware Bug: throws on empty metrics even if told not to in middy middleware Nov 14, 2022
@dreamorosi dreamorosi added the completed This item is complete and has been merged/shipped label Nov 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working completed This item is complete and has been merged/shipped metrics This item relates to the Metrics Utility
Projects
None yet
3 participants