-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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] gRPC Non-Per-Call Metrics framework implementation #35871
Conversation
src/core/lib/channel/metrics.h
Outdated
// Creates instrument in the GlobalInstrumentsRegistry. | ||
static GlobalUInt64CounterHandle RegisterUInt64Counter( | ||
absl::string_view name, absl::string_view description, | ||
absl::string_view unit, std::vector<absl::string_view> label_keys, |
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.
Note that we want the MakeValueSet
optimization here, but I see the TODO down below, so I'm fine with this as a first iteration
test/core/channel/metrics_test.cc
Outdated
} | ||
|
||
template <class T> | ||
std::string MakeKey(T t) { |
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 is weird. I would much prefer you just create a FakeCounter and a FakeHistogram. That's going to make much more sense.
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 removed this. The FakeStatsPlugin
creates an instrument for each instruments in the GlobalInstrumentsRegistry
. It now uses the index to find the instrument that it created (as it should be used IIUC).
src/core/lib/channel/metrics.h
Outdated
absl::string_view unit, std::vector<absl::string_view> label_keys, | ||
std::vector<absl::string_view> optional_label_keys); | ||
|
||
static const GlobalCounterDescriptor& GetCounterDescriptor( |
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 don't see the point of the GetCounterDescriptor()
or GetHistogramDescriptor()
methods. We could just use the counters()
or histograms()
methods and use the handle as an index directly?
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.
If you are thinking of this as just a convenience method, I'm fine with it
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.
Removed. I combined counters()
and histograms()
into a single instruments()
method, PTAL.
namespace grpc_core { | ||
|
||
// Static only. | ||
class GlobalInstrumentsRegistry { |
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.
"Static initialization"
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.
std::vector<absl::string_view> label_keys; | ||
std::vector<absl::string_view> optional_label_keys; | ||
}; | ||
struct GlobalHandle { |
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 we should make it clear that we are using the handle as an index in docs, and that that is an API. (unless, we want to hide the fact that handle is just an index)
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.
Added some comment about the index. I think we can expose it so that StatsPlugins can use it to uniquely identify an instrument later with the handle. PTAL.
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.
GlobalInstrumentHandle? I think grpc_core::GlobalHandle
sounds very generic
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 like a great start!
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!
namespace grpc_core { | ||
|
||
// Static only. | ||
class GlobalInstrumentsRegistry { |
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 great! Remaining comments are minor.
Please let me know if you have any questions. Thanks!
This looks great! The only remaining issue is the one about not wrapping the |
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, modulo one minor comment. Feel free to merge after addressing.
Nice work!
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 fabulous! Feel free to merge after addressing the remaining comment.
channel_filter) | ||
: channel_filter_(std::move(channel_filter)) { | ||
GlobalInstrumentsRegistry::ForEach( | ||
[this](const GlobalInstrumentsRegistry::GlobalInstrumentDescriptor& | ||
descriptor) { | ||
if (!descriptor.enable_by_default) { |
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.
Please also add a test that covers adding a metric that is not enabled by default.
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.
Looks great!
No description provided.