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;