Commit 97731196 authored by David Goulet's avatar David Goulet 🆘
Browse files

hs: Collect introduction circuit metrics



Tracks the total number of established introduction circuit.

Related to #40063
Signed-off-by: David Goulet's avatarDavid Goulet <dgoulet@torproject.org>
parent c081bee3
...@@ -57,4 +57,14 @@ void hs_metrics_update_by_service(const hs_metrics_key_t key, ...@@ -57,4 +57,14 @@ void hs_metrics_update_by_service(const hs_metrics_key_t key,
#define hs_metrics_new_rdv(i) \ #define hs_metrics_new_rdv(i) \
hs_metrics_update_by_ident(HS_METRICS_NUM_RDV, (i), 0, 1) 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) */ #endif /* !defined(TOR_FEATURE_HS_HS_METRICS_H) */
...@@ -53,6 +53,12 @@ const hs_metrics_entry_t base_metrics[] = ...@@ -53,6 +53,12 @@ const hs_metrics_entry_t base_metrics[] =
.name = "hs_rdv_num_total", .name = "hs_rdv_num_total",
.help = "Total number of rendezvous circuit created", .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. */ /** Size of base_metrics array that is number of entries. */
......
...@@ -25,6 +25,8 @@ typedef enum { ...@@ -25,6 +25,8 @@ typedef enum {
HS_METRICS_NUM_ESTABLISHED_RDV = 3, HS_METRICS_NUM_ESTABLISHED_RDV = 3,
/** Number of rendezsvous circuits created. */ /** Number of rendezsvous circuits created. */
HS_METRICS_NUM_RDV = 4, HS_METRICS_NUM_RDV = 4,
/** Number of established introducton points. */
HS_METRICS_NUM_ESTABLISHED_INTRO = 5,
} hs_metrics_key_t; } hs_metrics_key_t;
/** The metadata of an HS metrics. */ /** The metadata of an HS metrics. */
......
...@@ -3451,6 +3451,9 @@ service_handle_intro_established(origin_circuit_t *circ, ...@@ -3451,6 +3451,9 @@ service_handle_intro_established(origin_circuit_t *circ,
goto err; goto err;
} }
/* Update metrics. */
hs_metrics_new_established_intro(service);
log_info(LD_REND, "Successfully received an INTRO_ESTABLISHED cell " log_info(LD_REND, "Successfully received an INTRO_ESTABLISHED cell "
"on circuit %u for service %s", "on circuit %u for service %s",
TO_CIRCUIT(circ)->n_circ_id, TO_CIRCUIT(circ)->n_circ_id,
...@@ -3597,6 +3600,12 @@ hs_service_circuit_cleanup_on_close(const circuit_t *circ) ...@@ -3597,6 +3600,12 @@ hs_service_circuit_cleanup_on_close(const circuit_t *circ)
tor_assert(CIRCUIT_IS_ORIGIN(circ)); tor_assert(CIRCUIT_IS_ORIGIN(circ));
switch (circ->purpose) { 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: case CIRCUIT_PURPOSE_S_REND_JOINED:
/* About to close an established rendezvous circuit. Update the metrics to /* About to close an established rendezvous circuit. Update the metrics to
* reflect how many we have at the moment. */ * reflect how many we have at the moment. */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment