aboutsummaryrefslogtreecommitdiff
path: root/src/feature/stats/rephist.c
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2021-05-12 15:31:44 -0400
committerDavid Goulet <dgoulet@torproject.org>2021-05-12 15:31:44 -0400
commitd4fbfb54d41d9b93fbdfab48c59f0e688dd7f645 (patch)
tree463c0e3bc84073300fec225ac7198665d1d2c94d /src/feature/stats/rephist.c
parent3fbd510c527b64bb83e87d78e81f1ad72def5f5f (diff)
downloadtor-d4fbfb54d41d9b93fbdfab48c59f0e688dd7f645.tar.gz
tor-d4fbfb54d41d9b93fbdfab48c59f0e688dd7f645.zip
rephist: Add a counter for the onioniskins stats
Current counters are reset every heartbeat. This commit adds two counters for the assigned and dropped onionskins that are not reset so they can be exported onto the MetricsPort. Closes #40387 Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/feature/stats/rephist.c')
-rw-r--r--src/feature/stats/rephist.c33
1 files changed, 26 insertions, 7 deletions
diff --git a/src/feature/stats/rephist.c b/src/feature/stats/rephist.c
index 01fa644b9e..343303aa41 100644
--- a/src/feature/stats/rephist.c
+++ b/src/feature/stats/rephist.c
@@ -1997,12 +1997,18 @@ rep_hist_note_desc_served(const char * desc)
/** Internal statistics to track how many requests of each type of
* handshake we've received, and how many we've assigned to cpuworkers.
* Useful for seeing trends in cpu load.
+ *
+ * They are reset at every heartbeat.
* @{ */
STATIC int onion_handshakes_requested[MAX_ONION_HANDSHAKE_TYPE+1] = {0};
STATIC int onion_handshakes_assigned[MAX_ONION_HANDSHAKE_TYPE+1] = {0};
-STATIC uint64_t onion_handshakes_dropped[MAX_ONION_HANDSHAKE_TYPE+1] = {0};
/**@}*/
+/** Counters keeping the same stats as above but for the entire duration of the
+ * process (not reset). */
+static uint64_t stats_n_onionskin_assigned[MAX_ONION_HANDSHAKE_TYPE+1] = {0};
+static uint64_t stats_n_onionskin_dropped[MAX_ONION_HANDSHAKE_TYPE+1] = {0};
+
/** A new onionskin (using the <b>type</b> handshake) has arrived. */
void
rep_hist_note_circuit_handshake_requested(uint16_t type)
@@ -2016,8 +2022,10 @@ rep_hist_note_circuit_handshake_requested(uint16_t type)
void
rep_hist_note_circuit_handshake_assigned(uint16_t type)
{
- if (type <= MAX_ONION_HANDSHAKE_TYPE)
+ if (type <= MAX_ONION_HANDSHAKE_TYPE) {
onion_handshakes_assigned[type]++;
+ stats_n_onionskin_assigned[type]++;
+ }
}
/** We've just drop an onionskin (using the <b>type</b> handshake) due to being
@@ -2025,8 +2033,9 @@ rep_hist_note_circuit_handshake_assigned(uint16_t type)
void
rep_hist_note_circuit_handshake_dropped(uint16_t type)
{
- if (type <= MAX_ONION_HANDSHAKE_TYPE)
- onion_handshakes_dropped[type]++;
+ if (type <= MAX_ONION_HANDSHAKE_TYPE) {
+ stats_n_onionskin_dropped[type]++;
+ }
}
/** Get the circuit handshake value that is requested. */
@@ -2049,14 +2058,24 @@ rep_hist_get_circuit_handshake_assigned, (uint16_t type))
return onion_handshakes_assigned[type];
}
-/** Get the circuit handshake value that is dropped. */
+/** Get the total number of circuit handshake value that is assigned. */
+MOCK_IMPL(uint64_t,
+rep_hist_get_circuit_n_handshake_assigned, (uint16_t type))
+{
+ if (BUG(type > MAX_ONION_HANDSHAKE_TYPE)) {
+ return 0;
+ }
+ return stats_n_onionskin_assigned[type];
+}
+
+/** Get the total number of circuit handshake value that is dropped. */
MOCK_IMPL(uint64_t,
-rep_hist_get_circuit_handshake_dropped, (uint16_t type))
+rep_hist_get_circuit_n_handshake_dropped, (uint16_t type))
{
if (BUG(type > MAX_ONION_HANDSHAKE_TYPE)) {
return 0;
}
- return onion_handshakes_dropped[type];
+ return stats_n_onionskin_dropped[type];
}
/** Log our onionskin statistics since the last time we were called. */