Copilot commented on code in PR #3557:
URL: https://github.com/apache/brpc/pull/3557#discussion_r4061539602
##########
src/brpc/builtin/prometheus_metrics_service.cpp:
##########
@@ -228,19 +311,18 @@ void
PrometheusMetricsService::default_method(::google::protobuf::RpcController*
int DumpPrometheusMetricsToIOBuf(butil::IOBuf* output) {
butil::IOBufBuilder os;
PrometheusMetricsDumper dumper(&os, g_server_info_prefix);
- const int ndump = bvar::Variable::dump_exposed(&dumper, nullptr);
+ int ndump = bvar::Variable::dump_exposed(&dumper, nullptr);
if (ndump < 0) {
return -1;
}
os.move_to(*output);
if (bvar::FLAGS_bvar_max_dump_multi_dimension_metric_number > 0) {
PrometheusMetricsDumper dumper_md(&os, g_server_info_prefix);
- const int ndump_md = bvar::MVariableBase::dump_exposed(&dumper_md,
nullptr);
- if (ndump_md < 0) {
- return -1;
+ size_t ndump_md = bvar::MVariableBase::dump_exposed(&dumper_md,
nullptr);
+ if (ndump_md > 0) {
+ output->append(butil::IOBuf::Movable(os.buf()));
}
Review Comment:
`MVariableBase::dump_exposed` documents and implements `-1` as its error
sentinel, but its return type is `size_t`; this change stores that sentinel in
`ndump_md` and only checks `> 0`. Any error is therefore treated as a
successful non-empty dump, and the partial buffer is appended instead of
returning `-1` as before. Preserve the sentinel check before appending the
buffer.
--
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]