-
Notifications
You must be signed in to change notification settings - Fork 153
feat: add metrics #102
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: add metrics #102
Conversation
Coverage after merging feature/metrics into main
Coverage Report
|
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.
Left a couple comments, most of them are non-blocking.
private serviceVariable = 'POWERTOOLS_SERVICE_NAME'; | ||
|
||
public get(name: string): string { | ||
return process.env[name]?.trim() || ''; |
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 may not have caught usages of this, but why return an empty string instead of undefined
? Personally I find undefined
clearer than an empty string, but I'm aware that this would lead to a string | undefined
in a lot of signatures.
Noticed if (targetService.length > 0) {
in Metrics.ts
which could be reduced to if (targetService)
.
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 think this logic was taken from the Logger. I do not have a strong opinion on this, my reasoning was that an environment variable is always a string.
Happy to revisit this!
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 did take this from the logger, But slightly agree with @saragerion that ENV vars should always be strings,
Whatever we decide here I think we should apply it consistently across the pacakges
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.
@bahrmichael what's your take on this? One of these:
- Keep it as it is;
- Change it as you suggested, for the beta;
- Create a ticket to explore the issue after the beta;
I am in favour of 1 or 3.
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'm in favor of 3.
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've raised a placeholder issue #165 for visibility of this across all modules
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 your PR @alan-churley! 🎉
I left few comments, nothing major but curious to get yours and everyone's perspective on the points raised.
Let me know if you have any question.
Forgot to add: before implementing any significant changes related to feedback, it would be good to understand the pro's and cons' of incorporating this library https://github.com/awslabs/aws-embedded-metrics-node and regardless of the decision taken, record the decision with motivation inside the related issue #25 (for posterity and transparency). |
I have somewhat fresh experience from attaching this library to aws-sdk calls. Feel free to reach out to chat about its pros and cons. |
Coverage after merging feature/metrics into main
Coverage Report
|
Coverage after merging feature/metrics into main
Coverage Report
|
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.
great job @alan-churley ! I left a new round of comments - none of them are major or a priority for the beta, but let's keep track of possible improvement points via issues please.
Happy to approve once this is done!
private serviceVariable = 'POWERTOOLS_SERVICE_NAME'; | ||
|
||
public get(name: string): string { | ||
return process.env[name]?.trim() || ''; |
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.
@bahrmichael what's your take on this? One of these:
- Keep it as it is;
- Change it as you suggested, for the beta;
- Create a ticket to explore the issue after the beta;
I am in favour of 1 or 3.
Coverage after merging feature/metrics into main
Coverage Report
|
Coverage after merging feature/metrics into main
Coverage Report
|
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.
throw new RangeError('The number of metrics recorded must be higher than zero'); | ||
} | ||
|
||
/* TODO: Potentially a logger.warn users here if default namespace should be used? */ |
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.
What is the default namespace? "Default"? +1 for adding a console.warn.
Description of your changes
Initial draft of the Metrics module,
It's rough, so feedback is very welcome
How to verify this change
Related issues, RFCs
#25
PR status
Is this ready for review?: YES
Is it a breaking change?: NO
Checklist
Breaking change checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.