lint: optimize enum types and fix reserved identifiers in Base/PgSQL hostgroups

performance-enum-size fixes:
- p_mysql_error_type: add uint8_t underlying type (2 values)
- p_pgsql_error_type: add uint8_t underlying type (2 values)
- p_hg_dyn_gauge: add uint8_t underlying type (5 values)
- p_hg_dyn_counter: add uint8_t underlying type (9 values)
- PgSQL_p_hg_dyn_gauge: add uint8_t underlying type (5 values)
- PgSQL_p_hg_dyn_counter: add uint8_t underlying type (9 values)

bugprone-reserved-identifier fixes:
- Rename __size -> SIZE_ in all metric enums to avoid reserved identifier
- Update std::array size references to use new SIZE_ enum values

Applies same fixes as MySQL_HostGroups_Manager.h to:
- Base_HostGroups_Manager.h (base class)
- PgSQL_HostGroups_Manager.h (PostgreSQL implementation)
v3.0-lint
Rene Cannao 2 weeks ago
parent b531326c82
commit 0d6c0270a4

@ -482,7 +482,7 @@ struct p_hg_counter {
myhgm_myconnpool_reset,
myhgm_myconnpool_destroy,
auto_increment_delay_multiplex,
__size
SIZE_
};
};
@ -490,12 +490,12 @@ struct p_hg_gauge {
enum metric {
server_connections_connected = 0,
client_connections_connected,
__size
SIZE_
};
};
struct p_hg_dyn_counter {
enum metric {
enum metric : uint8_t {
conn_pool_bytes_data_recv = 0,
conn_pool_bytes_data_sent,
connection_pool_conn_err,
@ -504,22 +504,22 @@ struct p_hg_dyn_counter {
gtid_executed,
proxysql_mysql_error,
mysql_error,
__size
SIZE_
};
};
enum class p_mysql_error_type {
enum class p_mysql_error_type : uint8_t {
mysql,
proxysql
};
struct p_hg_dyn_gauge {
enum metric {
enum metric : uint8_t {
connection_pool_conn_free = 0,
connection_pool_conn_used,
connection_pool_latency_us,
connection_pool_status,
__size
SIZE_
};
};
@ -915,12 +915,12 @@ class MySQL_HostGroups_Manager {
//////////////////////////////////////////////////////
/// Prometheus metrics arrays
std::array<prometheus::Counter*, p_hg_counter::__size> p_counter_array {};
std::array<prometheus::Gauge*, p_hg_gauge::__size> p_gauge_array {};
std::array<prometheus::Counter*, p_hg_counter::SIZE_> p_counter_array {};
std::array<prometheus::Gauge*, p_hg_gauge::SIZE_> p_gauge_array {};
// Prometheus dyn_metrics families arrays
std::array<prometheus::Family<prometheus::Counter>*, p_hg_dyn_counter::__size> p_dyn_counter_array {};
std::array<prometheus::Family<prometheus::Gauge>*, p_hg_dyn_gauge::__size> p_dyn_gauge_array {};
std::array<prometheus::Family<prometheus::Counter>*, p_hg_dyn_counter::SIZE_> p_dyn_counter_array {};
std::array<prometheus::Family<prometheus::Gauge>*, p_hg_dyn_gauge::SIZE_> p_dyn_gauge_array {};
/// Prometheus connection_pool metrics
std::map<std::string, prometheus::Counter*> p_conn_pool_bytes_data_recv_map {};

@ -287,7 +287,7 @@ struct PgSQL_p_hg_counter {
pghgm_pgconnpool_reset,
pghgm_pgconnpool_destroy,
auto_increment_delay_multiplex,
__size
SIZE_
};
};
@ -295,12 +295,12 @@ struct PgSQL_p_hg_gauge {
enum metric {
server_connections_connected = 0,
client_connections_connected,
__size
SIZE_
};
};
struct PgSQL_p_hg_dyn_counter {
enum metric {
enum metric : uint8_t {
conn_pool_bytes_data_recv = 0,
conn_pool_bytes_data_sent,
connection_pool_conn_err,
@ -309,22 +309,22 @@ struct PgSQL_p_hg_dyn_counter {
gtid_executed,
proxysql_pgsql_error,
pgsql_error,
__size
SIZE_
};
};
enum class p_pgsql_error_type {
enum class p_pgsql_error_type : uint8_t {
pgsql,
proxysql
};
struct PgSQL_p_hg_dyn_gauge {
enum metric {
enum metric : uint8_t {
connection_pool_conn_free = 0,
connection_pool_conn_used,
connection_pool_latency_us,
connection_pool_status,
__size
SIZE_
};
};
@ -639,12 +639,12 @@ class PgSQL_HostGroups_Manager : public Base_HostGroups_Manager<PgSQL_HGC> {
//////////////////////////////////////////////////////
/// Prometheus metrics arrays
std::array<prometheus::Counter*, PgSQL_p_hg_counter::__size> p_counter_array {};
std::array<prometheus::Gauge*, PgSQL_p_hg_gauge::__size> p_gauge_array {};
std::array<prometheus::Counter*, PgSQL_p_hg_counter::SIZE_> p_counter_array {};
std::array<prometheus::Gauge*, PgSQL_p_hg_gauge::SIZE_> p_gauge_array {};
// Prometheus dyn_metrics families arrays
std::array<prometheus::Family<prometheus::Counter>*, PgSQL_p_hg_dyn_counter::__size> p_dyn_counter_array {};
std::array<prometheus::Family<prometheus::Gauge>*, PgSQL_p_hg_dyn_gauge::__size> p_dyn_gauge_array {};
std::array<prometheus::Family<prometheus::Counter>*, PgSQL_p_hg_dyn_counter::SIZE_> p_dyn_counter_array {};
std::array<prometheus::Family<prometheus::Gauge>*, PgSQL_p_hg_dyn_gauge::SIZE_> p_dyn_gauge_array {};
/// Prometheus connection_pool metrics
std::map<std::string, prometheus::Counter*> p_conn_pool_bytes_data_recv_map {};

Loading…
Cancel
Save