ZhengweiZhu commented on code in PR #2899:
URL: https://github.com/apache/brpc/pull/2899#discussion_r1967007899
##########
src/brpc/builtin/prometheus_metrics_service.cpp:
##########
@@ -102,9 +103,14 @@ bool PrometheusMetricsDumper::dump(const std::string& name,
auto metrics_name = GetMetricsName(name);
- *_os << "# HELP " << metrics_name << '\n'
- << "# TYPE " << metrics_name << " gauge" << '\n'
- << name << " " << desc << '\n';
+ // To meet specification of prometheus metric, there should be only
+ // one TYPE field for the same metric name.
+ if (metrics_name.as_string() != _last_metric_name) {
Review Comment:
Let me add some background knowledge. The metrics are stored in
butil::FlatMap and the uniqueness of metric name is guaranteed. The problem
arises from the introduction of mvar, where one metric name will correspond to
multiple metric with different labels. My patch just handles this problem
--
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]