darion-yaphet commented on code in PR #3643:
URL: https://github.com/apache/brpc/pull/3643#discussion_r4356502939
##########
test/brpc_prometheus_metrics_unittest.cpp:
##########
@@ -49,6 +53,53 @@ class DummyEchoServiceImpl : public test::EchoService {
}
};
+TEST(PrometheusMetrics, method_metrics_remain_exposed_during_startup) {
+ for (int i = 0; i < 20; ++i) {
+ DummyEchoServiceImpl echo_svc;
+ brpc::Server server;
+ ASSERT_EQ(0, server.AddService(&echo_svc,
brpc::SERVER_DOESNT_OWN_SERVICE));
+ brpc::ServerOptions options;
+ options.server_info_name = "prometheus_startup_alias";
+ const std::string count_name =
+ "rpc_server_prometheus_startup_alias_test_echo_service_echo_count";
+ std::atomic<bool> stop(false);
+ std::atomic<bool> observed(false);
+ std::atomic<bool> disappeared(false);
+ bthread::CountdownEvent started;
+ {
+ // Start observing before Start() can publish the first metric.
+ // echo.proto enables idl_support, so both full and short method
+ // names refer to the same MethodStatus.
+ std::thread observer([&] {
+ started.signal();
+ while (!stop.load(std::memory_order_relaxed)) {
+ if (!bvar::Variable::describe_exposed(count_name).empty())
{
+ observed.store(true, std::memory_order_relaxed);
+ } else if (observed.load(std::memory_order_relaxed)) {
+ disappeared.store(true, std::memory_order_relaxed);
+ }
Review Comment:
The test needs to observe the short window between hiding and re-exposing
the same variable. Adding a sleep could make the regression harder to detect.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]