Skip to content

Conversation

@dothomson
Copy link
Contributor

Summary

Changes

Please provide a summary of what's being changed

This is a Quality of Life improvement when using a metrics instance. By returning the class instance from some of the functions of the Metrics class then commands can be grouped together and improve readability of the code.

#4929

Issue number: closes #4929


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.

@pull-request-size pull-request-size bot added the size/L PRs between 100-499 LOC label Jan 8, 2026
@boring-cyborg boring-cyborg bot added metrics This item relates to the Metrics Utility tests PRs that add or change tests labels Jan 8, 2026
@boring-cyborg
Copy link

boring-cyborg bot commented Jan 8, 2026

Thanks a lot for your first contribution! Please check out our contributing guidelines and don't hesitate to ask whatever you need.
In the meantime, check out the #typescript channel on our Powertools for AWS Lambda Discord: Invite link

@svozza
Copy link
Contributor

svozza commented Jan 9, 2026

I don't think we need to change all the tests to use this new interface, I would prefer if we kept a mixture to show that both usages are still acceptable. Also, I think we should update one of the e2e tests to use the fluent interface too.

@svozza
Copy link
Contributor

svozza commented Jan 14, 2026

Hi @dothomson, just checking in to see if you need any help with the PR?

@dothomson
Copy link
Contributor Author

@svozza - Apologies I got drawn back into the day job.

I've reverted some of the tests to provided a mixture of the fluid and verbose versions in the tests and updated some of the e2e tests also. I didn't apply any rubric to which tests use which version - let me know if you'd like to apply one or if this random approach was suitable.


I was meaning to ask are you happy with the metric functions selected to return the Metrics class?

Generally speaking I wanted to make it easy to define and add and publish metrics, but avoid including "destructive" actions (i.e.clearDimensions) to avoid more confusing function chains.

@dothomson dothomson marked this pull request as ready for review January 14, 2026 17:10
@svozza
Copy link
Contributor

svozza commented Jan 14, 2026

Absolutely no need to apologise! These changes look good. I'm running the end-to-end tests now and the metrics test suites have already passed so we're looking good there.

Regarding the selection of methods, I think your reasoning is sound: t would be quite starange to do something like metrics.addDimension( ... ).addDeimesnion ( ... ).clearDimensions();. Furthermore, this is something we could always add later if there is some use case we've missed even though I doubt we have.

@sonarqubecloud
Copy link

@svozza
Copy link
Contributor

svozza commented Jan 16, 2026

Thank you @dothomson! Merging now.

@svozza svozza merged commit e7aa2e2 into aws-powertools:main Jan 16, 2026
46 checks passed
@boring-cyborg
Copy link

boring-cyborg bot commented Jan 16, 2026

Awesome work, congrats on your first merged pull request and thank you for helping improve everyone's experience!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

metrics This item relates to the Metrics Utility size/L PRs between 100-499 LOC tests PRs that add or change tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: QoL - Return the Metrics object instance from public functions (i.e. addDimension())

2 participants