-
Notifications
You must be signed in to change notification settings - Fork 100
fix(metrics): Clear custom dimensions when flushing. #2328
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
fix(metrics): Clear custom dimensions when flushing. #2328
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have tested this code with the original snippet from the bug and now no metrics are being emitted. In the log group I am seeing:
{
"level": "WARN",
"message": "No metrics were emitted",
"function_arn": null,
"function_name": null,
"function_request_id": null,
"function_version": null,
"service": null,
"timestamp": "2025-12-10T13:24:42.385Z"
}
To add context on how I am pulling the changes. I have grabbed a copy of the EmfMetricsLogger and create the instance like so:
private static final Metrics METRICS = new EmfMetricsLogger(new EnvironmentProvider(), new MetricsContext());
Don't think this makes a difference though for this small test. Deploying to mavenLocal might be a bit more tricky for me.
|
@surajkumar Thanks for testing! can you try to call as last statement in your testing code The reason why you see this warning is because |
I tried with the flush at the end of the method and yes that works. I then re-tried with |
surajkumar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pulled repo and performed my manual integration test. All looks good to me. Thanks @phipag !
|
Awesome, thanks for confirming @surajkumar! Merged this PR. |



Summary
This PR clears custom dimensions when
.flush()is called on the metrics instance. Note: This does not affect calls to.flushMetrics()since they create a temporary second metrics instance that supports flushing on its own with its own dimension set (copy).This was the default behavior in v1 of Powertools Java but is also the same behavior in the other runtimes such as TypeScript (see comment).
On flush, we clear:
Changes
Issue number: #2327
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.