Skip to content
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

Closed
wants to merge 16 commits into from

Conversation

yijiem
Copy link
Member

@yijiem yijiem commented Apr 24, 2024

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.

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.
@yijiem yijiem requested review from yashykt and ctiller April 24, 2024 23:30
@yijiem yijiem requested a review from markdroth as a code owner April 24, 2024 23:30
@yijiem yijiem added the release notes: no Indicates if PR should not be in release notes label Apr 24, 2024
@yijiem yijiem changed the title [metrics] Templatized metrics API [metrics] Templatized Metrics API Apr 24, 2024
Copy link
Member

@markdroth markdroth left a 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!

@@ -87,37 +91,238 @@ class GlobalInstrumentsRegistry {
using GlobalCallbackHandle = absl::variant<GlobalCallbackInt64GaugeHandle,
GlobalCallbackDoubleGaugeHandle>;

template <typename ValueType, typename InstrumentType, std::size_t M,
Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

src/core/lib/channel/metrics.h Outdated Show resolved Hide resolved
src/core/lib/channel/metrics.h Outdated Show resolved Hide resolved
src/core/ext/xds/xds_client_grpc.cc Outdated Show resolved Hide resolved
Copy link
Member

@markdroth markdroth left a 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!

src/core/lib/channel/metrics.h Outdated Show resolved Hide resolved
src/core/lib/channel/metrics.h Outdated Show resolved Hide resolved
src/core/lib/channel/metrics.h Outdated Show resolved Hide resolved
src/core/ext/xds/xds_client_grpc.cc Outdated Show resolved Hide resolved
src/core/load_balancing/rls/rls.cc Outdated Show resolved Hide resolved
Copy link
Member

@markdroth markdroth left a 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!

src/core/lib/channel/metrics.h Outdated Show resolved Hide resolved
src/core/lib/channel/metrics.h Outdated Show resolved Hide resolved
src/core/load_balancing/rls/rls.cc Outdated Show resolved Hide resolved
Copy link
Member Author

@yijiem yijiem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Mark!

src/core/lib/channel/metrics.h Outdated Show resolved Hide resolved
src/core/lib/channel/metrics.h Outdated Show resolved Hide resolved
src/core/load_balancing/rls/rls.cc Outdated Show resolved Hide resolved
Copy link
Member

@markdroth markdroth left a 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!

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

Successfully merging this pull request may close these issues.

None yet

2 participants