diff options
author | David Goulet <dgoulet@torproject.org> | 2021-05-05 14:09:07 -0400 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2021-05-12 11:58:25 -0400 |
commit | 897344fddc1ea5ba6dc0db814a703932b05560f4 (patch) | |
tree | 5906976057f27d2be9d496493c20e63ebd20ad12 /src/feature/relay | |
parent | 9040a5475ddaee4a244ae9e03f4597a75f86d9be (diff) | |
download | tor-897344fddc1ea5ba6dc0db814a703932b05560f4.tar.gz tor-897344fddc1ea5ba6dc0db814a703932b05560f4.zip |
relay: Add the global connection limit metrics
This emits two events (read and write) of the total number that the
global connection limit was reached.
Related to #40367
Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/feature/relay')
-rw-r--r-- | src/feature/relay/relay_metrics.c | 29 | ||||
-rw-r--r-- | src/feature/relay/relay_metrics.h | 2 |
2 files changed, 31 insertions, 0 deletions
diff --git a/src/feature/relay/relay_metrics.c b/src/feature/relay/relay_metrics.c index 72030e079b..47d7258239 100644 --- a/src/feature/relay/relay_metrics.c +++ b/src/feature/relay/relay_metrics.c @@ -22,6 +22,7 @@ #include "feature/stats/rephist.h" /** Declarations of each fill function for metrics defined in base_metrics. */ +static void fill_global_bw_limit_values(void); static void fill_socket_values(void); static void fill_onionskins_values(void); static void fill_oom_values(void); @@ -53,6 +54,13 @@ static const relay_metrics_entry_t base_metrics[] = .help = "Total number of sockets", .fill_fn = fill_socket_values, }, + { + .key = RELAY_METRICS_NUM_GLOBAL_RW_LIMIT, + .type = METRICS_TYPE_COUNTER, + .name = METRICS_NAME(relay_load_global_rate_limit_reached_total), + .help = "Total number of global connection bucket limit reached", + .fill_fn = fill_global_bw_limit_values, + }, }; static const size_t num_base_metrics = ARRAY_LENGTH(base_metrics); @@ -77,6 +85,27 @@ handshake_type_to_str(const uint16_t type) } } +/** Fill function for the RELAY_METRICS_NUM_GLOBAL_RW_LIMIT metrics. */ +static void +fill_global_bw_limit_values(void) +{ + metrics_store_entry_t *sentry; + const relay_metrics_entry_t *rentry = + &base_metrics[RELAY_METRICS_NUM_GLOBAL_RW_LIMIT]; + + sentry = metrics_store_add(the_store, rentry->type, rentry->name, + rentry->help); + metrics_store_entry_add_label(sentry, + metrics_format_label("side", "read")); + metrics_store_entry_update(sentry, rep_hist_get_n_read_limit_reached()); + + sentry = metrics_store_add(the_store, rentry->type, rentry->name, + rentry->help); + metrics_store_entry_add_label(sentry, + metrics_format_label("side", "write")); + metrics_store_entry_update(sentry, rep_hist_get_n_write_limit_reached()); +} + /** Fill function for the RELAY_METRICS_NUM_SOCKETS metrics. */ static void fill_socket_values(void) diff --git a/src/feature/relay/relay_metrics.h b/src/feature/relay/relay_metrics.h index fd310ec7ae..0fb7e82fa4 100644 --- a/src/feature/relay/relay_metrics.h +++ b/src/feature/relay/relay_metrics.h @@ -21,6 +21,8 @@ typedef enum { RELAY_METRICS_NUM_ONIONSKINS = 1, /** Number of sockets. */ RELAY_METRICS_NUM_SOCKETS = 2, + /** Number of global connection rate limit. */ + RELAY_METRICS_NUM_GLOBAL_RW_LIMIT = 3, } relay_metrics_key_t; /** The metadata of a relay metric. */ |