Copilot commented on code in PR #3557:
URL: https://github.com/apache/brpc/pull/3557#discussion_r4068277537


##########
src/bvar/latency_recorder.cpp:
##########
@@ -235,6 +240,16 @@ int LatencyRecorder::expose(const butil::StringPiece& 
prefix1,
     _latency.set_debug_name(prefix);
     _latency_percentile.set_debug_name(prefix);
 
+    // Exposing a LatencyRecorder is all-or-nothing: the prometheus exporter
+    // turns the sub-bvars below back into one summary and would happily write
+    // that summary out with empty values if only some of them made it.
+    bool expose_succeeded = false;
+    BUTIL_SCOPE_EXIT {
+        if (!expose_succeeded) {
+            hide();
+        }
+    };

Review Comment:
   `DumpLatencyRecorderSuffix()` synthesizes the summary names for every 
exposed bvar whose name starts with `g_server_info_prefix`, not only 
`MethodStatus` (see `prometheus_metrics_service.cpp:273-286`). This new 
all-or-nothing path still reserves only the child names, so a standalone 
`LatencyRecorder` exposed as `rpc_server_0_foo` can coexist with a plain bvar 
named `rpc_server_0_foo` or `rpc_server_0_foo_sum`; the scrape then contains 
duplicate metric names. Reserve and release the synthesized names in 
`LatencyRecorder::expose()`/`hide()` as well, or make the exporter synthesis 
apply only to `MethodStatus`.



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

Reply via email to