MINOR: stream: Expose the stream's uniq_id via a new sample fetch

"txn.id32" may now be used to get the stream's uniq_id. It is equivalent to
%rt in logs.
This commit is contained in:
Christopher Faulet 2023-11-28 21:01:18 +01:00
parent b1eb3bc9a2
commit 0b8e7d666e
2 changed files with 18 additions and 0 deletions

View File

@ -20103,6 +20103,12 @@ thread : integer
the function, between 0 and (global.nbthread-1). This is useful for logging
and debugging purposes.
txn.id32 : integer
Returns the internal transaction ID. It is a 32bits integer. So, in absolute,
its value is not unique, transaction IDs may wrap. The wrapping period
depends on the request rate. In practice, it should not be an issue. For a
true unique ID, see "unique-id-format" directive.
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
@ -24049,6 +24055,7 @@ Please refer to the table below for currently defined variables :
| | | %[txn.conn_retries] | |
+---+------+------------------------------------------------------+---------+
| | %rt | request_counter (HTTP req or TCP session) | numeric |
| | | %[txn.id32] | |
+---+------+------------------------------------------------------+---------+
| | %s | server_name | string |
+---+------+------------------------------------------------------+---------+

View File

@ -4002,6 +4002,16 @@ static int smp_fetch_conn_retries(const struct arg *args, struct sample *smp, co
return 1;
}
static int smp_fetch_id32(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;
smp->data.u.sint = smp->strm->uniq_id;
return 1;
}
/* Note: must not be declared <const> as its list will be overwritten.
* Please take care of keeping this list alphabetically sorted.
*/
@ -4012,6 +4022,7 @@ static struct sample_fetch_kw_list smp_kws = {ILH, {
{ "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.id32", smp_fetch_id32, 0, NULL, SMP_T_SINT, SMP_USE_INTRN, },
{ "txn.sess_term_state",smp_fetch_sess_term_state, 0, NULL, SMP_T_STR, SMP_USE_INTRN, },
{ NULL, NULL, 0, 0, 0 },
}};