diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/feature/relay/relay_metrics.c | 29 | ||||
-rw-r--r-- | src/feature/relay/relay_metrics.h | 2 |
2 files changed, 30 insertions, 1 deletions
diff --git a/src/feature/relay/relay_metrics.c b/src/feature/relay/relay_metrics.c index 6816c25f43..72030e079b 100644 --- a/src/feature/relay/relay_metrics.c +++ b/src/feature/relay/relay_metrics.c @@ -22,8 +22,9 @@ #include "feature/stats/rephist.h" /** Declarations of each fill function for metrics defined in base_metrics. */ -static void fill_oom_values(void); +static void fill_socket_values(void); static void fill_onionskins_values(void); +static void fill_oom_values(void); /** The base metrics that is a static array of metrics added to the metrics * store. @@ -45,6 +46,13 @@ static const relay_metrics_entry_t base_metrics[] = .help = "Total number of onionskins handled", .fill_fn = fill_onionskins_values, }, + { + .key = RELAY_METRICS_NUM_SOCKETS, + .type = METRICS_TYPE_GAUGE, + .name = METRICS_NAME(relay_load_socket_total), + .help = "Total number of sockets", + .fill_fn = fill_socket_values, + }, }; static const size_t num_base_metrics = ARRAY_LENGTH(base_metrics); @@ -69,6 +77,25 @@ handshake_type_to_str(const uint16_t type) } } +/** Fill function for the RELAY_METRICS_NUM_SOCKETS metrics. */ +static void +fill_socket_values(void) +{ + metrics_store_entry_t *sentry; + const relay_metrics_entry_t *rentry = + &base_metrics[RELAY_METRICS_NUM_SOCKETS]; + + sentry = metrics_store_add(the_store, rentry->type, rentry->name, + rentry->help); + metrics_store_entry_add_label(sentry, + metrics_format_label("state", "opened")); + metrics_store_entry_update(sentry, get_n_open_sockets()); + + sentry = metrics_store_add(the_store, rentry->type, rentry->name, + rentry->help); + metrics_store_entry_update(sentry, get_max_sockets()); +} + /** Fill function for the RELAY_METRICS_NUM_ONIONSKINS metrics. */ static void fill_onionskins_values(void) diff --git a/src/feature/relay/relay_metrics.h b/src/feature/relay/relay_metrics.h index 6868bd26df..fd310ec7ae 100644 --- a/src/feature/relay/relay_metrics.h +++ b/src/feature/relay/relay_metrics.h @@ -19,6 +19,8 @@ typedef enum { RELAY_METRICS_NUM_OOM_BYTES = 0, /** Number of onionskines handled. */ RELAY_METRICS_NUM_ONIONSKINS = 1, + /** Number of sockets. */ + RELAY_METRICS_NUM_SOCKETS = 2, } relay_metrics_key_t; /** The metadata of a relay metric. */ |