9 #define RELAY_METRICS_ENTRY_PRIVATE
20 #include "core/or/dos.h"
39 #include <event2/dns.h>
67 .type = METRICS_TYPE_COUNTER,
68 .name = METRICS_NAME(relay_load_oom_bytes_total),
69 .help =
"Total number of bytes the OOM has freed by subsystem",
74 .type = METRICS_TYPE_COUNTER,
75 .name = METRICS_NAME(relay_load_onionskins_total),
76 .help =
"Total number of onionskins handled",
81 .type = METRICS_TYPE_GAUGE,
82 .name = METRICS_NAME(relay_load_socket_total),
83 .help =
"Total number of sockets",
88 .type = METRICS_TYPE_COUNTER,
89 .name = METRICS_NAME(relay_load_global_rate_limit_reached_total),
90 .help =
"Total number of global connection bucket limit reached",
95 .type = METRICS_TYPE_COUNTER,
96 .name = METRICS_NAME(relay_exit_dns_query_total),
97 .help =
"Total number of DNS queries done by this relay",
102 .type = METRICS_TYPE_COUNTER,
103 .name = METRICS_NAME(relay_exit_dns_error_total),
104 .help =
"Total number of DNS errors encountered by this relay",
109 .type = METRICS_TYPE_COUNTER,
110 .name = METRICS_NAME(relay_load_tcp_exhaustion_total),
111 .help =
"Total number of times we ran out of TCP ports",
116 .type = METRICS_TYPE_COUNTER,
117 .name = METRICS_NAME(relay_connections_total),
118 .help =
"Total number of created/rejected connections",
123 .type = METRICS_TYPE_GAUGE,
124 .name = METRICS_NAME(relay_connections),
125 .help =
"Total number of opened connections",
130 .type = METRICS_TYPE_COUNTER,
131 .name = METRICS_NAME(relay_streams_total),
132 .help =
"Total number of streams",
137 .type = METRICS_TYPE_COUNTER,
138 .name = METRICS_NAME(relay_congestion_control_total),
139 .help =
"Congestion control related counters",
144 .type = METRICS_TYPE_GAUGE,
145 .name = METRICS_NAME(relay_congestion_control),
146 .help =
"Congestion control related gauges",
151 .type = METRICS_TYPE_COUNTER,
152 .name = METRICS_NAME(relay_dos_total),
153 .help =
"Denial of Service defenses related counters",
158 .type = METRICS_TYPE_COUNTER,
159 .name = METRICS_NAME(relay_traffic_bytes),
160 .help =
"Traffic related counters",
165 .type = METRICS_TYPE_GAUGE,
166 .name = METRICS_NAME(relay_flag),
167 .help =
"Relay flags from consensus",
172 .type = METRICS_TYPE_GAUGE,
173 .name = METRICS_NAME(relay_circuits_total),
174 .help =
"Total number of circuits",
184 static inline const char *
188 case ONION_HANDSHAKE_TYPE_TAP:
190 case ONION_HANDSHAKE_TYPE_FAST:
192 case ONION_HANDSHAKE_TYPE_NTOR:
194 case ONION_HANDSHAKE_TYPE_NTOR_V3:
198 tor_assert_unreached();
204 static inline const char *
226 the_store, rentry->type, rentry->name, rentry->help, 0, NULL);
238 uint8_t is_fast = 0, is_exit = 0, is_authority = 0, is_stable = 0;
239 uint8_t is_running = 0, is_v2_dir = 0, is_guard = 0, is_sybil = 0;
240 uint8_t is_hs_dir = 0;
250 is_v2_dir = me->rs->is_v2_dir;
259 the_store, rentry->type, rentry->name, rentry->help, 0, NULL);
266 rentry->help, 0, NULL);
272 rentry->help, 0, NULL);
278 rentry->help, 0, NULL);
284 rentry->help, 0, NULL);
290 rentry->help, 0, NULL);
296 rentry->help, 0, NULL);
302 rentry->help, 0, NULL);
308 rentry->help, 0, NULL);
321 the_store, rentry->type, rentry->name, rentry->help, 0, NULL);
328 rentry->help, 0, NULL);
340 the_store, rentry->type, rentry->name, rentry->help, 0, NULL);
347 rentry->help, 0, NULL);
353 rentry->help, 0, NULL);
359 rentry->help, 0, NULL);
365 rentry->help, 0, NULL);
371 rentry->help, 0, NULL);
377 rentry->help, 0, NULL);
383 rentry->help, 0, NULL);
389 rentry->help, 0, NULL);
403 the_store, rentry->type, rentry->name, rentry->help, 0, NULL);
411 rentry->help, 0, NULL);
420 rentry->help, 0, NULL);
429 rentry->help, 0, NULL);
435 cc_stats_flow_num_xon_sent);
438 rentry->help, 0, NULL);
446 rentry->help, 0, NULL);
454 rentry->help, 0, NULL);
462 rentry->help, 0, NULL);
470 rentry->help, 0, NULL);
478 rentry->help, 0, NULL);
494 the_store, rentry->type, rentry->name, rentry->help, 0, NULL);
503 rentry->help, 0, NULL);
512 rentry->help, 0, NULL);
521 rentry->help, 0, NULL);
530 rentry->help, 0, NULL);
539 rentry->help, 0, NULL);
548 rentry->help, 0, NULL);
557 rentry->help, 0, NULL);
566 rentry->help, 0, NULL);
575 rentry->help, 0, NULL);
584 rentry->help, 0, NULL);
593 rentry->help, 0, NULL);
602 rentry->help, 0, NULL);
611 rentry->help, 0, NULL);
620 rentry->help, 0, NULL);
629 rentry->help, 0, NULL);
638 rentry->help, 0, NULL);
663 the_store, rentry->type, rentry->name, rentry->help, 0, NULL);
667 rentry->help, 0, NULL);
671 rentry->help, 0, NULL);
678 unsigned int conn_type,
679 const char* direction,
702 for (
unsigned int i = CONN_TYPE_MIN_; i < CONN_TYPE_MAX_ ; i++) {
708 the_store, rentry->type, rentry->name, rentry->help, 0, NULL);
712 rentry->help, 0, NULL);
718 rentry->help, 0, NULL);
722 rentry->help, 0, NULL);
727 rentry->help, 0, NULL);
731 rentry->help, 0, NULL);
746 for (
unsigned int i = CONN_TYPE_MIN_; i < CONN_TYPE_MAX_ ; i++) {
752 the_store, rentry->type, rentry->name, rentry->help, 0, NULL);
756 rentry->help, 0, NULL);
761 rentry->help, 0, NULL);
765 rentry->help, 0, NULL);
775 metrics_store_entry_t *sentry;
780 rentry->help, 0, NULL);
788 static struct dns_type {
792 { .name =
"A", .type = DNS_IPv4_A },
793 { .name =
"PTR", .type = DNS_PTR },
794 { .name =
"AAAA", .type = DNS_IPv6_AAAA },
796 static const size_t num_dns_types =
ARRAY_LENGTH(dns_types);
803 metrics_store_entry_t *sentry;
809 static struct dns_error {
813 { .name =
"success", .key = DNS_ERR_NONE },
814 { .name =
"format", .key = DNS_ERR_FORMAT },
815 { .name =
"serverfailed", .key = DNS_ERR_SERVERFAILED },
816 { .name =
"notexist", .key = DNS_ERR_NOTEXIST },
817 { .name =
"notimpl", .key = DNS_ERR_NOTIMPL },
818 { .name =
"refused", .key = DNS_ERR_REFUSED },
819 { .name =
"truncated", .key = DNS_ERR_TRUNCATED },
820 { .name =
"unknown", .key = DNS_ERR_UNKNOWN },
821 { .name =
"tor_timeout", .key = DNS_ERR_TIMEOUT },
822 { .name =
"shutdown", .key = DNS_ERR_SHUTDOWN },
823 { .name =
"cancel", .key = DNS_ERR_CANCEL },
824 { .name =
"nodata", .key = DNS_ERR_NODATA },
830 for (
size_t i = 0; i < num_dns_types; i++) {
836 for (
size_t j = 0; j < num_errors; j++) {
838 rentry->help, 0, NULL);
850 for (
size_t j = 0; j < num_errors; j++) {
852 rentry->help, 0, NULL);
864 metrics_store_entry_t *sentry;
870 for (
size_t i = 0; i < num_dns_types; i++) {
876 rentry->help, 0, NULL);
885 rentry->help, 0, NULL);
893 metrics_store_entry_t *sentry;
898 rentry->help, 0, NULL);
904 rentry->help, 0, NULL);
914 metrics_store_entry_t *sentry;
919 rentry->help, 0, NULL);
925 rentry->help, 0, NULL);
933 metrics_store_entry_t *sentry;
937 for (uint16_t t = 0; t <= MAX_ONION_HANDSHAKE_TYPE; t++) {
943 rentry->help, 0, NULL);
951 rentry->help, 0, NULL);
965 metrics_store_entry_t *sentry;
970 rentry->help, 0, NULL);
976 rentry->help, 0, NULL);
982 rentry->help, 0, NULL);
988 rentry->help, 0, NULL);
1007 for (
size_t i = 0; i < num_base_metrics; i++) {
double cc_stats_circ_close_ss_cwnd_ma
smartlist_t * circuit_get_global_list(void)
double cc_stats_circ_close_cwnd_ma
Header file for circuitlist.c.
Header file for config.c.
uint64_t congestion_control_get_num_clock_stalls(void)
uint64_t congestion_control_get_num_rtt_reset(void)
uint64_t cc_stats_circs_created
Public APIs for congestion control.
uint64_t cc_stats_flow_num_xoff_sent
APIs for stream flow control on congestion controlled circuits.
uint64_t cc_stats_vegas_above_ss_cwnd_max
uint64_t cc_stats_vegas_above_delta
double cc_stats_vegas_exit_ss_cwnd_ma
Private-ish APIs for the TOR_VEGAS congestion control algorithm.
const char * conn_type_to_string(int type)
Header file for connection.c.
int64_t tor_llround(double d)
uint64_t hs_dos_get_intro2_rejected_count(void)
Header file containing denial of service defenses for the HS subsystem for all versions.
uint64_t get_bytes_read(void)
uint64_t get_bytes_written(void)
Header file for mainloop.c.
Headers for util_malloc.c.
const char * metrics_format_label(const char *key, const char *value)
metrics_store_entry_t * metrics_store_add(metrics_store_t *store, metrics_type_t type, const char *name, const char *help, size_t bucket_count, const int64_t *buckets)
metrics_store_t * metrics_store_new(void)
void metrics_store_reset(metrics_store_t *store)
Header for lib/metrics/metrics_store.c.
void metrics_store_entry_update(metrics_store_entry_t *entry, const int64_t value)
void metrics_store_entry_add_label(metrics_store_entry_t *entry, const char *label)
Node information structure.
const node_t * node_get_by_id(const char *identity_digest)
Header file for nodelist.c.
Master header file for Tor-specific functionality.
uint64_t oom_stats_n_bytes_removed_dns
uint64_t stats_n_circ_max_cell_reached
const char * relay_command_to_string(uint8_t command)
static void fill_oom_values(void)
static const char * handshake_type_to_str(const uint16_t type)
static void fill_traffic_values(void)
static void fill_store(void)
static void fill_streams_values(void)
static void fill_tcp_exhaustion_values(void)
static void fill_dns_query_values(void)
static void fill_onionskins_values(void)
static void fill_dos_values(void)
static void fill_dns_error_values(void)
static void fill_conn_gauge_values(void)
static void fill_conn_counter_values(void)
void relay_metrics_init(void)
static void fill_single_stream_value(metrics_store_entry_t *sentry, uint8_t cmd)
static void fill_single_connection_value(metrics_store_entry_t *sentry, unsigned int conn_type, const char *direction, const char *state, int socket_family, uint64_t value)
static void fill_circuits_values(void)
static void fill_global_bw_limit_values(void)
const smartlist_t * relay_metrics_get_stores(void)
static void fill_cc_counters_values(void)
void relay_metrics_free(void)
static const char * af_to_string(const int af)
static void fill_relay_flags(void)
static const relay_metrics_entry_t base_metrics[]
static void fill_cc_gauges_values(void)
static void fill_socket_values(void)
static metrics_store_t * the_store
Header for feature/relay/relay_metrics.c.
@ RELAY_METRICS_CC_GAUGES
@ RELAY_METRICS_NUM_GLOBAL_RW_LIMIT
@ RELAY_METRICS_NUM_STREAMS
@ RELAY_METRICS_NUM_CIRCUITS
@ RELAY_METRICS_NUM_TCP_EXHAUSTION
@ RELAY_METRICS_NUM_SOCKETS
@ RELAY_METRICS_CONN_COUNTERS
@ RELAY_METRICS_CC_COUNTERS
@ RELAY_METRICS_CONN_GAUGES
@ RELAY_METRICS_NUM_ONIONSKINS
@ RELAY_METRICS_RELAY_FLAGS
@ RELAY_METRICS_NUM_DNS_ERRORS
@ RELAY_METRICS_NUM_OOM_BYTES
@ RELAY_METRICS_NUM_TRAFFIC
uint64_t rep_hist_get_conn_created(bool from_listener, unsigned int type, int af)
uint64_t rep_hist_get_n_dns_request(int type)
uint64_t rep_hist_get_conn_rejected(unsigned int type, int af)
uint64_t rep_hist_get_circuit_n_handshake_assigned(uint16_t type)
uint64_t rep_hist_get_conn_opened(bool from_listener, unsigned int type, int af)
uint64_t rep_hist_get_n_dns_error(int type, uint8_t error)
uint64_t rep_hist_get_n_read_limit_reached(void)
uint64_t rep_hist_get_n_tcp_exhaustion(void)
uint64_t rep_hist_get_circuit_n_handshake_dropped(uint16_t type)
uint64_t rep_hist_get_exit_stream_seen(unsigned int cmd)
uint64_t rep_hist_get_n_write_limit_reached(void)
Header file for rephist.c.
const uint8_t * router_get_my_id_digest(void)
Header file for router.c.
Routerstatus (consensus entry) structure.
smartlist_t * smartlist_new(void)
void smartlist_add(smartlist_t *sl, void *element)
int get_max_sockets(void)
int get_n_open_sockets(void)
unsigned int is_possible_guard
unsigned int is_flagged_running
unsigned int is_authority
Macros to manage assertions, fatal and non-fatal.