aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2022-03-09 08:46:55 -0500
committerDavid Goulet <dgoulet@torproject.org>2022-03-09 08:46:55 -0500
commit472c7127c7ad3f42879d48bd2eb8d461abdb6230 (patch)
tree3f08e2bd7d41a4bbe3edf37d9665dcd64cced64d
parent5afdc851b2096f046503e63d9465d3c2c3ffba9a (diff)
parent9efb04bb3e979941eada05c1a7d61d08d395376e (diff)
downloadtor-472c7127c7ad3f42879d48bd2eb8d461abdb6230.tar.gz
tor-472c7127c7ad3f42879d48bd2eb8d461abdb6230.zip
Merge branch 'maint-0.4.5' into maint-0.4.6
-rw-r--r--changes/ticket405814
-rw-r--r--src/feature/hs/hs_metrics.c23
2 files changed, 19 insertions, 8 deletions
diff --git a/changes/ticket40581 b/changes/ticket40581
new file mode 100644
index 0000000000..315215d8ed
--- /dev/null
+++ b/changes/ticket40581
@@ -0,0 +1,4 @@
+ o Minor bugfixes (metrics port, onion service):
+ - Fix the metrics with a port label to be unique. Before this, all ports of
+ an onion service would be on the same line which violates the Prometheus
+ rules of unique labels. Fixes bug 40581; bugfix on 0.4.5.1-alpha.
diff --git a/src/feature/hs/hs_metrics.c b/src/feature/hs/hs_metrics.c
index 891029aded..a82d2ae370 100644
--- a/src/feature/hs/hs_metrics.c
+++ b/src/feature/hs/hs_metrics.c
@@ -59,19 +59,26 @@ init_store(hs_service_t *service)
store = service->metrics.store;
for (size_t i = 0; i < base_metrics_size; ++i) {
- metrics_store_entry_t *entry =
- metrics_store_add(store, base_metrics[i].type, base_metrics[i].name,
- base_metrics[i].help);
-
- /* Add labels to the entry. */
- metrics_store_entry_add_label(entry,
- format_label("onion", service->onion_address));
+ /* Add entries with port as label. We need one metric line per port. */
if (base_metrics[i].port_as_label && service->config.ports) {
SMARTLIST_FOREACH_BEGIN(service->config.ports,
const hs_port_config_t *, p) {
+ metrics_store_entry_t *entry =
+ metrics_store_add(store, base_metrics[i].type, base_metrics[i].name,
+ base_metrics[i].help);
+
+ /* Add labels to the entry. */
+ metrics_store_entry_add_label(entry,
+ format_label("onion", service->onion_address));
metrics_store_entry_add_label(entry,
- format_label("port", port_to_str(p->virtual_port)));
+ format_label("port", port_to_str(p->virtual_port)));
} SMARTLIST_FOREACH_END(p);
+ } else {
+ metrics_store_entry_t *entry =
+ metrics_store_add(store, base_metrics[i].type, base_metrics[i].name,
+ base_metrics[i].help);
+ metrics_store_entry_add_label(entry,
+ format_label("onion", service->onion_address));
}
}
}