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
[metrics] Templatized Metrics API #36449
Conversation
this adds compile-time checking that the type of the value and the size of the labels and optional labels when recording a metric must match with the type and the size specified when the metric is registered.
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 doing this! Overall, this looks very good, but I think we can improve it further.
Please let me know if you have any questions. Thanks!
src/core/lib/channel/metrics.h
Outdated
@@ -87,37 +91,238 @@ class GlobalInstrumentsRegistry { | |||
using GlobalCallbackHandle = absl::variant<GlobalCallbackInt64GaugeHandle, | |||
GlobalCallbackDoubleGaugeHandle>; | |||
|
|||
template <typename ValueType, typename InstrumentType, std::size_t M, |
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.
With all the new template stuff here, it's much harder for a reader to understand the API simply by reading the code. Can you please add a long comment immediately above the GlobalInstrumentsRegistry
class that explains how it is expected to be used, both by code defining metrics and by stats plugins?
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.
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.
This looks really good! Just a few minor comments.
Please let me know if you have any questions. 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.
This is really close! Just a few minor comments remaining.
Please let me know if you have any questions. 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.
Thanks Mark!
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.
This looks fantastic! Thanks for doing this!
This adds compile-time checking that the type of the value and the size of the labels and optional labels passed when recording a metric must match with the type and the size specified when the metric is registered.
The RegistrationBuilder API idea is credited to @ctiller.