From d623f31d978846a90cebcdc57d574547dc2d63bc Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Mon, 3 Jun 2024 15:35:47 -0700 Subject: [PATCH] [StatsPlugin] Reviewer comments from #36757 (#36787) Copybara missed the last commit on #36757 Closes #36787 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36787 from yashykt:36757Follow f62cf1eabd310366ef310ec566a5fef0276ed875 PiperOrigin-RevId: 639933826 --- src/core/telemetry/metrics.h | 4 ++-- src/cpp/ext/otel/otel_plugin.cc | 2 +- src/cpp/ext/otel/otel_plugin.h | 2 +- test/core/test_util/fake_stats_plugin.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core/telemetry/metrics.h b/src/core/telemetry/metrics.h index 55827c81a01..38a51b442f4 100644 --- a/src/core/telemetry/metrics.h +++ b/src/core/telemetry/metrics.h @@ -330,7 +330,7 @@ class StatsPlugin { virtual void RemoveCallback(RegisteredMetricCallback* callback) = 0; // Returns true if instrument \a handle is enabled. virtual bool IsInstrumentEnabled( - GlobalInstrumentsRegistry::GlobalInstrumentHandle handle) = 0; + GlobalInstrumentsRegistry::GlobalInstrumentHandle handle) const = 0; // Gets a ClientCallTracer associated with this stats plugin which can be used // in a call. @@ -429,7 +429,7 @@ class GlobalStatsPluginRegistry { // Returns true if any of the stats plugins in the group have enabled \a // handle. bool IsInstrumentEnabled( - GlobalInstrumentsRegistry::GlobalInstrumentHandle handle) { + GlobalInstrumentsRegistry::GlobalInstrumentHandle handle) const { for (auto& state : plugins_state_) { if (state.plugin->IsInstrumentEnabled(handle)) { return true; diff --git a/src/cpp/ext/otel/otel_plugin.cc b/src/cpp/ext/otel/otel_plugin.cc index 18cee7af41f..c4bd812fd3c 100644 --- a/src/cpp/ext/otel/otel_plugin.cc +++ b/src/cpp/ext/otel/otel_plugin.cc @@ -914,7 +914,7 @@ grpc_core::ServerCallTracer* OpenTelemetryPlugin::GetServerCallTracer( } bool OpenTelemetryPlugin::IsInstrumentEnabled( - grpc_core::GlobalInstrumentsRegistry::GlobalInstrumentHandle handle) { + grpc_core::GlobalInstrumentsRegistry::GlobalInstrumentHandle handle) const { return !absl::holds_alternative( instruments_data_.at(handle.index).instrument); } diff --git a/src/cpp/ext/otel/otel_plugin.h b/src/cpp/ext/otel/otel_plugin.h index 9928390222a..6a8c84fe43c 100644 --- a/src/cpp/ext/otel/otel_plugin.h +++ b/src/cpp/ext/otel/otel_plugin.h @@ -406,7 +406,7 @@ class OpenTelemetryPlugin : public grpc_core::StatsPlugin { override; bool IsInstrumentEnabled( grpc_core::GlobalInstrumentsRegistry::GlobalInstrumentHandle handle) - override; + const override; const absl::AnyInvocable& server_selector() const { diff --git a/test/core/test_util/fake_stats_plugin.h b/test/core/test_util/fake_stats_plugin.h index 045fffa443e..e9dcaa240a8 100644 --- a/test/core/test_util/fake_stats_plugin.h +++ b/test/core/test_util/fake_stats_plugin.h @@ -361,7 +361,7 @@ class FakeStatsPlugin : public StatsPlugin { return nullptr; } bool IsInstrumentEnabled( - GlobalInstrumentsRegistry::GlobalInstrumentHandle handle) override { + GlobalInstrumentsRegistry::GlobalInstrumentHandle handle) const override { const auto& descriptor = GlobalInstrumentsRegistry::GetInstrumentDescriptor(handle); return use_disabled_by_default_metrics_ || descriptor.enable_by_default;