[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
pull/37059/head
Mark D. Roth 8 months ago committed by Copybara-Service
parent 5c22745582
commit 80d9cba5bc
  1. 2
      BUILD
  2. 1
      bazel/experiments.bzl
  3. 16
      include/grpc/support/metrics.h
  4. 1
      src/core/BUILD
  5. 7
      src/core/client_channel/client_channel.cc
  6. 15
      src/core/lib/experiments/experiments.cc
  7. 8
      src/core/lib/experiments/experiments.h
  8. 5
      src/core/lib/experiments/experiments.yaml
  9. 6
      src/core/lib/surface/legacy_channel.cc
  10. 5
      src/core/xds/grpc/xds_client_grpc.cc
  11. 45
      test/core/telemetry/metrics_test.cc
  12. 23
      test/cpp/ext/otel/otel_plugin_test.cc

@ -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",

@ -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",

@ -17,6 +17,7 @@
#include "absl/strings/string_view.h"
#include <grpc/event_engine/endpoint_config.h>
#include <grpc/support/port_platform.h>
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

@ -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",

@ -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);
}

@ -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,

@ -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<kExperimentIdCallStatusOverrideOnCancellation>();
}
#define GRPC_EXPERIMENT_IS_INCLUDED_CALL_TRACER_IN_TRANSPORT
inline bool IsCallTracerInTransportEnabled() {
return IsExperimentEnabled<kExperimentIdCallTracerInTransport>();
}
#define GRPC_EXPERIMENT_IS_INCLUDED_CANARY_CLIENT_PRIVACY
inline bool IsCanaryClientPrivacyEnabled() {
return IsExperimentEnabled<kExperimentIdCanaryClientPrivacy>();

@ -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

@ -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<RefCountedPtr<Channel>> 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.

@ -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);
}

@ -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,

@ -39,6 +39,7 @@
#include <grpcpp/grpcpp.h>
#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;

Loading…
Cancel
Save