mirror of
https://github.com/haproxy/haproxy.git
synced 2026-04-22 23:02:34 -04:00
MINOR: stream: add a sample fetch to get the number of connection retries
"txn.conn_retries" can now be used to get the number of connection retries. This value is only stable once the connection is fully established. For HTTP sessions, L7-retries must also be passed.
This commit is contained in:
parent
8f56552862
commit
b1eb3bc9a2
2 changed files with 21 additions and 0 deletions
|
|
@ -20103,6 +20103,12 @@ thread : integer
|
|||
the function, between 0 and (global.nbthread-1). This is useful for logging
|
||||
and debugging purposes.
|
||||
|
||||
txn.conn_retries : integer
|
||||
Returns the the number of connection retries experienced by this session when
|
||||
trying to connect to the server. This value is subject to change while the
|
||||
connection is not fully established. For HTTP connections, the value may be
|
||||
affected by L7 retries.
|
||||
|
||||
txn.sess_term_state : string
|
||||
Retruns the TCP or HTTP session termination state, as reported in the log. It
|
||||
is a 2-characters string, The final session state followed by the event which
|
||||
|
|
@ -24040,6 +24046,7 @@ Please refer to the table below for currently defined variables :
|
|||
| H | %r | http_request | string |
|
||||
+---+------+------------------------------------------------------+---------+
|
||||
| | %rc | retries | numeric |
|
||||
| | | %[txn.conn_retries] | |
|
||||
+---+------+------------------------------------------------------+---------+
|
||||
| | %rt | request_counter (HTTP req or TCP session) | numeric |
|
||||
+---+------+------------------------------------------------------+---------+
|
||||
|
|
|
|||
14
src/stream.c
14
src/stream.c
|
|
@ -3989,6 +3989,19 @@ static int smp_fetch_sess_term_state(const struct arg *args, struct sample *smp,
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int smp_fetch_conn_retries(const struct arg *args, struct sample *smp, const char *km, void *private)
|
||||
{
|
||||
smp->flags = SMP_F_VOL_TXN;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
if (!smp->strm)
|
||||
return 0;
|
||||
|
||||
if (!sc_state_in(smp->strm->scb->state, SC_SB_DIS|SC_SB_CLO))
|
||||
smp->flags |= SMP_F_VOL_TEST;
|
||||
smp->data.u.sint = smp->strm->conn_retries;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Note: must not be declared <const> as its list will be overwritten.
|
||||
* Please take care of keeping this list alphabetically sorted.
|
||||
*/
|
||||
|
|
@ -3998,6 +4011,7 @@ static struct sample_fetch_kw_list smp_kws = {ILH, {
|
|||
{ "cur_tunnel_timeout", smp_fetch_cur_tunnel_timeout, 0, NULL, SMP_T_SINT, SMP_USE_BKEND, },
|
||||
{ "last_rule_file", smp_fetch_last_rule_file, 0, NULL, SMP_T_STR, SMP_USE_INTRN, },
|
||||
{ "last_rule_line", smp_fetch_last_rule_line, 0, NULL, SMP_T_SINT, SMP_USE_INTRN, },
|
||||
{ "txn.conn_retries", smp_fetch_conn_retries, 0, NULL, SMP_T_SINT, SMP_USE_L4SRV, },
|
||||
{ "txn.sess_term_state",smp_fetch_sess_term_state, 0, NULL, SMP_T_STR, SMP_USE_INTRN, },
|
||||
{ NULL, NULL, 0, 0, 0 },
|
||||
}};
|
||||
|
|
|
|||
Loading…
Reference in a new issue