Skip to content

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

@kiesel

Description

@kiesel

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcompletedThis item is complete and has been merged/shippedmetricsThis item relates to the Metrics Utility

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions