1 /* Copyright (c) 2021, The Tor Project, Inc. */ 2 /* See LICENSE for licensing information */ 3 4 /** 5 * @file relay_metrics.h 6 * @brief Header for feature/relay/relay_metrics.c 7 **/ 8 9 #ifndef TOR_FEATURE_RELAY_RELAY_METRICS_H 10 #define TOR_FEATURE_RELAY_RELAY_METRICS_H 11 12 #include "lib/container/smartlist.h" 13 #include "lib/metrics/metrics_common.h" 14 15 /** Metrics key for each reported metrics. This key is also used as an index in 16 * the base_metrics array. */ 17 typedef enum { 18 /** Number of OOM invocation. */ 19 RELAY_METRICS_NUM_OOM_BYTES = 0, 20 /** Number of onionskines handled. */ 21 RELAY_METRICS_NUM_ONIONSKINS = 1, 22 /** Number of sockets. */ 23 RELAY_METRICS_NUM_SOCKETS = 2, 24 /** Number of global connection rate limit. */ 25 RELAY_METRICS_NUM_GLOBAL_RW_LIMIT = 3, 26 /** Number of DNS queries. */ 27 RELAY_METRICS_NUM_DNS = 4, 28 /** Number of DNS query errors. */ 29 RELAY_METRICS_NUM_DNS_ERRORS = 5, 30 /** Number of TCP exhaustion reached. */ 31 RELAY_METRICS_NUM_TCP_EXHAUSTION = 6, 32 } relay_metrics_key_t; 33 34 /** The metadata of a relay metric. */ 35 typedef struct relay_metrics_entry_t { 36 /* Metric key used as a static array index. */ 37 relay_metrics_key_t key; 38 /* Metric type. */ 39 metrics_type_t type; 40 /* Metrics output name. */ 41 const char *name; 42 /* Metrics output help comment. */ 43 const char *help; 44 /* Update value function. */ 45 void (*fill_fn)(void); 46 } relay_metrics_entry_t; 47 48 /* Init. */ 49 void relay_metrics_init(void); 50 void relay_metrics_free(void); 51 52 /* Accessors. */ 53 const smartlist_t *relay_metrics_get_stores(void); 54 55 #endif /* !defined(TOR_FEATURE_RELAY_RELAY_METRICS_H) */ 56