aboutsummaryrefslogtreecommitdiff
path: root/src/feature/relay/relay_metrics.c
diff options
context:
space:
mode:
authorfriendly73 <friendly73@x.x>2023-02-19 16:17:50 +0000
committerDavid Goulet <dgoulet@torproject.org>2023-05-25 11:03:35 -0400
commit36076d3c46afd02bb7072c9d2aa9c5196932f024 (patch)
tree591e88f1e467f986c40c2b29a451d9365c773d4e /src/feature/relay/relay_metrics.c
parenta1042f4873edd2f04787e7f60b3f9d3642b36611 (diff)
downloadtor-36076d3c46afd02bb7072c9d2aa9c5196932f024.tar.gz
tor-36076d3c46afd02bb7072c9d2aa9c5196932f024.zip
Added INTRO and REND metrics for relay.
Diffstat (limited to 'src/feature/relay/relay_metrics.c')
-rw-r--r--src/feature/relay/relay_metrics.c151
1 files changed, 151 insertions, 0 deletions
diff --git a/src/feature/relay/relay_metrics.c b/src/feature/relay/relay_metrics.c
index 5309411804..a1cd855b3d 100644
--- a/src/feature/relay/relay_metrics.c
+++ b/src/feature/relay/relay_metrics.c
@@ -59,6 +59,11 @@ static void fill_tcp_exhaustion_values(void);
static void fill_traffic_values(void);
static void fill_signing_cert_expiry(void);
+static void fill_est_intro_cells(void);
+static void fill_est_rend_cells(void);
+static void fill_intro1_cells(void);
+static void fill_rend1_cells(void);
+
/** The base metrics that is a static array of metrics added to the metrics
* store.
*
@@ -184,6 +189,34 @@ static const relay_metrics_entry_t base_metrics[] =
.help = "Timestamp at which the current online keys will expire",
.fill_fn = fill_signing_cert_expiry,
},
+ {
+ .key = RELAY_METRICS_NUM_EST_REND,
+ .type = METRICS_TYPE_COUNTER,
+ .name = METRICS_NAME(relay_est_rend_total),
+ .help = "Total number of EST_REND cells we received",
+ .fill_fn = fill_est_rend_cells,
+ },
+ {
+ .key = RELAY_METRICS_NUM_EST_INTRO,
+ .type = METRICS_TYPE_COUNTER,
+ .name = METRICS_NAME(relay_est_intro_total),
+ .help = "Total number of EST_INTRO cells we received",
+ .fill_fn = fill_est_intro_cells,
+ },
+ {
+ .key = RELAY_METRICS_NUM_INTRO1_CELLS,
+ .type = METRICS_TYPE_COUNTER,
+ .name = METRICS_NAME(relay_intro1_total),
+ .help = "Total number of INTRO1 cells we received",
+ .fill_fn = fill_intro1_cells,
+ },
+ {
+ .key = RELAY_METRICS_NUM_REND1_CELLS,
+ .type = METRICS_TYPE_COUNTER,
+ .name = METRICS_NAME(relay_rend1_total),
+ .help = "Total number of REND1 cells we received",
+ .fill_fn = fill_rend1_cells,
+ },
};
static const size_t num_base_metrics = ARRAY_LENGTH(base_metrics);
@@ -1020,6 +1053,124 @@ fill_signing_cert_expiry(void)
}
}
+static void
+fill_est_intro_cells(void)
+{
+ metrics_store_entry_t *sentry;
+ const relay_metrics_entry_t *rentry =
+ &base_metrics[RELAY_METRICS_NUM_EST_INTRO];
+
+ static struct {
+ const char *name;
+ est_intro_action_t key;
+ } actions[] = {
+ {.name = "success", .key = EST_INTRO_SUCCESS},
+ {.name = "malformed", .key = EST_INTRO_MALFORMED},
+ {.name = "unsuitable_circuit", .key = EST_INTRO_UNSUITABLE_CIRCUIT},
+ {.name = "circuit_dead", .key = EST_INTRO_CIRCUIT_DEAD},
+ };
+ static const size_t num_actions = ARRAY_LENGTH(actions);
+
+ for (size_t i = 0; i < num_actions; ++i) {
+ sentry =
+ metrics_store_add(the_store, rentry->type, rentry->name, rentry->help);
+ metrics_store_entry_add_label(
+ sentry, metrics_format_label("action", actions[i].name));
+ metrics_store_entry_update(
+ sentry, (long)rep_hist_get_est_intro_action_count(actions[i].key));
+ }
+}
+
+static void
+fill_est_rend_cells(void)
+{
+ metrics_store_entry_t *sentry;
+ const relay_metrics_entry_t *rentry =
+ &base_metrics[RELAY_METRICS_NUM_EST_REND];
+
+ static struct {
+ const char *name;
+ est_rend_action_t key;
+ } actions[] = {
+ {.name = "success", .key = EST_REND_SUCCESS},
+ {.name = "unsuitable_circuit", .key = EST_REND_UNSUITABLE_CIRCUIT},
+ {.name = "single_hop", .key = EST_REND_SINGLE_HOP},
+ {.name = "malformed", .key = EST_REND_MALFORMED},
+ {.name = "duplicate_cookie", .key = EST_REND_DUPLICATE_COOKIE},
+ {.name = "circuit_dead", .key = EST_REND_CIRCUIT_DEAD},
+ };
+ static const size_t num_actions = ARRAY_LENGTH(actions);
+
+ for (size_t i = 0; i < num_actions; ++i) {
+ sentry =
+ metrics_store_add(the_store, rentry->type, rentry->name, rentry->help);
+ metrics_store_entry_add_label(
+ sentry, metrics_format_label("action", actions[i].name));
+ metrics_store_entry_update(
+ sentry, (long)rep_hist_get_est_rend_action_count(actions[i].key));
+ }
+}
+
+static void
+fill_intro1_cells(void)
+{
+ metrics_store_entry_t *sentry;
+ const relay_metrics_entry_t *rentry =
+ &base_metrics[RELAY_METRICS_NUM_INTRO1_CELLS];
+
+ static struct {
+ const char *name;
+ intro1_action_t key;
+ } actions[] = {
+ {.name = "success", .key = INTRO1_SUCCESS},
+ {.name = "circuit_dead", .key = INTRO1_CIRCUIT_DEAD},
+ {.name = "malformed", .key = INTRO1_MALFORMED},
+ {.name = "unknown_service", .key = INTRO1_UNKNOWN_SERVICE},
+ {.name = "rate_limited", .key = INTRO1_RATE_LIMITED},
+ {.name = "circuit_reused", .key = INTRO1_CIRCUIT_REUSED},
+ {.name = "single_hop", .key = INTRO1_SINGLE_HOP},
+ };
+ static const size_t num_actions = ARRAY_LENGTH(actions);
+
+ for (size_t i = 0; i < num_actions; ++i) {
+ sentry =
+ metrics_store_add(the_store, rentry->type, rentry->name, rentry->help);
+ metrics_store_entry_add_label(
+ sentry, metrics_format_label("action", actions[i].name));
+ metrics_store_entry_update(
+ sentry, (long)rep_hist_get_intro1_action_count(actions[i].key));
+ }
+}
+
+static void
+fill_rend1_cells(void)
+{
+ metrics_store_entry_t *sentry;
+ const relay_metrics_entry_t *rentry =
+ &base_metrics[RELAY_METRICS_NUM_REND1_CELLS];
+
+ static struct {
+ const char *name;
+ rend1_action_t key;
+ } actions[] = {
+ {.name = "success", .key = REND1_SUCCESS},
+ {.name = "unsuitable_circuit", .key = REND1_UNSUITABLE_CIRCUIT},
+ {.name = "malformed", .key = REND1_MALFORMED},
+ {.name = "unknown_service", .key = REND1_UNKNOWN_SERVICE},
+ {.name = "circuit_dead", .key = REND1_CIRCUIT_DEAD},
+ };
+ static const size_t num_actions = ARRAY_LENGTH(actions);
+
+ for (size_t i = 0; i < num_actions; ++i) {
+ sentry =
+ metrics_store_add(the_store, rentry->type, rentry->name, rentry->help);
+ metrics_store_entry_add_label(
+ sentry, metrics_format_label("action", actions[i].name));
+ metrics_store_entry_update(
+ sentry, (long)rep_hist_get_rend1_action_count(actions[i].key));
+ }
+}
+
/** Reset the global store and fill it with all the metrics from base_metrics
* and their associated values.
*