From 80d9cba5bc0a902529c0ee0864edb49f8b8d4cf6 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Fri, 28 Jun 2024 10:40:52 -0700 Subject: [PATCH] [StatsPlugin] Plumb channel args through `StatsPluginChannelScope` This allows CallTracers to be created with parameters dictated by channel args. For the moment, I've used the EventEngine `EndpointConfig` API to expose the channel args here, so as to avoid directly exposing `grpc_core::ChannelArgs`. We should determine a better API here before we de-experimentalize the stats APIs. Also add an experiment to be used in a subsequent PR. PiperOrigin-RevId: 647730284 --- BUILD | 2 + bazel/experiments.bzl | 1 + include/grpc/support/metrics.h | 16 ++++++-- src/core/BUILD | 1 + src/core/client_channel/client_channel.cc | 7 +++- src/core/lib/experiments/experiments.cc | 15 ++++++++ src/core/lib/experiments/experiments.h | 8 ++++ src/core/lib/experiments/experiments.yaml | 5 +++ src/core/lib/surface/legacy_channel.cc | 6 ++- src/core/xds/grpc/xds_client_grpc.cc | 5 ++- test/core/telemetry/metrics_test.cc | 45 +++++++++++++---------- test/cpp/ext/otel/otel_plugin_test.cc | 23 +++++++++--- 12 files changed, 102 insertions(+), 32 deletions(-) diff --git a/BUILD b/BUILD index c0bcb493f12..9745ce61a69 100644 --- a/BUILD +++ b/BUILD @@ -1822,6 +1822,7 @@ grpc_cc_library( "//src/core:arena", "//src/core:call_arena_allocator", "//src/core:channel_args", + "//src/core:channel_args_endpoint_config", "//src/core:channel_fwd", "//src/core:channel_init", "//src/core:channel_stack_type", @@ -3799,6 +3800,7 @@ grpc_cc_library( "//src/core:call_spine", "//src/core:cancel_callback", "//src/core:channel_args", + "//src/core:channel_args_endpoint_config", "//src/core:channel_fwd", "//src/core:channel_init", "//src/core:channel_stack_type", diff --git a/bazel/experiments.bzl b/bazel/experiments.bzl index 1e58632622a..8774185732a 100644 --- a/bazel/experiments.bzl +++ b/bazel/experiments.bzl @@ -18,6 +18,7 @@ EXPERIMENT_ENABLES = { "call_status_override_on_cancellation": "call_status_override_on_cancellation", + "call_tracer_in_transport": "call_tracer_in_transport", "canary_client_privacy": "canary_client_privacy", "client_privacy": "client_privacy", "event_engine_client": "event_engine_client", diff --git a/include/grpc/support/metrics.h b/include/grpc/support/metrics.h index 7462e6aba65..20d9833385d 100644 --- a/include/grpc/support/metrics.h +++ b/include/grpc/support/metrics.h @@ -17,6 +17,7 @@ #include "absl/strings/string_view.h" +#include #include namespace grpc_core { @@ -26,9 +27,10 @@ namespace experimental { // plugins. class StatsPluginChannelScope { public: - StatsPluginChannelScope(absl::string_view target, - absl::string_view default_authority) - : target_(target), default_authority_(default_authority) {} + StatsPluginChannelScope( + absl::string_view target, absl::string_view default_authority, + const grpc_event_engine::experimental::EndpointConfig& args) + : target_(target), default_authority_(default_authority), args_(args) {} /// Returns the target used for creating the channel in the canonical form. /// (Canonicalized target definition - @@ -36,13 +38,21 @@ class StatsPluginChannelScope { absl::string_view target() const { return target_; } /// Returns the default authority for the channel. absl::string_view default_authority() const { return default_authority_; } + /// Returns channel arguments. + // TODO(roth, ctiller, yashkt): Find a better representation for + // channel args before de-experimentalizing this API. + const grpc_event_engine::experimental::EndpointConfig& args() const { + return args_; + } private: // Disable copy constructor and copy-assignment operator. StatsPluginChannelScope(const StatsPluginChannelScope&) = delete; StatsPluginChannelScope& operator=(const StatsPluginChannelScope&) = delete; + absl::string_view target_; absl::string_view default_authority_; + const grpc_event_engine::experimental::EndpointConfig& args_; }; } // namespace experimental diff --git a/src/core/BUILD b/src/core/BUILD index f711c07c4e5..2b32c215d37 100644 --- a/src/core/BUILD +++ b/src/core/BUILD @@ -5298,6 +5298,7 @@ grpc_cc_library( "certificate_provider_factory", "certificate_provider_registry", "channel_args", + "channel_args_endpoint_config", "channel_creds_registry", "channel_fwd", "closure", diff --git a/src/core/client_channel/client_channel.cc b/src/core/client_channel/client_channel.cc index de84331fefe..4bc8e44b333 100644 --- a/src/core/client_channel/client_channel.cc +++ b/src/core/client_channel/client_channel.cc @@ -61,6 +61,7 @@ #include "src/core/lib/channel/status_util.h" #include "src/core/lib/config/core_configuration.h" #include "src/core/lib/debug/trace.h" +#include "src/core/lib/event_engine/channel_args_endpoint_config.h" #include "src/core/lib/gprpp/crash.h" #include "src/core/lib/gprpp/debug_location.h" #include "src/core/lib/gprpp/sync.h" @@ -637,8 +638,10 @@ ClientChannel::ClientChannel( keepalive_time_ = -1; // unset } // Get stats plugins for channel. - experimental::StatsPluginChannelScope scope(this->target(), - default_authority_); + grpc_event_engine::experimental::ChannelArgsEndpointConfig endpoint_config( + channel_args_); + experimental::StatsPluginChannelScope scope( + this->target(), default_authority_, endpoint_config); stats_plugin_group_ = GlobalStatsPluginRegistry::GetStatsPluginsForChannel(scope); } diff --git a/src/core/lib/experiments/experiments.cc b/src/core/lib/experiments/experiments.cc index abaf294db5a..e100621f1d0 100644 --- a/src/core/lib/experiments/experiments.cc +++ b/src/core/lib/experiments/experiments.cc @@ -27,6 +27,9 @@ const char* const description_call_status_override_on_cancellation = "with cancellation."; const char* const additional_constraints_call_status_override_on_cancellation = "{}"; +const char* const description_call_tracer_in_transport = + "Transport directly passes byte counts to CallTracer."; +const char* const additional_constraints_call_tracer_in_transport = "{}"; const char* const description_canary_client_privacy = "If set, canary client privacy"; const char* const additional_constraints_canary_client_privacy = "{}"; @@ -121,6 +124,8 @@ const ExperimentMetadata g_experiment_metadata[] = { description_call_status_override_on_cancellation, additional_constraints_call_status_override_on_cancellation, nullptr, 0, true, true}, + {"call_tracer_in_transport", description_call_tracer_in_transport, + additional_constraints_call_tracer_in_transport, nullptr, 0, false, true}, {"canary_client_privacy", description_canary_client_privacy, additional_constraints_canary_client_privacy, nullptr, 0, false, false}, {"client_privacy", description_client_privacy, @@ -189,6 +194,9 @@ const char* const description_call_status_override_on_cancellation = "with cancellation."; const char* const additional_constraints_call_status_override_on_cancellation = "{}"; +const char* const description_call_tracer_in_transport = + "Transport directly passes byte counts to CallTracer."; +const char* const additional_constraints_call_tracer_in_transport = "{}"; const char* const description_canary_client_privacy = "If set, canary client privacy"; const char* const additional_constraints_canary_client_privacy = "{}"; @@ -283,6 +291,8 @@ const ExperimentMetadata g_experiment_metadata[] = { description_call_status_override_on_cancellation, additional_constraints_call_status_override_on_cancellation, nullptr, 0, true, true}, + {"call_tracer_in_transport", description_call_tracer_in_transport, + additional_constraints_call_tracer_in_transport, nullptr, 0, false, true}, {"canary_client_privacy", description_canary_client_privacy, additional_constraints_canary_client_privacy, nullptr, 0, false, false}, {"client_privacy", description_client_privacy, @@ -351,6 +361,9 @@ const char* const description_call_status_override_on_cancellation = "with cancellation."; const char* const additional_constraints_call_status_override_on_cancellation = "{}"; +const char* const description_call_tracer_in_transport = + "Transport directly passes byte counts to CallTracer."; +const char* const additional_constraints_call_tracer_in_transport = "{}"; const char* const description_canary_client_privacy = "If set, canary client privacy"; const char* const additional_constraints_canary_client_privacy = "{}"; @@ -445,6 +458,8 @@ const ExperimentMetadata g_experiment_metadata[] = { description_call_status_override_on_cancellation, additional_constraints_call_status_override_on_cancellation, nullptr, 0, true, true}, + {"call_tracer_in_transport", description_call_tracer_in_transport, + additional_constraints_call_tracer_in_transport, nullptr, 0, false, true}, {"canary_client_privacy", description_canary_client_privacy, additional_constraints_canary_client_privacy, nullptr, 0, false, false}, {"client_privacy", description_client_privacy, diff --git a/src/core/lib/experiments/experiments.h b/src/core/lib/experiments/experiments.h index 9281a350d32..a1b2662ed4d 100644 --- a/src/core/lib/experiments/experiments.h +++ b/src/core/lib/experiments/experiments.h @@ -59,6 +59,7 @@ namespace grpc_core { #if defined(GRPC_CFSTREAM) #define GRPC_EXPERIMENT_IS_INCLUDED_CALL_STATUS_OVERRIDE_ON_CANCELLATION inline bool IsCallStatusOverrideOnCancellationEnabled() { return true; } +inline bool IsCallTracerInTransportEnabled() { return false; } inline bool IsCanaryClientPrivacyEnabled() { return false; } inline bool IsClientPrivacyEnabled() { return false; } inline bool IsEventEngineClientEnabled() { return false; } @@ -92,6 +93,7 @@ inline bool IsWorkSerializerDispatchEnabled() { return false; } #elif defined(GPR_WINDOWS) #define GRPC_EXPERIMENT_IS_INCLUDED_CALL_STATUS_OVERRIDE_ON_CANCELLATION inline bool IsCallStatusOverrideOnCancellationEnabled() { return true; } +inline bool IsCallTracerInTransportEnabled() { return false; } inline bool IsCanaryClientPrivacyEnabled() { return false; } inline bool IsClientPrivacyEnabled() { return false; } #define GRPC_EXPERIMENT_IS_INCLUDED_EVENT_ENGINE_CLIENT @@ -128,6 +130,7 @@ inline bool IsWorkSerializerDispatchEnabled() { return false; } #else #define GRPC_EXPERIMENT_IS_INCLUDED_CALL_STATUS_OVERRIDE_ON_CANCELLATION inline bool IsCallStatusOverrideOnCancellationEnabled() { return true; } +inline bool IsCallTracerInTransportEnabled() { return false; } inline bool IsCanaryClientPrivacyEnabled() { return false; } inline bool IsClientPrivacyEnabled() { return false; } inline bool IsEventEngineClientEnabled() { return false; } @@ -165,6 +168,7 @@ inline bool IsWorkSerializerDispatchEnabled() { return true; } #else enum ExperimentIds { kExperimentIdCallStatusOverrideOnCancellation, + kExperimentIdCallTracerInTransport, kExperimentIdCanaryClientPrivacy, kExperimentIdClientPrivacy, kExperimentIdEventEngineClient, @@ -195,6 +199,10 @@ enum ExperimentIds { inline bool IsCallStatusOverrideOnCancellationEnabled() { return IsExperimentEnabled(); } +#define GRPC_EXPERIMENT_IS_INCLUDED_CALL_TRACER_IN_TRANSPORT +inline bool IsCallTracerInTransportEnabled() { + return IsExperimentEnabled(); +} #define GRPC_EXPERIMENT_IS_INCLUDED_CANARY_CLIENT_PRIVACY inline bool IsCanaryClientPrivacyEnabled() { return IsExperimentEnabled(); diff --git a/src/core/lib/experiments/experiments.yaml b/src/core/lib/experiments/experiments.yaml index f888e0017e4..db570744011 100644 --- a/src/core/lib/experiments/experiments.yaml +++ b/src/core/lib/experiments/experiments.yaml @@ -47,6 +47,11 @@ expiry: 2024/08/01 owner: vigneshbabu@google.com test_tags: [] +- name: call_tracer_in_transport + description: Transport directly passes byte counts to CallTracer. + expiry: 2024/09/30 + owner: roth@google.com + test_tags: [] - name: canary_client_privacy description: If set, canary client privacy diff --git a/src/core/lib/surface/legacy_channel.cc b/src/core/lib/surface/legacy_channel.cc index 57196e97c63..d1986939ad5 100644 --- a/src/core/lib/surface/legacy_channel.cc +++ b/src/core/lib/surface/legacy_channel.cc @@ -37,6 +37,7 @@ #include "src/core/lib/channel/channel_stack.h" #include "src/core/lib/channel/channel_stack_builder_impl.h" #include "src/core/lib/config/core_configuration.h" +#include "src/core/lib/event_engine/channel_args_endpoint_config.h" #include "src/core/lib/gprpp/crash.h" #include "src/core/lib/gprpp/dual_ref_counted.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" @@ -107,7 +108,10 @@ absl::StatusOr> LegacyChannel::Create( .value_or(CoreConfiguration::Get() .resolver_registry() .GetDefaultAuthority(target)); - experimental::StatsPluginChannelScope scope(target, authority); + grpc_event_engine::experimental::ChannelArgsEndpointConfig endpoint_config( + args); + experimental::StatsPluginChannelScope scope(target, authority, + endpoint_config); *(*r)->stats_plugin_group = GlobalStatsPluginRegistry::GetStatsPluginsForChannel(scope); // Add per-channel stats plugins. diff --git a/src/core/xds/grpc/xds_client_grpc.cc b/src/core/xds/grpc/xds_client_grpc.cc index a1899f47673..96492ff31ff 100644 --- a/src/core/xds/grpc/xds_client_grpc.cc +++ b/src/core/xds/grpc/xds_client_grpc.cc @@ -41,6 +41,7 @@ #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/debug/trace.h" +#include "src/core/lib/event_engine/channel_args_endpoint_config.h" #include "src/core/lib/event_engine/default_event_engine.h" #include "src/core/lib/gprpp/debug_location.h" #include "src/core/lib/gprpp/env.h" @@ -283,8 +284,10 @@ GlobalStatsPluginRegistry::StatsPluginGroup GetStatsPluginGroupForKey( if (key == GrpcXdsClient::kServerKey) { return GlobalStatsPluginRegistry::GetStatsPluginsForServer(ChannelArgs{}); } + grpc_event_engine::experimental::ChannelArgsEndpointConfig endpoint_config( + ChannelArgs{}); // TODO(roth): How do we set the authority here? - experimental::StatsPluginChannelScope scope(key, ""); + experimental::StatsPluginChannelScope scope(key, "", endpoint_config); return GlobalStatsPluginRegistry::GetStatsPluginsForChannel(scope); } diff --git a/test/core/telemetry/metrics_test.cc b/test/core/telemetry/metrics_test.cc index a57a0118ae7..8c492cb698f 100644 --- a/test/core/telemetry/metrics_test.cc +++ b/test/core/telemetry/metrics_test.cc @@ -20,6 +20,7 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" +#include "src/core/lib/event_engine/channel_args_endpoint_config.h" #include "test/core/test_util/fake_stats_plugin.h" #include "test/core/test_util/test_config.h" @@ -29,11 +30,15 @@ namespace { using experimental::StatsPluginChannelScope; class MetricsTest : public ::testing::Test { - public: + protected: + MetricsTest() : endpoint_config_(ChannelArgs()) {} + void TearDown() override { GlobalInstrumentsRegistryTestPeer::ResetGlobalInstrumentsRegistry(); GlobalStatsPluginRegistryTestPeer::ResetGlobalStatsPluginRegistry(); } + + grpc_event_engine::experimental::ChannelArgsEndpointConfig endpoint_config_; }; TEST_F(MetricsTest, UInt64Counter) { @@ -54,15 +59,15 @@ TEST_F(MetricsTest, UInt64Counter) { auto plugin2 = MakeStatsPluginForTarget(kDomain2To4); auto plugin3 = MakeStatsPluginForTarget(kDomain3To4); GlobalStatsPluginRegistry::GetStatsPluginsForChannel( - StatsPluginChannelScope(kDomain1To4, "")) + StatsPluginChannelScope(kDomain1To4, "", endpoint_config_)) .AddCounter(uint64_counter_handle, uint64_t(1), kLabelValues, kOptionalLabelValues); GlobalStatsPluginRegistry::GetStatsPluginsForChannel( - StatsPluginChannelScope(kDomain2To4, "")) + StatsPluginChannelScope(kDomain2To4, "", endpoint_config_)) .AddCounter(uint64_counter_handle, uint64_t(2), kLabelValues, kOptionalLabelValues); GlobalStatsPluginRegistry::GetStatsPluginsForChannel( - StatsPluginChannelScope(kDomain3To4, "")) + StatsPluginChannelScope(kDomain3To4, "", endpoint_config_)) .AddCounter(uint64_counter_handle, uint64_t(3), kLabelValues, kOptionalLabelValues); EXPECT_THAT(plugin1->GetUInt64CounterValue( @@ -94,15 +99,15 @@ TEST_F(MetricsTest, DoubleCounter) { auto plugin2 = MakeStatsPluginForTarget(kDomain2To4); auto plugin3 = MakeStatsPluginForTarget(kDomain3To4); GlobalStatsPluginRegistry::GetStatsPluginsForChannel( - StatsPluginChannelScope(kDomain1To4, "")) + StatsPluginChannelScope(kDomain1To4, "", endpoint_config_)) .AddCounter(double_counter_handle, 1.23, kLabelValues, kOptionalLabelValues); GlobalStatsPluginRegistry::GetStatsPluginsForChannel( - StatsPluginChannelScope(kDomain2To4, "")) + StatsPluginChannelScope(kDomain2To4, "", endpoint_config_)) .AddCounter(double_counter_handle, 2.34, kLabelValues, kOptionalLabelValues); GlobalStatsPluginRegistry::GetStatsPluginsForChannel( - StatsPluginChannelScope(kDomain3To4, "")) + StatsPluginChannelScope(kDomain3To4, "", endpoint_config_)) .AddCounter(double_counter_handle, 3.45, kLabelValues, kOptionalLabelValues); EXPECT_THAT(plugin1->GetDoubleCounterValue( @@ -134,15 +139,15 @@ TEST_F(MetricsTest, UInt64Histogram) { auto plugin2 = MakeStatsPluginForTarget(kDomain2To4); auto plugin3 = MakeStatsPluginForTarget(kDomain3To4); GlobalStatsPluginRegistry::GetStatsPluginsForChannel( - StatsPluginChannelScope(kDomain1To4, "")) + StatsPluginChannelScope(kDomain1To4, "", endpoint_config_)) .RecordHistogram(uint64_histogram_handle, uint64_t(1), kLabelValues, kOptionalLabelValues); GlobalStatsPluginRegistry::GetStatsPluginsForChannel( - StatsPluginChannelScope(kDomain2To4, "")) + StatsPluginChannelScope(kDomain2To4, "", endpoint_config_)) .RecordHistogram(uint64_histogram_handle, uint64_t(2), kLabelValues, kOptionalLabelValues); GlobalStatsPluginRegistry::GetStatsPluginsForChannel( - StatsPluginChannelScope(kDomain3To4, "")) + StatsPluginChannelScope(kDomain3To4, "", endpoint_config_)) .RecordHistogram(uint64_histogram_handle, uint64_t(3), kLabelValues, kOptionalLabelValues); EXPECT_THAT(plugin1->GetUInt64HistogramValue( @@ -174,15 +179,15 @@ TEST_F(MetricsTest, DoubleHistogram) { auto plugin2 = MakeStatsPluginForTarget(kDomain2To4); auto plugin3 = MakeStatsPluginForTarget(kDomain3To4); GlobalStatsPluginRegistry::GetStatsPluginsForChannel( - StatsPluginChannelScope(kDomain1To4, "")) + StatsPluginChannelScope(kDomain1To4, "", endpoint_config_)) .RecordHistogram(double_histogram_handle, 1.23, kLabelValues, kOptionalLabelValues); GlobalStatsPluginRegistry::GetStatsPluginsForChannel( - StatsPluginChannelScope(kDomain2To4, "")) + StatsPluginChannelScope(kDomain2To4, "", endpoint_config_)) .RecordHistogram(double_histogram_handle, 2.34, kLabelValues, kOptionalLabelValues); GlobalStatsPluginRegistry::GetStatsPluginsForChannel( - StatsPluginChannelScope(kDomain3To4, "")) + StatsPluginChannelScope(kDomain3To4, "", endpoint_config_)) .RecordHistogram(double_histogram_handle, 3.45, kLabelValues, kOptionalLabelValues); EXPECT_THAT(plugin1->GetDoubleHistogramValue( @@ -220,7 +225,7 @@ TEST_F(MetricsTest, Int64CallbackGauge) { // label values. The callbacks get used only by plugin1. LOG(INFO) << "testing callbacks for: plugin1"; auto group1 = GlobalStatsPluginRegistry::GetStatsPluginsForChannel( - StatsPluginChannelScope(kDomain3To4, "")); + StatsPluginChannelScope(kDomain3To4, "", endpoint_config_)); auto callback1 = group1.RegisterCallback( [&](CallbackMetricReporter& reporter) { reporter.Report(int64_gauge_handle, int64_t(1), kLabelValues, @@ -281,7 +286,7 @@ TEST_F(MetricsTest, Int64CallbackGauge) { // Now register callbacks that hit both plugin1 and plugin2. LOG(INFO) << "testing callbacks for: plugin1, plugin2"; auto group2 = GlobalStatsPluginRegistry::GetStatsPluginsForChannel( - StatsPluginChannelScope(kDomain2To4, "")); + StatsPluginChannelScope(kDomain2To4, "", endpoint_config_)); callback1 = group2.RegisterCallback( [&](CallbackMetricReporter& reporter) { reporter.Report(int64_gauge_handle, int64_t(3), kLabelValues, @@ -342,7 +347,7 @@ TEST_F(MetricsTest, Int64CallbackGauge) { // Now register callbacks that hit all three plugins. LOG(INFO) << "testing callbacks for: plugin1, plugin2, plugin3"; auto group3 = GlobalStatsPluginRegistry::GetStatsPluginsForChannel( - StatsPluginChannelScope(kDomain1To4, "")); + StatsPluginChannelScope(kDomain1To4, "", endpoint_config_)); callback1 = group3.RegisterCallback( [&](CallbackMetricReporter& reporter) { reporter.Report(int64_gauge_handle, int64_t(5), kLabelValues, @@ -425,7 +430,7 @@ TEST_F(MetricsTest, DoubleCallbackGauge) { // label values. The callbacks get used only by plugin1. LOG(INFO) << "testing callbacks for: plugin1"; auto group1 = GlobalStatsPluginRegistry::GetStatsPluginsForChannel( - StatsPluginChannelScope(kDomain3To4, "")); + StatsPluginChannelScope(kDomain3To4, "", endpoint_config_)); auto callback1 = group1.RegisterCallback( [&](CallbackMetricReporter& reporter) { reporter.Report(double_gauge_handle, 1.23, kLabelValues, @@ -486,7 +491,7 @@ TEST_F(MetricsTest, DoubleCallbackGauge) { // Now register callbacks that hit both plugin1 and plugin2. LOG(INFO) << "testing callbacks for: plugin1, plugin2"; auto group2 = GlobalStatsPluginRegistry::GetStatsPluginsForChannel( - StatsPluginChannelScope(kDomain2To4, "")); + StatsPluginChannelScope(kDomain2To4, "", endpoint_config_)); callback1 = group2.RegisterCallback( [&](CallbackMetricReporter& reporter) { reporter.Report(double_gauge_handle, 3.45, kLabelValues, @@ -547,7 +552,7 @@ TEST_F(MetricsTest, DoubleCallbackGauge) { // Now register callbacks that hit all three plugins. LOG(INFO) << "testing callbacks for: plugin1, plugin2, plugin3"; auto group3 = GlobalStatsPluginRegistry::GetStatsPluginsForChannel( - StatsPluginChannelScope(kDomain1To4, "")); + StatsPluginChannelScope(kDomain1To4, "", endpoint_config_)); callback1 = group3.RegisterCallback( [&](CallbackMetricReporter& reporter) { reporter.Report(double_gauge_handle, 5.67, kLabelValues, @@ -621,7 +626,7 @@ TEST_F(MetricsTest, DisableByDefaultMetricIsNotRecordedByFakeStatsPlugin) { constexpr absl::string_view kDomain1To4 = "domain1.domain2.domain3.domain4"; auto plugin = MakeStatsPluginForTarget(kDomain1To4); GlobalStatsPluginRegistry::GetStatsPluginsForChannel( - StatsPluginChannelScope(kDomain1To4, "")) + StatsPluginChannelScope(kDomain1To4, "", endpoint_config_)) .RecordHistogram(double_histogram_handle, 1.23, kLabelValues, kOptionalLabelValues); EXPECT_EQ(plugin->GetDoubleHistogramValue(double_histogram_handle, diff --git a/test/cpp/ext/otel/otel_plugin_test.cc b/test/cpp/ext/otel/otel_plugin_test.cc index ad7bc11d565..863181f2d34 100644 --- a/test/cpp/ext/otel/otel_plugin_test.cc +++ b/test/cpp/ext/otel/otel_plugin_test.cc @@ -39,6 +39,7 @@ #include #include "src/core/lib/config/core_configuration.h" +#include "src/core/lib/event_engine/channel_args_endpoint_config.h" #include "src/core/telemetry/call_tracer.h" #include "test/core/test_util/fake_stats_plugin.h" #include "test/core/test_util/test_config.h" @@ -1286,6 +1287,9 @@ TEST_F(OpenTelemetryPluginOptionEnd2EndTest, class OpenTelemetryPluginNPCMetricsTest : public OpenTelemetryPluginEnd2EndTest { protected: + OpenTelemetryPluginNPCMetricsTest() + : endpoint_config_(grpc_core::ChannelArgs()) {} + void TearDown() override { // We are tearing down OpenTelemetryPluginEnd2EndTest first to ensure that // gRPC has shutdown before we reset the instruments registry. @@ -1293,6 +1297,8 @@ class OpenTelemetryPluginNPCMetricsTest grpc_core::GlobalInstrumentsRegistryTestPeer:: ResetGlobalInstrumentsRegistry(); } + + grpc_event_engine::experimental::ChannelArgsEndpointConfig endpoint_config_; }; TEST_F(OpenTelemetryPluginNPCMetricsTest, RecordUInt64Counter) { @@ -1327,7 +1333,7 @@ TEST_F(OpenTelemetryPluginNPCMetricsTest, RecordUInt64Counter) { auto stats_plugins = grpc_core::GlobalStatsPluginRegistry::GetStatsPluginsForChannel( grpc_core::experimental::StatsPluginChannelScope( - "dns:///localhost:8080", "")); + "dns:///localhost:8080", "", endpoint_config_)); for (auto v : kCounterValues) { stats_plugins.AddCounter(handle, v, kLabelValues, kOptionalLabelValues); } @@ -1377,7 +1383,7 @@ TEST_F(OpenTelemetryPluginNPCMetricsTest, RecordDoubleCounter) { auto stats_plugins = grpc_core::GlobalStatsPluginRegistry::GetStatsPluginsForChannel( grpc_core::experimental::StatsPluginChannelScope( - "dns:///localhost:8080", "")); + "dns:///localhost:8080", "", endpoint_config_)); for (auto v : kCounterValues) { stats_plugins.AddCounter(handle, v, kLabelValues, kOptionalLabelValues); } @@ -1709,7 +1715,14 @@ TEST_F(OpenTelemetryPluginNPCMetricsTest, InstrumentsEnabledTest) { EXPECT_FALSE(stats_plugins.IsInstrumentEnabled(counter_handle)); } -using OpenTelemetryPluginCallbackMetricsTest = OpenTelemetryPluginEnd2EndTest; +class OpenTelemetryPluginCallbackMetricsTest + : public OpenTelemetryPluginEnd2EndTest { + protected: + OpenTelemetryPluginCallbackMetricsTest() + : endpoint_config_(grpc_core::ChannelArgs()) {} + + grpc_event_engine::experimental::ChannelArgsEndpointConfig endpoint_config_; +}; // The callback minimal interval is longer than the OT reporting interval, so we // expect to collect duplicated (cached) values. @@ -1753,7 +1766,7 @@ TEST_F(OpenTelemetryPluginCallbackMetricsTest, auto stats_plugins = grpc_core::GlobalStatsPluginRegistry::GetStatsPluginsForChannel( grpc_core::experimental::StatsPluginChannelScope( - "dns:///localhost:8080", "")); + "dns:///localhost:8080", "", endpoint_config_)); // Multiple callbacks for the same metrics, each reporting different // label values. int report_count_1 = 0; @@ -1888,7 +1901,7 @@ TEST_F(OpenTelemetryPluginCallbackMetricsTest, auto stats_plugins = grpc_core::GlobalStatsPluginRegistry::GetStatsPluginsForChannel( grpc_core::experimental::StatsPluginChannelScope( - "dns:///localhost:8080", "")); + "dns:///localhost:8080", "", endpoint_config_)); // Multiple callbacks for the same metrics, each reporting different // label values. int report_count_1 = 0;