summaryrefslogtreecommitdiff
path: root/src/test/test_hs_metrics.c
diff options
context:
space:
mode:
authorGabriela Moldovan <gabi@torproject.org>2023-02-15 14:52:35 +0000
committerDavid Goulet <dgoulet@torproject.org>2023-03-07 09:46:05 -0500
commit16c6788fbc30cf0a2611dd021d1797931a53a86d (patch)
tree10486dd6918e9c97c85fc1539abe6bfec0f5a3ff /src/test/test_hs_metrics.c
parent119b84c365da867a6dcb85877f1d13dcf06c59a4 (diff)
downloadtor-16c6788fbc30cf0a2611dd021d1797931a53a86d.tar.gz
tor-16c6788fbc30cf0a2611dd021d1797931a53a86d.zip
metrics: Add a `reason` label to the HS error metrics.
This adds a `reason` label to the `hs_intro_rejected_intro_req_count` and `hs_rdv_error_count` metrics introduced in #40755. Metric look up and intialization is now more a bit more involved. This may be fine for now, but it will become unwieldy if/when we add more labels (and as such will need to be refactored). Also, in the future, we may want to introduce finer grained `reason` labels. For example, the `invalid_introduce2` label actually covers multiple types of errors that can happen during the processing of an INTRODUCE2 cell (such as cell parse errors, replays, decryption errors). Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
Diffstat (limited to 'src/test/test_hs_metrics.c')
-rw-r--r--src/test/test_hs_metrics.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/test/test_hs_metrics.c b/src/test/test_hs_metrics.c
index 03f6aedbb4..b7c0ab53da 100644
--- a/src/test/test_hs_metrics.c
+++ b/src/test/test_hs_metrics.c
@@ -40,7 +40,7 @@ test_metrics(void *arg)
/* Update entry by identifier. */
hs_metrics_update_by_ident(HS_METRICS_NUM_INTRODUCTIONS,
- &service->keys.identity_pk, 0, 42);
+ &service->keys.identity_pk, 0, NULL, 42);
/* Confirm the entry value. */
const smartlist_t *entries = metrics_store_get_all(service->metrics.store,
@@ -53,24 +53,29 @@ test_metrics(void *arg)
/* Update entry by service now. */
hs_metrics_update_by_service(HS_METRICS_NUM_INTRODUCTIONS,
- service, 0, 42);
+ service, 0, NULL, 42);
tt_int_op(metrics_store_entry_get_value(entry), OP_EQ, 84);
+ const char *reason = HS_METRICS_ERR_INTRO_REQ_BAD_AUTH_KEY;
+
/* Update tor_hs_intro_rejected_intro_req_count */
hs_metrics_update_by_ident(HS_METRICS_NUM_REJECTED_INTRO_REQ,
- &service->keys.identity_pk, 0, 112);
+ &service->keys.identity_pk, 0, reason, 112);
entries = metrics_store_get_all(service->metrics.store,
"tor_hs_intro_rejected_intro_req_count");
tt_assert(entries);
- tt_int_op(smartlist_len(entries), OP_EQ, 1);
- entry = smartlist_get(entries, 0);
+ tt_int_op(smartlist_len(entries), OP_EQ,
+ hs_metrics_intro_req_error_reasons_size);
+
+ entry = metrics_store_find_entry_with_label(
+ entries, "reason=\"bad_auth_key\"");
tt_assert(entry);
tt_int_op(metrics_store_entry_get_value(entry), OP_EQ, 112);
/* Update tor_hs_intro_rejected_intro_req_count entry by service now. */
- hs_metrics_update_by_service(HS_METRICS_NUM_REJECTED_INTRO_REQ,
- service, 0, 10);
+ hs_metrics_update_by_service(HS_METRICS_NUM_REJECTED_INTRO_REQ, service, 0,
+ reason, 10);
tt_int_op(metrics_store_entry_get_value(entry), OP_EQ, 122);
done: