From 016b0a41b54102c69e6828425c014ada2b066af2 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Thu, 15 Aug 2024 22:33:59 +0000 Subject: [PATCH] Reviewer comments --- test/cpp/ext/otel/otel_plugin_test.cc | 47 +++++++++++++-------------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/test/cpp/ext/otel/otel_plugin_test.cc b/test/cpp/ext/otel/otel_plugin_test.cc index 1d2f19f9909..19438b8c268 100644 --- a/test/cpp/ext/otel/otel_plugin_test.cc +++ b/test/cpp/ext/otel/otel_plugin_test.cc @@ -2038,35 +2038,34 @@ TEST_F(OpenTelemetryPluginCallbackMetricsTest, VerifyCallbacksAreCleanedUp) { grpc_core::Duration::Milliseconds(50) * grpc_test_slowdown_factor(), integer_gauge_handle, double_gauge_handle); constexpr int kIterations = 50; - MetricsCollectorThread collector{ - this, - grpc_core::Duration::Milliseconds(100) * grpc_test_slowdown_factor(), - kIterations, - [&](const absl::flat_hash_map< - std::string, - std::vector>& - data) { - return !data.contains(kInt64CallbackGaugeMetric) || - !data.contains(kDoubleCallbackGaugeMetric); - }}; - absl::flat_hash_map< - std::string, - std::vector> - data = collector.Stop(); + { + MetricsCollectorThread collector{ + this, + grpc_core::Duration::Milliseconds(100) * grpc_test_slowdown_factor(), + kIterations, + [&](const absl::flat_hash_map< + std::string, + std::vector>& + data) { + return !data.contains(kInt64CallbackGaugeMetric) || + !data.contains(kDoubleCallbackGaugeMetric); + }}; + } // Verify that callbacks are invoked EXPECT_EQ(report_count_1, kIterations); EXPECT_EQ(report_count_2, kIterations); // Remove one of the callbacks registered_metric_callback_1.reset(); - MetricsCollectorThread new_collector{ - this, - grpc_core::Duration::Milliseconds(100) * grpc_test_slowdown_factor(), - kIterations, - [&](const absl::flat_hash_map< - std::string, - std::vector>& - data) { return false; }}; - new_collector.Stop(); + { + MetricsCollectorThread new_collector{ + this, + grpc_core::Duration::Milliseconds(100) * grpc_test_slowdown_factor(), + kIterations, + [&](const absl::flat_hash_map< + std::string, + std::vector>& + data) { return false; }}; + } EXPECT_EQ(report_count_1, kIterations); // No change since previous EXPECT_EQ(report_count_2, 2 * kIterations); // Gets another kIterations // Remove the other callback as well