mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
hs: Collect introduction circuit metrics
Tracks the total number of established introduction circuit. Related to #40063 Signed-off-by: David Goulet <dgoulet@torproject.org>
This commit is contained in:
@@ -57,4 +57,14 @@ void hs_metrics_update_by_service(const hs_metrics_key_t key,
|
||||
#define hs_metrics_new_rdv(i) \
|
||||
hs_metrics_update_by_ident(HS_METRICS_NUM_RDV, (i), 0, 1)
|
||||
|
||||
/** New introduction circuit has been established. This is called when the
|
||||
* INTRO_ESTABLISHED has been received by the service. */
|
||||
#define hs_metrics_new_established_intro(s) \
|
||||
hs_metrics_update_by_service(HS_METRICS_NUM_ESTABLISHED_INTRO, (s), 0, 1)
|
||||
|
||||
/** Established introduction circuit closes. This is called when
|
||||
* INTRO_ESTABLISHED circuit is marked for close. */
|
||||
#define hs_metrics_close_established_intro(i) \
|
||||
hs_metrics_update_by_ident(HS_METRICS_NUM_ESTABLISHED_INTRO, (i), 0, 1)
|
||||
|
||||
#endif /* !defined(TOR_FEATURE_HS_HS_METRICS_H) */
|
||||
|
||||
@@ -53,6 +53,12 @@ const hs_metrics_entry_t base_metrics[] =
|
||||
.name = "hs_rdv_num_total",
|
||||
.help = "Total number of rendezvous circuit created",
|
||||
},
|
||||
{
|
||||
.key = HS_METRICS_NUM_ESTABLISHED_INTRO,
|
||||
.type = METRICS_TYPE_GAUGE,
|
||||
.name = "hs_intro_established_count",
|
||||
.help = "Total number of established introduction circuit",
|
||||
},
|
||||
};
|
||||
|
||||
/** Size of base_metrics array that is number of entries. */
|
||||
|
||||
@@ -25,6 +25,8 @@ typedef enum {
|
||||
HS_METRICS_NUM_ESTABLISHED_RDV = 3,
|
||||
/** Number of rendezsvous circuits created. */
|
||||
HS_METRICS_NUM_RDV = 4,
|
||||
/** Number of established introducton points. */
|
||||
HS_METRICS_NUM_ESTABLISHED_INTRO = 5,
|
||||
} hs_metrics_key_t;
|
||||
|
||||
/** The metadata of an HS metrics. */
|
||||
|
||||
@@ -3451,6 +3451,9 @@ service_handle_intro_established(origin_circuit_t *circ,
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* Update metrics. */
|
||||
hs_metrics_new_established_intro(service);
|
||||
|
||||
log_info(LD_REND, "Successfully received an INTRO_ESTABLISHED cell "
|
||||
"on circuit %u for service %s",
|
||||
TO_CIRCUIT(circ)->n_circ_id,
|
||||
@@ -3597,6 +3600,12 @@ hs_service_circuit_cleanup_on_close(const circuit_t *circ)
|
||||
tor_assert(CIRCUIT_IS_ORIGIN(circ));
|
||||
|
||||
switch (circ->purpose) {
|
||||
case CIRCUIT_PURPOSE_S_INTRO:
|
||||
/* About to close an established introduction circuit. Update the metrics
|
||||
* to reflect how many we have at the moment. */
|
||||
hs_metrics_close_established_intro(
|
||||
&CONST_TO_ORIGIN_CIRCUIT(circ)->hs_ident->identity_pk);
|
||||
break;
|
||||
case CIRCUIT_PURPOSE_S_REND_JOINED:
|
||||
/* About to close an established rendezvous circuit. Update the metrics to
|
||||
* reflect how many we have at the moment. */
|
||||
|
||||
Reference in New Issue
Block a user