summaryrefslogtreecommitdiff
path: root/src/feature
diff options
context:
space:
mode:
Diffstat (limited to 'src/feature')
-rw-r--r--src/feature/stats/rephist.c44
-rw-r--r--src/feature/stats/rephist.h3
2 files changed, 47 insertions, 0 deletions
diff --git a/src/feature/stats/rephist.c b/src/feature/stats/rephist.c
index f12b1e8a70..962450e72b 100644
--- a/src/feature/stats/rephist.c
+++ b/src/feature/stats/rephist.c
@@ -1639,6 +1639,50 @@ rep_hist_note_exit_stream_opened(uint16_t port)
log_debug(LD_HIST, "Opened exit stream to port %d", port);
}
+/*** Streams statistics ***/
+
+/** Number of BEGIN streams seen. */
+static uint64_t streams_begin_seen;
+/** Number of BEGIN_DIR streams seen. */
+static uint64_t streams_begindir_seen;
+/** Number of RESOLVE streams seen. */
+static uint64_t streams_resolve_seen;
+
+/** Note a stream as seen for the given relay command. */
+void
+rep_hist_note_stream(unsigned int cmd)
+{
+ switch (cmd) {
+ case RELAY_COMMAND_BEGIN:
+ streams_begin_seen++;
+ break;
+ case RELAY_COMMAND_BEGIN_DIR:
+ streams_begindir_seen++;
+ break;
+ case RELAY_COMMAND_RESOLVE:
+ streams_resolve_seen++;
+ break;
+ default:
+ break;
+ }
+}
+
+/** Return number of stream seen for the given command. */
+uint64_t
+rep_hist_get_stream_seen(unsigned int cmd)
+{
+ switch (cmd) {
+ case RELAY_COMMAND_BEGIN:
+ return streams_begin_seen;
+ case RELAY_COMMAND_BEGIN_DIR:
+ return streams_begindir_seen;
+ case RELAY_COMMAND_RESOLVE:
+ return streams_resolve_seen;
+ default:
+ return 0;
+ }
+}
+
/******* Connections statistics *******/
#define CONN_DIRECTION_INITIATED 0
diff --git a/src/feature/stats/rephist.h b/src/feature/stats/rephist.h
index 2a83dd185e..c1352ae7f8 100644
--- a/src/feature/stats/rephist.h
+++ b/src/feature/stats/rephist.h
@@ -48,6 +48,9 @@ uint64_t rep_hist_get_conn_created(bool initiated, unsigned int type);
uint64_t rep_hist_get_conn_opened(bool initiated, unsigned int type);
uint64_t rep_hist_get_conn_rejected(unsigned int type);
+void rep_hist_note_stream(unsigned int cmd);
+uint64_t rep_hist_get_stream_seen(unsigned int cmd);
+
void rep_hist_buffer_stats_init(time_t now);
void rep_hist_buffer_stats_add_circ(circuit_t *circ,
time_t end_of_interval);