MINOR: trace: Add the checks as a possible trace source

To be able to add the trace support for the checks, a new kind of source
must be added for this purpose.
This commit is contained in:
Christopher Faulet 2021-04-12 11:53:16 +02:00
parent 7b1425a91b
commit 6d80b63e3c
2 changed files with 26 additions and 0 deletions

View File

@ -42,31 +42,37 @@
#define TRC_ARG_CONN (1 << 0)
#define TRC_ARG_SESS (1 << 1)
#define TRC_ARG_STRM (1 << 2)
#define TRC_ARG_CHK (1 << 3)
#define TRC_ARG1_PRIV (TRC_ARG_PRIV << 0)
#define TRC_ARG1_CONN (TRC_ARG_CONN << 0)
#define TRC_ARG1_SESS (TRC_ARG_SESS << 0)
#define TRC_ARG1_STRM (TRC_ARG_STRM << 0)
#define TRC_ARG1_CHK (TRC_ARG_CHK << 0)
#define TRC_ARG2_PRIV (TRC_ARG_PRIV << 8)
#define TRC_ARG2_CONN (TRC_ARG_CONN << 8)
#define TRC_ARG2_SESS (TRC_ARG_SESS << 8)
#define TRC_ARG2_STRM (TRC_ARG_STRM << 8)
#define TRC_ARG2_CHK (TRC_ARG_CHK << 8)
#define TRC_ARG3_PRIV (TRC_ARG_PRIV << 16)
#define TRC_ARG3_CONN (TRC_ARG_CONN << 16)
#define TRC_ARG3_SESS (TRC_ARG_SESS << 16)
#define TRC_ARG3_STRM (TRC_ARG_STRM << 16)
#define TRC_ARG3_CHK (TRC_ARG_CHK << 16)
#define TRC_ARG4_PRIV (TRC_ARG_PRIV << 24)
#define TRC_ARG4_CONN (TRC_ARG_CONN << 24)
#define TRC_ARG4_SESS (TRC_ARG_SESS << 24)
#define TRC_ARG4_STRM (TRC_ARG_STRM << 24)
#define TRC_ARG4_CHK (TRC_ARG_CHK << 24)
/* usable to detect the presence of any arg of the desired type */
#define TRC_ARGS_CONN (TRC_ARG_CONN * 0x01010101U)
#define TRC_ARGS_SESS (TRC_ARG_SESS * 0x01010101U)
#define TRC_ARGS_STRM (TRC_ARG_STRM * 0x01010101U)
#define TRC_ARGS_CHK (TRC_ARG_CHK * 0x01010101U)
enum trace_state {
@ -97,6 +103,7 @@ enum trace_lockon {
TRACE_LOCKON_CONNECTION, // lock on the connection that started the trace
TRACE_LOCKON_SESSION, // lock on the session that started the trace
TRACE_LOCKON_STREAM, // lock on the stream that started the trace
TRACE_LOCKON_CHECK, // lock on the check that started the trace
TRACE_LOCKON_ARG1, // lock on arg1, totally source-dependent
TRACE_LOCKON_ARG2, // lock on arg2, totally source-dependent
TRACE_LOCKON_ARG3, // lock on arg3, totally source-dependent

View File

@ -85,6 +85,7 @@ void __trace(enum trace_level level, uint64_t mask, struct trace_source *src,
const struct session *sess = NULL;
const struct stream *strm = NULL;
const struct connection *conn = NULL;
const struct check *check = NULL;
const void *lockon_ptr = NULL;
struct ist ist_func = ist(func);
char tnum[4];
@ -108,10 +109,15 @@ void __trace(enum trace_level level, uint64_t mask, struct trace_source *src,
if (src->arg_def & TRC_ARGS_STRM)
strm = trace_pick_arg(src->arg_def & TRC_ARGS_STRM, a1, a2, a3, a4);
if (src->arg_def & TRC_ARGS_CHK)
check = trace_pick_arg(src->arg_def & TRC_ARGS_CHK, a1, a2, a3, a4);
if (!sess && strm)
sess = strm->sess;
else if (!sess && conn)
sess = conn->owner;
else if (!sess && check)
sess = check->sess;
if (sess) {
fe = sess->fe;
@ -128,6 +134,10 @@ void __trace(enum trace_level level, uint64_t mask, struct trace_source *src,
be = strm->be;
srv = strm->srv_conn;
}
if (check) {
srv = check->server;
be = srv->proxy;
}
if (!srv && conn)
srv = objt_server(conn->target);
@ -159,6 +169,7 @@ void __trace(enum trace_level level, uint64_t mask, struct trace_source *src,
case TRACE_LOCKON_SERVER: lockon_ptr = srv; break;
case TRACE_LOCKON_SESSION: lockon_ptr = sess; break;
case TRACE_LOCKON_STREAM: lockon_ptr = strm; break;
case TRACE_LOCKON_CHECK: lockon_ptr = check; break;
case TRACE_LOCKON_THREAD: lockon_ptr = ti; break;
case TRACE_LOCKON_ARG1: lockon_ptr = a1; break;
case TRACE_LOCKON_ARG2: lockon_ptr = a2; break;
@ -447,6 +458,10 @@ static int cli_parse_trace(char **args, char *payload, struct appctx *appctx, vo
chunk_appendf(&trash, " %c backend : lock on the backend that started the trace\n",
src->lockon == TRACE_LOCKON_BACKEND ? '*' : ' ');
if (src->arg_def & TRC_ARGS_CHK)
chunk_appendf(&trash, " %c check : lock on the check that started the trace\n",
src->lockon == TRACE_LOCKON_CHECK ? '*' : ' ');
if (src->arg_def & TRC_ARGS_CONN)
chunk_appendf(&trash, " %c connection : lock on the connection that started the trace\n",
src->lockon == TRACE_LOCKON_CONNECTION ? '*' : ' ');
@ -504,6 +519,10 @@ static int cli_parse_trace(char **args, char *payload, struct appctx *appctx, vo
HA_ATOMIC_STORE(&src->lockon, TRACE_LOCKON_BACKEND);
HA_ATOMIC_STORE(&src->lockon_ptr, NULL);
}
else if ((src->arg_def & TRC_ARGS_CHK) && strcmp(name, "check") == 0) {
HA_ATOMIC_STORE(&src->lockon, TRACE_LOCKON_CHECK);
HA_ATOMIC_STORE(&src->lockon_ptr, NULL);
}
else if ((src->arg_def & TRC_ARGS_CONN) && strcmp(name, "connection") == 0) {
HA_ATOMIC_STORE(&src->lockon, TRACE_LOCKON_CONNECTION);
HA_ATOMIC_STORE(&src->lockon_ptr, NULL);