Tor  0.4.7.0-alpha-dev
Data Structures | Macros | Functions | Variables
relay_metrics.c File Reference

Relay metrics exposed through the MetricsPort. More...

#include "orconfig.h"
#include "core/or/or.h"
#include "core/or/relay.h"
#include "lib/malloc/malloc.h"
#include "lib/container/smartlist.h"
#include "lib/metrics/metrics_store.h"
#include "lib/log/util_bug.h"
#include "feature/relay/relay_metrics.h"
#include "feature/stats/rephist.h"
#include <event2/dns.h>

Go to the source code of this file.

Data Structures

struct  dns_type
 

Functions

static void fill_dns_error_values (void)
 
static void fill_dns_query_values (void)
 
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)
 
static void fill_tcp_exhaustion_values (void)
 
static const char * handshake_type_to_str (const uint16_t type)
 
static void fill_store (void)
 
const smartlist_trelay_metrics_get_stores (void)
 
void relay_metrics_init (void)
 
void relay_metrics_free (void)
 

Variables

static const relay_metrics_entry_t base_metrics []
 
static const size_t num_base_metrics = ARRAY_LENGTH(base_metrics)
 
static metrics_store_tthe_store
 
static struct dns_type dns_types []
 
static const size_t num_dns_types = ARRAY_LENGTH(dns_types)
 

Detailed Description

Relay metrics exposed through the MetricsPort.

Definition in file relay_metrics.c.

Function Documentation

◆ fill_dns_error_values()

static void fill_dns_error_values ( void  )
static

Declarations of each fill function for metrics defined in base_metrics.

Fill function for the RELAY_METRICS_NUM_DNS_ERRORS metrics.

Definition at line 141 of file relay_metrics.c.

◆ fill_dns_query_values()

static void fill_dns_query_values ( void  )
static

Fill function for the RELAY_METRICS_NUM_DNS metrics.

Definition at line 189 of file relay_metrics.c.

◆ fill_global_bw_limit_values()

static void fill_global_bw_limit_values ( void  )
static

Fill function for the RELAY_METRICS_NUM_GLOBAL_RW_LIMIT metrics.

Definition at line 211 of file relay_metrics.c.

◆ fill_onionskins_values()

static void fill_onionskins_values ( void  )
static

Fill function for the RELAY_METRICS_NUM_ONIONSKINS metrics.

Definition at line 251 of file relay_metrics.c.

◆ fill_oom_values()

static void fill_oom_values ( void  )
static

Fill function for the RELAY_METRICS_NUM_OOM_BYTES metrics.

Definition at line 283 of file relay_metrics.c.

◆ fill_socket_values()

static void fill_socket_values ( void  )
static

Fill function for the RELAY_METRICS_NUM_SOCKETS metrics.

Definition at line 232 of file relay_metrics.c.

◆ fill_store()

static void fill_store ( void  )
static

Reset the global store and fill it with all the metrics from base_metrics and their associated values.

To pull this off, every metrics has a "fill" function that is called and in charge of adding the metrics to the store, appropriate labels and finally updating the value to report.

Definition at line 321 of file relay_metrics.c.

Referenced by relay_metrics_get_stores().

◆ fill_tcp_exhaustion_values()

static void fill_tcp_exhaustion_values ( void  )
static

Fill function for the RELAY_METRICS_NUM_DNS metrics.

Definition at line 116 of file relay_metrics.c.

◆ handshake_type_to_str()

static const char* handshake_type_to_str ( const uint16_t  type)
inlinestatic

Helper function to convert an handshake type into a string.

Definition at line 98 of file relay_metrics.c.

◆ relay_metrics_free()

void relay_metrics_free ( void  )

Free the relay metrics.

Definition at line 371 of file relay_metrics.c.

◆ relay_metrics_get_stores()

const smartlist_t* relay_metrics_get_stores ( void  )

Return a list of all the relay metrics stores. This is the function attached to the .get_metrics() member of the subsys_t.

Definition at line 338 of file relay_metrics.c.

◆ relay_metrics_init()

void relay_metrics_init ( void  )

Initialize the relay metrics.

Definition at line 361 of file relay_metrics.c.

Variable Documentation

◆ base_metrics

const relay_metrics_entry_t base_metrics[]
static

The base metrics that is a static array of metrics added to the metrics store.

The key member MUST be also the index of the entry in the array.

Definition at line 39 of file relay_metrics.c.

Referenced by fill_dns_error_values(), fill_dns_query_values(), fill_global_bw_limit_values(), fill_onionskins_values(), fill_oom_values(), fill_socket_values(), and fill_tcp_exhaustion_values().

◆ dns_types

struct dns_type dns_types[]
static
Initial value:
= {
{ .name = "A", .type = DNS_IPv4_A },
{ .name = "PTR", .type = DNS_PTR },
{ .name = "AAAA", .type = DNS_IPv6_AAAA },
}

◆ the_store

metrics_store_t* the_store
static

The only and single store of all the relay metrics.

Definition at line 94 of file relay_metrics.c.

Referenced by fill_global_bw_limit_values(), fill_oom_values(), fill_socket_values(), fill_store(), fill_tcp_exhaustion_values(), relay_metrics_free(), and relay_metrics_get_stores().