static void fill_socket_values(void);
static void fill_onionskins_values(void);
static void fill_oom_values(void);
+static void fill_streams_values(void);
static void fill_tcp_exhaustion_values(void);
/** The base metrics that is a static array of metrics added to the metrics
.help = "Connections metrics of this relay",
.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);
}
}
+/** 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. */
static void
fill_single_connection_value(metrics_store_entry_t *sentry,