powertools-lambda-typescript
powertools-lambda-typescript copied to clipboard
Bug (metrics): throws on empty metrics even if told not to in middy middleware
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
- Setup via
middy(handler).use(logMetrics(metrics, { throwOnEmptyMetrics: false }));
- Do not emit metric
- 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
Thanks for reporting this. A fix is on his way !
⚠️ 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.