ZhengweiZhu commented on PR #2899:
URL: https://github.com/apache/brpc/pull/2899#issuecomment-2692089599
Update: The original patch only handles mvar not in LatencyRecorder type
correctly. When the mvar is in LatencyRecorder type, things get more
complicated.
For example, we expose a mvar in LatencyRecorder type with two different
labels.
` std::list<std::string> labels = {"idc", "method", "status"};
bvar::MultiDimension<bvar::LatencyRecorder > my_lat("dump_lat", labels);
bvar::LatencyRecorder* lat1 = my_lat.get_stats({"gz", "post", "200"});
*lat1 << 1;
*lat1 << 2;
bvar::LatencyRecorder* lat2 = my_lat.get_stats({"tj", "post", "300"});
*lat2 << 3;
*lat2 << 4;`
- For the upstream code
#curl -s 127.0.0.1:8000/brpc_metrics
# HELP dump_lat_latency
# TYPE dump_lat_latency gauge
dump_lat_latency{idc="gz",method="post",status="200",quantile="0"} 0
# HELP dump_lat_latency
# TYPE dump_lat_latency gauge
dump_lat_latency{idc="gz",method="post",status="200",quantile="80"} 0
...
#curl -s 127.0.0.1:8000/brpc_metrics | promtool check metrics
error while linting: text format parsing error in line 5: second TYPE line
for metric name "dump_lat_latency", or TYPE reported after samples
- After applying my original patch (judging if last metric name is equal to
this one)
#curl -s 127.0.0.1:8000/brpc_metrics
# HELP dump_lat_latency
# TYPE dump_lat_latency gauge
dump_lat_latency{idc="gz",method="post",status="200",quantile="0"} 0
dump_lat_latency{idc="gz",method="post",status="200",quantile="80"} 0
dump_lat_latency{idc="gz",method="post",status="200",quantile="90"} 0
dump_lat_latency{idc="gz",method="post",status="200",quantile="99"} 0
dump_lat_latency{idc="gz",method="post",status="200",quantile="999"} 0
dump_lat_latency{idc="gz",method="post",status="200",quantile="9999"} 0
# HELP dump_lat_max_latency
# TYPE dump_lat_max_latency gauge
dump_lat_max_latency{idc="gz",method="post",status="200"} 0
# HELP dump_lat_qps
# TYPE dump_lat_qps gauge
dump_lat_qps{idc="gz",method="post",status="200"} 0
# HELP dump_lat_count
# TYPE dump_lat_count gauge
dump_lat_count{idc="gz",method="post",status="200"} 2
# HELP dump_lat_latency
# TYPE dump_lat_latency gauge
dump_lat_latency{idc="tj",method="post",status="300",quantile="0"} 0
dump_lat_latency{idc="tj",method="post",status="300",quantile="80"} 0
dump_lat_latency{idc="tj",method="post",status="300",quantile="90"} 0
dump_lat_latency{idc="tj",method="post",status="300",quantile="99"} 0
dump_lat_latency{idc="tj",method="post",status="300",quantile="999"} 0
dump_lat_latency{idc="tj",method="post",status="300",quantile="9999"} 0
# HELP dump_lat_max_latency
# TYPE dump_lat_max_latency gauge
dump_lat_max_latency{idc="tj",method="post",status="300"} 0
# HELP dump_lat_qps
# TYPE dump_lat_qps gauge
dump_lat_qps{idc="tj",method="post",status="300"} 0
# HELP dump_lat_count
# TYPE dump_lat_count gauge
dump_lat_count{idc="tj",method="post",status="300"} 2
#curl -s 127.0.0.1:8000/brpc_metrics | promtool check metrics
error while linting: text format parsing error in line 19: second TYPE line
for metric name "dump_lat_latency", or TYPE reported after samples
The problem here is that the second "# TYPE dump_lat_latency gauge" in line
19 is equal to the one in line 2.
So we need to refactor code and rearrange the output of mvar in
LatencyRecorder type by putting the same metric name (with different labels)
together, such like:
# HELP dump_lat_latency
# TYPE dump_lat_latency gauge
dump_lat_latency{idc="gz",method="post",status="200",quantile="0"} 0
dump_lat_latency{idc="gz",method="post",status="200",quantile="80"} 0
dump_lat_latency{idc="gz",method="post",status="200",quantile="90"} 0
dump_lat_latency{idc="gz",method="post",status="200",quantile="99"} 0
dump_lat_latency{idc="gz",method="post",status="200",quantile="999"} 0
dump_lat_latency{idc="gz",method="post",status="200",quantile="9999"} 0
dump_lat_latency{idc="tj",method="post",status="300",quantile="0"} 0
dump_lat_latency{idc="tj",method="post",status="300",quantile="80"} 0
dump_lat_latency{idc="tj",method="post",status="300",quantile="90"} 0
dump_lat_latency{idc="tj",method="post",status="300",quantile="99"} 0
dump_lat_latency{idc="tj",method="post",status="300",quantile="999"} 0
dump_lat_latency{idc="tj",method="post",status="300",quantile="9999"} 0
# HELP dump_lat_max_latency
# TYPE dump_lat_max_latency gauge
dump_lat_max_latency{idc="gz",method="post",status="200"} 0
dump_lat_max_latency{idc="tj",method="post",status="300"} 0
# HELP dump_lat_qps
# TYPE dump_lat_qps gauge
dump_lat_qps{idc="gz",method="post",status="200"} 0
dump_lat_qps{idc="tj",method="post",status="300"} 0
# HELP dump_lat_count
# TYPE dump_lat_count gauge
dump_lat_count{idc="gz",method="post",status="200"} 2
dump_lat_count{idc="tj",method="post",status="300"} 2
--
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]