-
Notifications
You must be signed in to change notification settings - Fork 39
Add publicly accessible units #49
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
Conversation
aws_embedded_metrics/constants.py
Outdated
@@ -14,3 +14,31 @@ | |||
DEFAULT_NAMESPACE = "aws-embedded-metrics" | |||
MAX_DIMENSIONS = 9 | |||
MAX_METRICS_PER_EVENT = 100 | |||
|
|||
# Units | |||
SECONDS = "Seconds" |
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.
Thanks for the PR! Can we namespace (e.g. Units.SECONDS
) these rather than dropping them in as constants?
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.
The most pythonic way that comes to mind to namespace is moving these constants to a new file called units.py
. Happy to implement this in the next revision or any alternative preferred. Please let me know, thanks!
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.
Another option would be use an Enum
for the units. That'd have the advantage to play nicely with typing
.
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 agree—I think that an enum is the preferred option here. This is what we do in the node and java libraries.
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.
The thing I didn't really like with enum is that we'd access the string with something like Units.SECONDS.value
, but I'm okay with that given the packages you linked use enum for units for consistency. One more question before I submit the next revision - should I create a new file, unit.py
?
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.
is that we'd access the string with something like Units.SECONDS.value
I think for this version that should be okay. In the next breaking version we may choose to replace the signature of put_metric
with the new enum type. Any strong disagreements with that approach?
should I create a new file, unit.py
Yes, I think that's a good choice and then we can add it as a top-level import.
Issue #, if available:
N/A
Description of changes:
Having
.now()
inutils
is nice. As a developer using this package, it would be also great to have publicly accessible constants for metric units available. It not only reduces the chance of silly spelling mistakes, but benefits discoverability outside of the documentation.https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_MetricDatum.html
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.