-
Notifications
You must be signed in to change notification settings - Fork 421
feat(metrics): add support to persist default dimensions #410
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
feat(metrics): add support to persist default dimensions #410
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.
Only a few documentation comments and a question around the behavior of clear_metrics()
I'd like this approach for some use cases but I think it may add a "burden" on the dev UX to remember where the defaults where set. I'd prefer an approach where the decorator has something like:
Which keeps the defaults very close to the function. I wouldn't expect this defaults to be shared across other decorators in my opinion - i.e. if the code is reusing a library that has it's own defaults |
Yeah, I'd have loved to go down that route too, however I also experimented with: dimensions = [{"name": "dimension_1"}, "value": "value"}, {"name": "dimension_2"}, "value": "value"}]
@metrics.log_metrics(default_dimensions=dimensions) But this was more explicit and can work outside Lambda handler like in Lambda layers code, other modules, etc. metrics = Metrics()
metrics.set_default_dimensions(environment="prod", dimension_one="value", ...) |
Wouldn't something like this below help?
I have a sample version here: https://github.com/heitorlessa/aws-lambda-powertools-python/compare/feat/metrics-default-dimensions...pcolazurdo:pr_410?expand=1 |
This does @pcolazurdo - I was initially thinking the name=, value=, which didn't fit. I'll include that in today now that the implementation is already done |
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.
Looks great
Codecov Report
@@ Coverage Diff @@
## develop #410 +/- ##
========================================
Coverage 99.89% 99.89%
========================================
Files 100 100
Lines 3779 3827 +48
Branches 175 178 +3
========================================
+ Hits 3775 3823 +48
Misses 1 1
Partials 3 3
Continue to review full report at Codecov.
|
Issue #, if available: #406
Description of changes:
Checklist
set_default_dimensions
methodclear_default_dimensions
methodUX
Persists two dimensions across all metrics, every Metrics instance throughout the codebase, and across all Lambda invocations.
Breaking change checklist
RFC issue #:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.