added tests

pull/36001/head
Mark D. Roth 9 months ago
parent 78d36f8c5e
commit 75033ad67b
  1. 5
      src/core/lib/channel/metrics.h
  2. 428
      test/core/channel/metrics_test.cc
  3. 3
      test/core/util/fake_stats_plugin.h

@ -293,6 +293,11 @@ class GlobalStatsPluginRegistry {
// Registers a callback to be used to populate callback metrics.
// The callback will update the specified metrics. The callback
// will be invoked no more often than min_interval.
//
// The returned object is a handle that allows the caller to control
// the lifetime of the callback; when the returned object is
// destroyed, the callback is de-registered. The returned object
// must not outlive the StatsPluginGroup object that created it.
std::unique_ptr<RegisteredMetricCallback> RegisterCallback(
absl::AnyInvocable<void(CallbackMetricReporter&)> callback,
std::vector<GlobalInstrumentsRegistry::GlobalCallbackHandle> metrics,

@ -201,8 +201,8 @@ TEST_F(MetricsTest, Int64Gauge) {
const absl::string_view kLabelKeys[] = {"label_key_1", "label_key_2"};
const absl::string_view kOptionalLabelKeys[] = {"optional_label_key_1",
"optional_label_key_2"};
auto uint64_gauge_handle = GlobalInstrumentsRegistry::RegisterInt64Gauge(
"uint64_gauge", "A simple int64 gauge.", "unit", kLabelKeys,
auto int64_gauge_handle = GlobalInstrumentsRegistry::RegisterInt64Gauge(
"int64_gauge", "A simple int64 gauge.", "unit", kLabelKeys,
kOptionalLabelKeys, true);
constexpr absl::string_view kLabelValues[] = {"label_value_1",
"label_value_2"};
@ -216,20 +216,20 @@ TEST_F(MetricsTest, Int64Gauge) {
auto plugin3 = MakeStatsPluginForTarget(kDomain3To4);
GlobalStatsPluginRegistry::GetStatsPluginsForChannel(
StatsPlugin::ChannelScope(kDomain1To4, ""))
.SetGauge(uint64_gauge_handle, 1, kLabelValues, kOptionalLabelValues);
.SetGauge(int64_gauge_handle, 1, kLabelValues, kOptionalLabelValues);
GlobalStatsPluginRegistry::GetStatsPluginsForChannel(
StatsPlugin::ChannelScope(kDomain2To4, ""))
.SetGauge(uint64_gauge_handle, 2, kLabelValues, kOptionalLabelValues);
.SetGauge(int64_gauge_handle, 2, kLabelValues, kOptionalLabelValues);
GlobalStatsPluginRegistry::GetStatsPluginsForChannel(
StatsPlugin::ChannelScope(kDomain3To4, ""))
.SetGauge(uint64_gauge_handle, 3, kLabelValues, kOptionalLabelValues);
EXPECT_THAT(plugin1->GetGaugeValue(uint64_gauge_handle, kLabelValues,
.SetGauge(int64_gauge_handle, 3, kLabelValues, kOptionalLabelValues);
EXPECT_THAT(plugin1->GetGaugeValue(int64_gauge_handle, kLabelValues,
kOptionalLabelValues),
::testing::Optional(1));
EXPECT_THAT(plugin2->GetGaugeValue(uint64_gauge_handle, kLabelValues,
EXPECT_THAT(plugin2->GetGaugeValue(int64_gauge_handle, kLabelValues,
kOptionalLabelValues),
::testing::Optional(2));
EXPECT_THAT(plugin3->GetGaugeValue(uint64_gauge_handle, kLabelValues,
EXPECT_THAT(plugin3->GetGaugeValue(int64_gauge_handle, kLabelValues,
kOptionalLabelValues),
::testing::Optional(3));
}
@ -271,6 +271,418 @@ TEST_F(MetricsTest, DoubleGauge) {
::testing::Optional(3.45));
}
TEST_F(MetricsTest, Int64CallbackGauge) {
const absl::string_view kLabelKeys[] = {"label_key_1", "label_key_2"};
const absl::string_view kOptionalLabelKeys[] = {"optional_label_key_1",
"optional_label_key_2"};
auto int64_gauge_handle =
GlobalInstrumentsRegistry::RegisterCallbackInt64Gauge(
"int64_gauge", "A simple int64 gauge.", "unit", kLabelKeys,
kOptionalLabelKeys, true);
constexpr absl::string_view kLabelValues[] = {"label_value_1",
"label_value_2"};
constexpr absl::string_view kLabelValues2[] = {"label_value_3",
"label_value_2"};
constexpr absl::string_view kOptionalLabelValues[] = {
"optional_label_value_1", "optional_label_value_2"};
constexpr absl::string_view kDomain1To4 = "domain1.domain2.domain3.domain4";
constexpr absl::string_view kDomain2To4 = "domain2.domain3.domain4";
constexpr absl::string_view kDomain3To4 = "domain3.domain4";
auto plugin1 = MakeStatsPluginForTarget(kDomain3To4);
auto plugin2 = MakeStatsPluginForTarget(kDomain2To4);
auto plugin3 = MakeStatsPluginForTarget(kDomain1To4);
// Register two callbacks that set the same metric but with different
// label values. The callbacks get used only by plugin1.
gpr_log(GPR_INFO, "testing callbacks for: plugin1");
auto group1 = GlobalStatsPluginRegistry::GetStatsPluginsForChannel(
StatsPlugin::ChannelScope(kDomain3To4, ""));
auto callback1 = group1.RegisterCallback(
[&](CallbackMetricReporter& reporter) {
reporter.Report(int64_gauge_handle, 1, kLabelValues,
kOptionalLabelValues);
},
{int64_gauge_handle});
auto callback2 = group1.RegisterCallback(
[&](CallbackMetricReporter& reporter) {
reporter.Report(int64_gauge_handle, 2, kLabelValues2,
kOptionalLabelValues);
},
{int64_gauge_handle});
// No plugins have data yet.
EXPECT_EQ(plugin1->GetCallbackGaugeValue(int64_gauge_handle, kLabelValues,
kOptionalLabelValues),
absl::nullopt);
EXPECT_EQ(plugin1->GetCallbackGaugeValue(int64_gauge_handle, kLabelValues2,
kOptionalLabelValues),
absl::nullopt);
EXPECT_EQ(plugin2->GetCallbackGaugeValue(int64_gauge_handle, kLabelValues,
kOptionalLabelValues),
absl::nullopt);
EXPECT_EQ(plugin2->GetCallbackGaugeValue(int64_gauge_handle, kLabelValues2,
kOptionalLabelValues),
absl::nullopt);
EXPECT_EQ(plugin3->GetCallbackGaugeValue(int64_gauge_handle, kLabelValues,
kOptionalLabelValues),
absl::nullopt);
EXPECT_EQ(plugin3->GetCallbackGaugeValue(int64_gauge_handle, kLabelValues2,
kOptionalLabelValues),
absl::nullopt);
// Now invoke the callbacks.
plugin1->TriggerCallbacks();
plugin2->TriggerCallbacks();
plugin3->TriggerCallbacks();
// Now plugin1 should have data, but the others should not.
EXPECT_THAT(plugin1->GetCallbackGaugeValue(int64_gauge_handle, kLabelValues,
kOptionalLabelValues),
::testing::Optional(1));
EXPECT_THAT(plugin1->GetCallbackGaugeValue(int64_gauge_handle, kLabelValues2,
kOptionalLabelValues),
::testing::Optional(2));
EXPECT_EQ(plugin2->GetCallbackGaugeValue(int64_gauge_handle, kLabelValues,
kOptionalLabelValues),
absl::nullopt);
EXPECT_EQ(plugin2->GetCallbackGaugeValue(int64_gauge_handle, kLabelValues2,
kOptionalLabelValues),
absl::nullopt);
EXPECT_EQ(plugin3->GetCallbackGaugeValue(int64_gauge_handle, kLabelValues,
kOptionalLabelValues),
absl::nullopt);
EXPECT_EQ(plugin3->GetCallbackGaugeValue(int64_gauge_handle, kLabelValues2,
kOptionalLabelValues),
absl::nullopt);
// De-register the callbacks.
callback1.reset();
callback2.reset();
// Now register callbacks that hit both plugin1 and plugin2.
gpr_log(GPR_INFO, "testing callbacks for: plugin1, plugin2");
auto group2 = GlobalStatsPluginRegistry::GetStatsPluginsForChannel(
StatsPlugin::ChannelScope(kDomain2To4, ""));
callback1 = group2.RegisterCallback(
[&](CallbackMetricReporter& reporter) {
reporter.Report(int64_gauge_handle, 3, kLabelValues,
kOptionalLabelValues);
},
{int64_gauge_handle});
callback2 = group2.RegisterCallback(
[&](CallbackMetricReporter& reporter) {
reporter.Report(int64_gauge_handle, 4, kLabelValues2,
kOptionalLabelValues);
},
{int64_gauge_handle});
// Plugin1 still has data from before, but the others have none.
EXPECT_THAT(plugin1->GetCallbackGaugeValue(int64_gauge_handle, kLabelValues,
kOptionalLabelValues),
::testing::Optional(1));
EXPECT_THAT(plugin1->GetCallbackGaugeValue(int64_gauge_handle, kLabelValues2,
kOptionalLabelValues),
::testing::Optional(2));
EXPECT_EQ(plugin2->GetCallbackGaugeValue(int64_gauge_handle, kLabelValues,
kOptionalLabelValues),
absl::nullopt);
EXPECT_EQ(plugin2->GetCallbackGaugeValue(int64_gauge_handle, kLabelValues2,
kOptionalLabelValues),
absl::nullopt);
EXPECT_EQ(plugin3->GetCallbackGaugeValue(int64_gauge_handle, kLabelValues,
kOptionalLabelValues),
absl::nullopt);
EXPECT_EQ(plugin3->GetCallbackGaugeValue(int64_gauge_handle, kLabelValues2,
kOptionalLabelValues),
absl::nullopt);
// Now invoke the callbacks.
plugin1->TriggerCallbacks();
plugin2->TriggerCallbacks();
plugin3->TriggerCallbacks();
// Now plugin1 and plugin2 should have data, but plugin3 should not.
EXPECT_THAT(plugin1->GetCallbackGaugeValue(int64_gauge_handle, kLabelValues,
kOptionalLabelValues),
::testing::Optional(3));
EXPECT_THAT(plugin1->GetCallbackGaugeValue(int64_gauge_handle, kLabelValues2,
kOptionalLabelValues),
::testing::Optional(4));
EXPECT_THAT(plugin2->GetCallbackGaugeValue(int64_gauge_handle, kLabelValues,
kOptionalLabelValues),
::testing::Optional(3));
EXPECT_THAT(plugin2->GetCallbackGaugeValue(int64_gauge_handle, kLabelValues2,
kOptionalLabelValues),
::testing::Optional(4));
EXPECT_EQ(plugin3->GetCallbackGaugeValue(int64_gauge_handle, kLabelValues,
kOptionalLabelValues),
absl::nullopt);
EXPECT_EQ(plugin3->GetCallbackGaugeValue(int64_gauge_handle, kLabelValues2,
kOptionalLabelValues),
absl::nullopt);
// De-register the callbacks.
callback1.reset();
callback2.reset();
// Now register callbacks that hit all three plugins.
gpr_log(GPR_INFO, "testing callbacks for: plugin1, plugin2, plugin3");
auto group3 = GlobalStatsPluginRegistry::GetStatsPluginsForChannel(
StatsPlugin::ChannelScope(kDomain1To4, ""));
callback1 = group3.RegisterCallback(
[&](CallbackMetricReporter& reporter) {
reporter.Report(int64_gauge_handle, 5, kLabelValues,
kOptionalLabelValues);
},
{int64_gauge_handle});
callback2 = group3.RegisterCallback(
[&](CallbackMetricReporter& reporter) {
reporter.Report(int64_gauge_handle, 6, kLabelValues2,
kOptionalLabelValues);
},
{int64_gauge_handle});
// Plugin1 and plugin2 still has data from before, but plugin3 has none.
EXPECT_THAT(plugin1->GetCallbackGaugeValue(int64_gauge_handle, kLabelValues,
kOptionalLabelValues),
::testing::Optional(3));
EXPECT_THAT(plugin1->GetCallbackGaugeValue(int64_gauge_handle, kLabelValues2,
kOptionalLabelValues),
::testing::Optional(4));
EXPECT_THAT(plugin2->GetCallbackGaugeValue(int64_gauge_handle, kLabelValues,
kOptionalLabelValues),
::testing::Optional(3));
EXPECT_THAT(plugin2->GetCallbackGaugeValue(int64_gauge_handle, kLabelValues2,
kOptionalLabelValues),
::testing::Optional(4));
EXPECT_EQ(plugin3->GetCallbackGaugeValue(int64_gauge_handle, kLabelValues,
kOptionalLabelValues),
absl::nullopt);
EXPECT_EQ(plugin3->GetCallbackGaugeValue(int64_gauge_handle, kLabelValues2,
kOptionalLabelValues),
absl::nullopt);
// Now invoke the callbacks.
plugin1->TriggerCallbacks();
plugin2->TriggerCallbacks();
plugin3->TriggerCallbacks();
// Now plugin1 and plugin2 should have data, but plugin3 should not.
EXPECT_THAT(plugin1->GetCallbackGaugeValue(int64_gauge_handle, kLabelValues,
kOptionalLabelValues),
::testing::Optional(5));
EXPECT_THAT(plugin1->GetCallbackGaugeValue(int64_gauge_handle, kLabelValues2,
kOptionalLabelValues),
::testing::Optional(6));
EXPECT_THAT(plugin2->GetCallbackGaugeValue(int64_gauge_handle, kLabelValues,
kOptionalLabelValues),
::testing::Optional(5));
EXPECT_THAT(plugin2->GetCallbackGaugeValue(int64_gauge_handle, kLabelValues2,
kOptionalLabelValues),
::testing::Optional(6));
EXPECT_THAT(plugin3->GetCallbackGaugeValue(int64_gauge_handle, kLabelValues,
kOptionalLabelValues),
::testing::Optional(5));
EXPECT_THAT(plugin3->GetCallbackGaugeValue(int64_gauge_handle, kLabelValues2,
kOptionalLabelValues),
::testing::Optional(6));
// Need to destroy callbacks before the plugin group that created them.
callback1.reset();
callback2.reset();
}
TEST_F(MetricsTest, DoubleCallbackGauge) {
const absl::string_view kLabelKeys[] = {"label_key_1", "label_key_2"};
const absl::string_view kOptionalLabelKeys[] = {"optional_label_key_1",
"optional_label_key_2"};
auto double_gauge_handle =
GlobalInstrumentsRegistry::RegisterCallbackDoubleGauge(
"double_gauge", "A simple double gauge.", "unit", kLabelKeys,
kOptionalLabelKeys, true);
constexpr absl::string_view kLabelValues[] = {"label_value_1",
"label_value_2"};
constexpr absl::string_view kLabelValues2[] = {"label_value_3",
"label_value_2"};
constexpr absl::string_view kOptionalLabelValues[] = {
"optional_label_value_1", "optional_label_value_2"};
constexpr absl::string_view kDomain1To4 = "domain1.domain2.domain3.domain4";
constexpr absl::string_view kDomain2To4 = "domain2.domain3.domain4";
constexpr absl::string_view kDomain3To4 = "domain3.domain4";
auto plugin1 = MakeStatsPluginForTarget(kDomain3To4);
auto plugin2 = MakeStatsPluginForTarget(kDomain2To4);
auto plugin3 = MakeStatsPluginForTarget(kDomain1To4);
// Register two callbacks that set the same metric but with different
// label values. The callbacks get used only by plugin1.
gpr_log(GPR_INFO, "testing callbacks for: plugin1");
auto group1 = GlobalStatsPluginRegistry::GetStatsPluginsForChannel(
StatsPlugin::ChannelScope(kDomain3To4, ""));
auto callback1 = group1.RegisterCallback(
[&](CallbackMetricReporter& reporter) {
reporter.Report(double_gauge_handle, 1.23, kLabelValues,
kOptionalLabelValues);
},
{double_gauge_handle});
auto callback2 = group1.RegisterCallback(
[&](CallbackMetricReporter& reporter) {
reporter.Report(double_gauge_handle, 2.34, kLabelValues2,
kOptionalLabelValues);
},
{double_gauge_handle});
// No plugins have data yet.
EXPECT_EQ(plugin1->GetCallbackGaugeValue(double_gauge_handle, kLabelValues,
kOptionalLabelValues),
absl::nullopt);
EXPECT_EQ(plugin1->GetCallbackGaugeValue(double_gauge_handle, kLabelValues2,
kOptionalLabelValues),
absl::nullopt);
EXPECT_EQ(plugin2->GetCallbackGaugeValue(double_gauge_handle, kLabelValues,
kOptionalLabelValues),
absl::nullopt);
EXPECT_EQ(plugin2->GetCallbackGaugeValue(double_gauge_handle, kLabelValues2,
kOptionalLabelValues),
absl::nullopt);
EXPECT_EQ(plugin3->GetCallbackGaugeValue(double_gauge_handle, kLabelValues,
kOptionalLabelValues),
absl::nullopt);
EXPECT_EQ(plugin3->GetCallbackGaugeValue(double_gauge_handle, kLabelValues2,
kOptionalLabelValues),
absl::nullopt);
// Now invoke the callbacks.
plugin1->TriggerCallbacks();
plugin2->TriggerCallbacks();
plugin3->TriggerCallbacks();
// Now plugin1 should have data, but the others should not.
EXPECT_THAT(plugin1->GetCallbackGaugeValue(double_gauge_handle, kLabelValues,
kOptionalLabelValues),
::testing::Optional(1.23));
EXPECT_THAT(plugin1->GetCallbackGaugeValue(double_gauge_handle, kLabelValues2,
kOptionalLabelValues),
::testing::Optional(2.34));
EXPECT_EQ(plugin2->GetCallbackGaugeValue(double_gauge_handle, kLabelValues,
kOptionalLabelValues),
absl::nullopt);
EXPECT_EQ(plugin2->GetCallbackGaugeValue(double_gauge_handle, kLabelValues2,
kOptionalLabelValues),
absl::nullopt);
EXPECT_EQ(plugin3->GetCallbackGaugeValue(double_gauge_handle, kLabelValues,
kOptionalLabelValues),
absl::nullopt);
EXPECT_EQ(plugin3->GetCallbackGaugeValue(double_gauge_handle, kLabelValues2,
kOptionalLabelValues),
absl::nullopt);
// De-register the callbacks.
callback1.reset();
callback2.reset();
// Now register callbacks that hit both plugin1 and plugin2.
gpr_log(GPR_INFO, "testing callbacks for: plugin1, plugin2");
auto group2 = GlobalStatsPluginRegistry::GetStatsPluginsForChannel(
StatsPlugin::ChannelScope(kDomain2To4, ""));
callback1 = group2.RegisterCallback(
[&](CallbackMetricReporter& reporter) {
reporter.Report(double_gauge_handle, 3.45, kLabelValues,
kOptionalLabelValues);
},
{double_gauge_handle});
callback2 = group2.RegisterCallback(
[&](CallbackMetricReporter& reporter) {
reporter.Report(double_gauge_handle, 4.56, kLabelValues2,
kOptionalLabelValues);
},
{double_gauge_handle});
// Plugin1 still has data from before, but the others have none.
EXPECT_THAT(plugin1->GetCallbackGaugeValue(double_gauge_handle, kLabelValues,
kOptionalLabelValues),
::testing::Optional(1.23));
EXPECT_THAT(plugin1->GetCallbackGaugeValue(double_gauge_handle, kLabelValues2,
kOptionalLabelValues),
::testing::Optional(2.34));
EXPECT_EQ(plugin2->GetCallbackGaugeValue(double_gauge_handle, kLabelValues,
kOptionalLabelValues),
absl::nullopt);
EXPECT_EQ(plugin2->GetCallbackGaugeValue(double_gauge_handle, kLabelValues2,
kOptionalLabelValues),
absl::nullopt);
EXPECT_EQ(plugin3->GetCallbackGaugeValue(double_gauge_handle, kLabelValues,
kOptionalLabelValues),
absl::nullopt);
EXPECT_EQ(plugin3->GetCallbackGaugeValue(double_gauge_handle, kLabelValues2,
kOptionalLabelValues),
absl::nullopt);
// Now invoke the callbacks.
plugin1->TriggerCallbacks();
plugin2->TriggerCallbacks();
plugin3->TriggerCallbacks();
// Now plugin1 and plugin2 should have data, but plugin3 should not.
EXPECT_THAT(plugin1->GetCallbackGaugeValue(double_gauge_handle, kLabelValues,
kOptionalLabelValues),
::testing::Optional(3.45));
EXPECT_THAT(plugin1->GetCallbackGaugeValue(double_gauge_handle, kLabelValues2,
kOptionalLabelValues),
::testing::Optional(4.56));
EXPECT_THAT(plugin2->GetCallbackGaugeValue(double_gauge_handle, kLabelValues,
kOptionalLabelValues),
::testing::Optional(3.45));
EXPECT_THAT(plugin2->GetCallbackGaugeValue(double_gauge_handle, kLabelValues2,
kOptionalLabelValues),
::testing::Optional(4.56));
EXPECT_EQ(plugin3->GetCallbackGaugeValue(double_gauge_handle, kLabelValues,
kOptionalLabelValues),
absl::nullopt);
EXPECT_EQ(plugin3->GetCallbackGaugeValue(double_gauge_handle, kLabelValues2,
kOptionalLabelValues),
absl::nullopt);
// De-register the callbacks.
callback1.reset();
callback2.reset();
// Now register callbacks that hit all three plugins.
gpr_log(GPR_INFO, "testing callbacks for: plugin1, plugin2, plugin3");
auto group3 = GlobalStatsPluginRegistry::GetStatsPluginsForChannel(
StatsPlugin::ChannelScope(kDomain1To4, ""));
callback1 = group3.RegisterCallback(
[&](CallbackMetricReporter& reporter) {
reporter.Report(double_gauge_handle, 5.67, kLabelValues,
kOptionalLabelValues);
},
{double_gauge_handle});
callback2 = group3.RegisterCallback(
[&](CallbackMetricReporter& reporter) {
reporter.Report(double_gauge_handle, 6.78, kLabelValues2,
kOptionalLabelValues);
},
{double_gauge_handle});
// Plugin1 and plugin2 still has data from before, but plugin3 has none.
EXPECT_THAT(plugin1->GetCallbackGaugeValue(double_gauge_handle, kLabelValues,
kOptionalLabelValues),
::testing::Optional(3.45));
EXPECT_THAT(plugin1->GetCallbackGaugeValue(double_gauge_handle, kLabelValues2,
kOptionalLabelValues),
::testing::Optional(4.56));
EXPECT_THAT(plugin2->GetCallbackGaugeValue(double_gauge_handle, kLabelValues,
kOptionalLabelValues),
::testing::Optional(3.45));
EXPECT_THAT(plugin2->GetCallbackGaugeValue(double_gauge_handle, kLabelValues2,
kOptionalLabelValues),
::testing::Optional(4.56));
EXPECT_EQ(plugin3->GetCallbackGaugeValue(double_gauge_handle, kLabelValues,
kOptionalLabelValues),
absl::nullopt);
EXPECT_EQ(plugin3->GetCallbackGaugeValue(double_gauge_handle, kLabelValues2,
kOptionalLabelValues),
absl::nullopt);
// Now invoke the callbacks.
plugin1->TriggerCallbacks();
plugin2->TriggerCallbacks();
plugin3->TriggerCallbacks();
// Now plugin1 and plugin2 should have data, but plugin3 should not.
EXPECT_THAT(plugin1->GetCallbackGaugeValue(double_gauge_handle, kLabelValues,
kOptionalLabelValues),
::testing::Optional(5.67));
EXPECT_THAT(plugin1->GetCallbackGaugeValue(double_gauge_handle, kLabelValues2,
kOptionalLabelValues),
::testing::Optional(6.78));
EXPECT_THAT(plugin2->GetCallbackGaugeValue(double_gauge_handle, kLabelValues,
kOptionalLabelValues),
::testing::Optional(5.67));
EXPECT_THAT(plugin2->GetCallbackGaugeValue(double_gauge_handle, kLabelValues2,
kOptionalLabelValues),
::testing::Optional(6.78));
EXPECT_THAT(plugin3->GetCallbackGaugeValue(double_gauge_handle, kLabelValues,
kOptionalLabelValues),
::testing::Optional(5.67));
EXPECT_THAT(plugin3->GetCallbackGaugeValue(double_gauge_handle, kLabelValues2,
kOptionalLabelValues),
::testing::Optional(6.78));
// Need to destroy callbacks before the plugin group that created them.
callback1.reset();
callback2.reset();
}
TEST_F(MetricsTest, DisableByDefaultMetricIsNotRecordedByFakeStatsPlugin) {
const absl::string_view kLabelKeys[] = {"label_key_1", "label_key_2"};
const absl::string_view kOptionalLabelKeys[] = {"optional_label_key_1",

@ -359,9 +359,12 @@ class FakeStatsPlugin : public StatsPlugin {
iter->second.Set(value, label_values, optional_values);
}
void AddCallback(RegisteredMetricCallback* callback) override {
gpr_log(GPR_INFO, "FakeStatsPlugin[%p]::AddCallback(%p)", this, callback);
callbacks_.insert(callback);
}
void RemoveCallback(RegisteredMetricCallback* callback) override {
gpr_log(GPR_INFO, "FakeStatsPlugin[%p]::RemoveCallback(%p)", this,
callback);
callbacks_.erase(callback);
}

Loading…
Cancel
Save