Skip to content

Bug: EMF Metrics Logger emits root dict without metrics when no metrics are added #1890

Closed

Description

@phipag

Is your feature request related to a problem? Please describe.
When using @FlushMetrics, the default behavior is to log a warning if no metrics emitted. This works correctly. However, when no metrics were added, in addition to logging a warning, the root-level section of the _aws EMF dict is printed. Example:

This is the output when placing @FlushMetrics on a Lambda handler that is not interacting with metrics at all.

{"Service":"payment","logStreamId":"$LATEST","functionVersion":"$LATEST","executionEnvironment":"AWS_Lambda_java11"}

Describe the solution you'd like
If no metrics are added, we should not attempt to flush since this seems to be a bug in the underlying aws-embedded-metrics library.

The expected output is that nothing except for the warning is logged when the user is not emitting any metrics.

Activity

  1. self-assigned this
    on Jun 16, 2025
  2. moved this from Triage to Backlog in Powertools for AWS Lambda (Java)on Jun 16, 2025
  3. phipag commented on Jun 16, 2025

    @phipag
    ContributorAuthor

    Created PR: #1891

  4. moved this from Backlog to Working on it in Powertools for AWS Lambda (Java)on Jun 16, 2025
  5. phipag commented on Jun 16, 2025

    @phipag
    ContributorAuthor

    Created issue in EMF repository: awslabs/aws-embedded-metrics-java#165

  6. phipag commented on Jun 16, 2025

    @phipag
    ContributorAuthor

    Resolving here since the PR addresses the issue.

  7. moved this from Working on it to Shipped in Powertools for AWS Lambda (Java)on Jun 18, 2025
  8. moved this from Shipped to Coming soon in Powertools for AWS Lambda (Java)on Jun 18, 2025
  9. moved this from Coming soon to Shipped in Powertools for AWS Lambda (Java)on Jul 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions