mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-27 22:03:31 +01:00
relay: Add total number of streams seen on MetricsPort
Related to #40194 Signed-off-by: David Goulet <dgoulet@torproject.org>
This commit is contained in:
parent
98b98fd3ce
commit
e7e18ae914
@ -502,7 +502,7 @@ relay_header_unpack(relay_header_t *dest, const uint8_t *src)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Convert the relay <b>command</b> into a human-readable string. */
|
/** Convert the relay <b>command</b> into a human-readable string. */
|
||||||
static const char *
|
const char *
|
||||||
relay_command_to_string(uint8_t command)
|
relay_command_to_string(uint8_t command)
|
||||||
{
|
{
|
||||||
static char buf[64];
|
static char buf[64];
|
||||||
|
@ -16,6 +16,8 @@ extern uint64_t stats_n_relay_cells_relayed;
|
|||||||
extern uint64_t stats_n_relay_cells_delivered;
|
extern uint64_t stats_n_relay_cells_delivered;
|
||||||
extern uint64_t stats_n_circ_max_cell_reached;
|
extern uint64_t stats_n_circ_max_cell_reached;
|
||||||
|
|
||||||
|
const char *relay_command_to_string(uint8_t command);
|
||||||
|
|
||||||
void relay_consensus_has_changed(const networkstatus_t *ns);
|
void relay_consensus_has_changed(const networkstatus_t *ns);
|
||||||
uint32_t relay_get_param_max_circuit_cell_queue_size(
|
uint32_t relay_get_param_max_circuit_cell_queue_size(
|
||||||
const networkstatus_t *ns);
|
const networkstatus_t *ns);
|
||||||
|
@ -32,6 +32,7 @@ static void fill_global_bw_limit_values(void);
|
|||||||
static void fill_socket_values(void);
|
static void fill_socket_values(void);
|
||||||
static void fill_onionskins_values(void);
|
static void fill_onionskins_values(void);
|
||||||
static void fill_oom_values(void);
|
static void fill_oom_values(void);
|
||||||
|
static void fill_streams_values(void);
|
||||||
static void fill_tcp_exhaustion_values(void);
|
static void fill_tcp_exhaustion_values(void);
|
||||||
|
|
||||||
/** The base metrics that is a static array of metrics added to the metrics
|
/** The base metrics that is a static array of metrics added to the metrics
|
||||||
@ -96,6 +97,13 @@ static const relay_metrics_entry_t base_metrics[] =
|
|||||||
.help = "Connections metrics of this relay",
|
.help = "Connections metrics of this relay",
|
||||||
.fill_fn = fill_connections_values,
|
.fill_fn = fill_connections_values,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
.key = RELAY_METRICS_NUM_STREAMS,
|
||||||
|
.type = METRICS_TYPE_COUNTER,
|
||||||
|
.name = METRICS_NAME(relay_streams_total),
|
||||||
|
.help = "Total number of streams",
|
||||||
|
.fill_fn = fill_streams_values,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
static const size_t num_base_metrics = ARRAY_LENGTH(base_metrics);
|
static const size_t num_base_metrics = ARRAY_LENGTH(base_metrics);
|
||||||
|
|
||||||
@ -122,6 +130,34 @@ handshake_type_to_str(const uint16_t type)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Helper: Fill in single stream metrics output. */
|
||||||
|
static void
|
||||||
|
fill_single_stream_value(metrics_store_entry_t *sentry, uint8_t cmd)
|
||||||
|
{
|
||||||
|
metrics_store_entry_add_label(sentry,
|
||||||
|
metrics_format_label("type", relay_command_to_string(cmd)));
|
||||||
|
metrics_store_entry_update(sentry, rep_hist_get_stream_seen(cmd));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Fill function for the RELAY_METRICS_NUM_STREAMS metric. */
|
||||||
|
static void
|
||||||
|
fill_streams_values(void)
|
||||||
|
{
|
||||||
|
const relay_metrics_entry_t *rentry =
|
||||||
|
&base_metrics[RELAY_METRICS_NUM_STREAMS];
|
||||||
|
metrics_store_entry_t *sentry =
|
||||||
|
metrics_store_add(the_store, rentry->type, rentry->name, rentry->help);
|
||||||
|
fill_single_stream_value(sentry, RELAY_COMMAND_BEGIN);
|
||||||
|
|
||||||
|
sentry = metrics_store_add(the_store, rentry->type, rentry->name,
|
||||||
|
rentry->help);
|
||||||
|
fill_single_stream_value(sentry, RELAY_COMMAND_BEGIN_DIR);
|
||||||
|
|
||||||
|
sentry = metrics_store_add(the_store, rentry->type, rentry->name,
|
||||||
|
rentry->help);
|
||||||
|
fill_single_stream_value(sentry, RELAY_COMMAND_RESOLVE);
|
||||||
|
}
|
||||||
|
|
||||||
/** Helper: Fill in single connection metrics output. */
|
/** Helper: Fill in single connection metrics output. */
|
||||||
static void
|
static void
|
||||||
fill_single_connection_value(metrics_store_entry_t *sentry,
|
fill_single_connection_value(metrics_store_entry_t *sentry,
|
||||||
|
@ -31,6 +31,8 @@ typedef enum {
|
|||||||
RELAY_METRICS_NUM_TCP_EXHAUSTION = 6,
|
RELAY_METRICS_NUM_TCP_EXHAUSTION = 6,
|
||||||
/** Number of connections. */
|
/** Number of connections. */
|
||||||
RELAY_METRICS_NUM_CONNECTIONS = 7,
|
RELAY_METRICS_NUM_CONNECTIONS = 7,
|
||||||
|
/** Number of streams. */
|
||||||
|
RELAY_METRICS_NUM_STREAMS = 8,
|
||||||
} relay_metrics_key_t;
|
} relay_metrics_key_t;
|
||||||
|
|
||||||
/** The metadata of a relay metric. */
|
/** The metadata of a relay metric. */
|
||||||
|
Loading…
Reference in New Issue
Block a user