Skip to content

Commit a5cb3cb

Browse files
committed
Make 'runtime_servers_*' consistent with dynamic 'gauge' metrics
Dynamic Prometheus gauge metrics are only exposed while the source for the data used for the time-series exists. If the source of the data is no longer present, we omit the metric in the exporter output.
1 parent 1509975 commit a5cb3cb

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

include/MySQL_HostGroups_Manager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ class MySQL_HostGroups_Manager {
927927
// PMM-Compatibility metrics
928928
///////////////////////////////////////////////////////////////////////
929929
std::map<std::string, prometheus::Gauge*> p_runtime_servers_status_map {};
930-
std::map<std::string, prometheus::Gauge*> p_runtime_servers_weigth_map {};
930+
std::map<std::string, prometheus::Gauge*> p_runtime_servers_weight_map {};
931931
std::map<std::string, prometheus::Gauge*> p_runtime_servers_compress_map {};
932932
std::map<std::string, prometheus::Gauge*> p_runtime_servers_max_conns_map {};
933933
std::map<std::string, prometheus::Gauge*> p_runtime_servers_max_repl_lag_map {};

lib/MySQL_HostGroups_Manager.cpp

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3470,7 +3470,7 @@ void MySQL_HostGroups_Manager::p_update_connection_pool() {
34703470
p_update_connection_pool_update_gauge(
34713471
endpoint_id,
34723472
srvs_common_labels,
3473-
status.p_runtime_servers_weigth_map,
3473+
status.p_runtime_servers_weight_map,
34743474
mysrvc->weight,
34753475
p_hg_dyn_gauge::runtime_servers_weight
34763476
);
@@ -3544,6 +3544,37 @@ void MySQL_HostGroups_Manager::p_update_connection_pool() {
35443544
gauge = status.p_connection_pool_latency_us_map[key];
35453545
status.p_dyn_gauge_array[p_hg_dyn_gauge::connection_pool_latency_us]->Remove(gauge);
35463546
status.p_connection_pool_latency_us_map.erase(key);
3547+
3548+
// PMM-Compatibility metrics
3549+
////////////////////////////////////////////////////////////////////
3550+
gauge = status.p_runtime_servers_status_map[key];
3551+
status.p_dyn_gauge_array[p_hg_dyn_gauge::runtime_servers_status]->Remove(gauge);
3552+
status.p_runtime_servers_status_map.erase(key);
3553+
3554+
gauge = status.p_runtime_servers_weight_map[key];
3555+
status.p_dyn_gauge_array[p_hg_dyn_gauge::runtime_servers_weight]->Remove(gauge);
3556+
status.p_runtime_servers_weight_map.erase(key);
3557+
3558+
gauge = status.p_runtime_servers_compress_map[key];
3559+
status.p_dyn_gauge_array[p_hg_dyn_gauge::runtime_servers_compression]->Remove(gauge);
3560+
status.p_runtime_servers_compress_map.erase(key);
3561+
3562+
gauge = status.p_runtime_servers_max_conns_map[key];
3563+
status.p_dyn_gauge_array[p_hg_dyn_gauge::runtime_servers_max_connections]->Remove(gauge);
3564+
status.p_runtime_servers_max_conns_map.erase(key);
3565+
3566+
gauge = status.p_runtime_servers_max_repl_lag_map[key];
3567+
status.p_dyn_gauge_array[p_hg_dyn_gauge::runtime_servers_max_replication_lag]->Remove(gauge);
3568+
status.p_runtime_servers_max_repl_lag_map.erase(key);
3569+
3570+
gauge = status.p_runtime_servers_use_ssl_map[key];
3571+
status.p_dyn_gauge_array[p_hg_dyn_gauge::runtime_servers_use_ssl]->Remove(gauge);
3572+
status.p_runtime_servers_use_ssl_map.erase(key);
3573+
3574+
gauge = status.p_runtime_servers_max_lat_map[key];
3575+
status.p_dyn_gauge_array[p_hg_dyn_gauge::runtime_servers_max_latency_ms]->Remove(gauge);
3576+
status.p_runtime_servers_max_lat_map.erase(key);
3577+
////////////////////////////////////////////////////////////////////
35473578
}
35483579

35493580
wrunlock();

0 commit comments

Comments
 (0)