From 812b627bd8ebf228de003f11990a9c5245b550fc Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Tue, 5 Dec 2023 13:58:49 -0500 Subject: [PATCH] MT#55283 use typed GHashTables for metric_types Change-Id: I097e9bb471b1559561c7ce631fadfe7f068b5ecc --- daemon/websocket.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/daemon/websocket.c b/daemon/websocket.c index e6d162534..2578f656f 100644 --- a/daemon/websocket.c +++ b/daemon/websocket.c @@ -381,12 +381,14 @@ static const char *websocket_http_ping(struct websocket_message *wm) { } +TYPED_GHASHTABLE(metric_types_ht, char, void, g_str_hash, g_str_equal, NULL, NULL) + static const char *websocket_http_metrics(struct websocket_message *wm) { ilogs(http, LOG_DEBUG, "Respoding to GET /metrics"); g_autoptr(stats_metric_q) metrics = statistics_gather_metrics(NULL); g_autoptr(GString) outp = g_string_new(""); - g_autoptr(GHashTable) metric_types = g_hash_table_new(g_str_hash, g_str_equal); + g_auto(metric_types_ht) metric_types = metric_types_ht_new(); for (__auto_type l = metrics->head; l; l = l->next) { stats_metric *m = l->data; @@ -397,14 +399,14 @@ static const char *websocket_http_metrics(struct websocket_message *wm) { if (!m->prom_name) continue; - if (!g_hash_table_lookup(metric_types, m->prom_name)) { + if (!t_hash_table_lookup(metric_types, m->prom_name)) { if (m->descr) g_string_append_printf(outp, "# HELP rtpengine_%s %s\n", m->prom_name, m->descr); if (m->prom_type) g_string_append_printf(outp, "# TYPE rtpengine_%s %s\n", m->prom_name, m->prom_type); - g_hash_table_insert(metric_types, (void *) m->prom_name, (void *) 0x1); + t_hash_table_insert(metric_types, (void *) m->prom_name, (void *) 0x1); } g_string_append_printf(outp, "rtpengine_%s", m->prom_name);