powertools-lambda-typescript icon indicating copy to clipboard operation
powertools-lambda-typescript copied to clipboard

Bug (metrics): throws on empty metrics even if told not to in middy middleware

Open kiesel opened this issue 2 years ago • 1 comments

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 avatar Sep 15 '22 10:09 kiesel

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

flochaz avatar Sep 16 '22 12:09 flochaz

⚠️ 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[bot] avatar Sep 29 '22 09:09 github-actions[bot]