[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] metrics: Add tor_ namespace to all metrics
commit 5de66739724451801487dbec0eb210c0595cc00f
Author: David Goulet <dgoulet@xxxxxxxxxxxxxx>
Date: Tue Oct 27 10:43:19 2020 -0400
metrics: Add tor_ namespace to all metrics
Closes #40063
Signed-off-by: David Goulet <dgoulet@xxxxxxxxxxxxxx>
---
src/feature/hs/hs_metrics_entry.c | 12 ++++++------
src/lib/metrics/metrics_common.h | 9 +++++++++
2 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/src/feature/hs/hs_metrics_entry.c b/src/feature/hs/hs_metrics_entry.c
index e4da0921aa..7eb78db5ac 100644
--- a/src/feature/hs/hs_metrics_entry.c
+++ b/src/feature/hs/hs_metrics_entry.c
@@ -23,40 +23,40 @@ const hs_metrics_entry_t base_metrics[] =
{
.key = HS_METRICS_NUM_INTRODUCTIONS,
.type = METRICS_TYPE_COUNTER,
- .name = "hs_intro_num_total",
+ .name = METRICS_NAME(hs_intro_num_total),
.help = "Total number of introduction received",
.port_as_label = false,
},
{
.key = HS_METRICS_APP_WRITE_BYTES,
.type = METRICS_TYPE_COUNTER,
- .name = "hs_app_write_bytes_total",
+ .name = METRICS_NAME(hs_app_write_bytes_total),
.help = "Total number of bytes written to the application",
.port_as_label = true,
},
{
.key = HS_METRICS_APP_READ_BYTES,
.type = METRICS_TYPE_COUNTER,
- .name = "hs_app_read_bytes_total",
+ .name = METRICS_NAME(hs_app_read_bytes_total),
.help = "Total number of bytes read from the application",
.port_as_label = true,
},
{
.key = HS_METRICS_NUM_ESTABLISHED_RDV,
.type = METRICS_TYPE_GAUGE,
- .name = "hs_rdv_established_count",
+ .name = METRICS_NAME(hs_rdv_established_count),
.help = "Total number of established rendezvous circuit",
},
{
.key = HS_METRICS_NUM_RDV,
.type = METRICS_TYPE_COUNTER,
- .name = "hs_rdv_num_total",
+ .name = METRICS_NAME(hs_rdv_num_total),
.help = "Total number of rendezvous circuit created",
},
{
.key = HS_METRICS_NUM_ESTABLISHED_INTRO,
.type = METRICS_TYPE_GAUGE,
- .name = "hs_intro_established_count",
+ .name = METRICS_NAME(hs_intro_established_count),
.help = "Total number of established introduction circuit",
},
};
diff --git a/src/lib/metrics/metrics_common.h b/src/lib/metrics/metrics_common.h
index 5d1a32ea6c..50f6147007 100644
--- a/src/lib/metrics/metrics_common.h
+++ b/src/lib/metrics/metrics_common.h
@@ -11,6 +11,15 @@
#include "lib/cc/torint.h"
+/** Prefix to every metrics exposed. This is insures that the metrics are
+ * always in the same namespace. */
+#define METRICS_PREFIX tor_
+
+/** Helper macro that must be used to construct the right namespaced metrics
+ * name. A name is a string so stringify the result. */
+#define METRICS_STR(val) #val
+#define METRICS_NAME(name) METRICS_STR(METRICS_PREFIX ## name)
+
/** Format output type. */
typedef enum {
/** Prometheus data output format. */
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits