relay_metrics.h (3834B)
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, 20 /** Number of onionskines handled. */ 21 RELAY_METRICS_NUM_ONIONSKINS, 22 /** Number of sockets. */ 23 RELAY_METRICS_NUM_SOCKETS, 24 /** Number of global connection rate limit. */ 25 RELAY_METRICS_NUM_GLOBAL_RW_LIMIT, 26 /** Number of DNS queries. */ 27 RELAY_METRICS_NUM_DNS, 28 /** Number of DNS query errors. */ 29 RELAY_METRICS_NUM_DNS_ERRORS, 30 /** Number of TCP exhaustion reached. */ 31 RELAY_METRICS_NUM_TCP_EXHAUSTION, 32 /** Connections counters (always going up). */ 33 RELAY_METRICS_CONN_COUNTERS, 34 /** Connections gauges. */ 35 RELAY_METRICS_CONN_GAUGES, 36 /** Number of streams. */ 37 RELAY_METRICS_NUM_STREAMS, 38 /** Congestion control counters. */ 39 RELAY_METRICS_CC_COUNTERS, 40 /** Congestion control gauges. */ 41 RELAY_METRICS_CC_GAUGES, 42 /** Denial of Service defenses subsystem. */ 43 RELAY_METRICS_NUM_DOS, 44 /** Denial of Service defenses subsystem. */ 45 RELAY_METRICS_NUM_TRAFFIC, 46 /** Relay flags. */ 47 RELAY_METRICS_RELAY_FLAGS, 48 /** Numer of circuits. */ 49 RELAY_METRICS_NUM_CIRCUITS, 50 /** Timestamp at which the current online keys will expire. */ 51 RELAY_METRICS_SIGNING_CERT_EXPIRY, 52 /** Number of times we received an EST_REND cell */ 53 RELAY_METRICS_NUM_EST_REND, 54 /** Number of times we received an EST_INTRO cell */ 55 RELAY_METRICS_NUM_EST_INTRO, 56 /** Number of times we received an INTRO1 cell */ 57 RELAY_METRICS_NUM_INTRO1_CELLS, 58 /** Number of times we received a REND1 cell */ 59 RELAY_METRICS_NUM_REND1_CELLS, 60 /** Number of circuit closed by receiving a DESTROY cell. */ 61 RELAY_METRICS_CIRC_DESTROY_CELL, 62 /** Number of circuits closed due to protocol violation. */ 63 RELAY_METRICS_CIRC_PROTO_VIOLATION, 64 /** Number of drop cell seen. */ 65 RELAY_METRICS_CIRC_DROP_CELL, 66 } relay_metrics_key_t; 67 68 /** The metadata of a relay metric. */ 69 typedef struct relay_metrics_entry_t { 70 /* Metric key used as a static array index. */ 71 relay_metrics_key_t key; 72 /* Metric type. */ 73 metrics_type_t type; 74 /* Metrics output name. */ 75 const char *name; 76 /* Metrics output help comment. */ 77 const char *help; 78 /* Update value function. */ 79 void (*fill_fn)(void); 80 } relay_metrics_entry_t; 81 82 /* Init. */ 83 void relay_metrics_init(void); 84 void relay_metrics_free(void); 85 86 /* Accessors. */ 87 const smartlist_t *relay_metrics_get_stores(void); 88 89 typedef enum { 90 EST_INTRO_SUCCESS, 91 EST_INTRO_MALFORMED, 92 EST_INTRO_UNSUITABLE_CIRCUIT, 93 EST_INTRO_CIRCUIT_DEAD, 94 95 EST_INTRO_ACTION_COUNT 96 } est_intro_action_t; 97 98 void relay_increment_est_intro_action(est_intro_action_t); 99 100 typedef enum { 101 EST_REND_SUCCESS, 102 EST_REND_UNSUITABLE_CIRCUIT, 103 EST_REND_SINGLE_HOP, 104 EST_REND_MALFORMED, 105 EST_REND_DUPLICATE_COOKIE, 106 EST_REND_CIRCUIT_DEAD, 107 108 EST_REND_ACTION_COUNT 109 } est_rend_action_t; 110 111 void relay_increment_est_rend_action(est_rend_action_t); 112 113 typedef enum { 114 INTRO1_SUCCESS, 115 INTRO1_CIRCUIT_DEAD, 116 INTRO1_MALFORMED, 117 INTRO1_UNKNOWN_SERVICE, 118 INTRO1_RATE_LIMITED, 119 INTRO1_CIRCUIT_REUSED, 120 INTRO1_SINGLE_HOP, 121 122 INTRO1_ACTION_COUNT 123 } intro1_action_t; 124 125 void relay_increment_intro1_action(intro1_action_t); 126 127 typedef enum { 128 REND1_SUCCESS, 129 REND1_UNSUITABLE_CIRCUIT, 130 REND1_MALFORMED, 131 REND1_UNKNOWN_COOKIE, 132 REND1_CIRCUIT_DEAD, 133 134 REND1_ACTION_COUNT 135 } rend1_action_t; 136 137 void relay_increment_rend1_action(rend1_action_t); 138 139 #endif /* !defined(TOR_FEATURE_RELAY_RELAY_METRICS_H) */