From: Willy Tarreau Date: Tue, 6 Aug 2024 16:09:18 +0000 (+0200) Subject: MINOR: trace: add a per-source helper to pre-fill the context X-Git-Tag: v3.1-dev5~19 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=10c8baca4481d41831cd012e587f91f61058caf7;p=thirdparty%2Fhaproxy.git MINOR: trace: add a per-source helper to pre-fill the context Now sources which want to do it can provide a helper that can pre-fill some fields in the context based on their knowledge (e.g. mux streams). --- diff --git a/include/haproxy/trace-t.h b/include/haproxy/trace-t.h index 0c9452cc21..73bec5b899 100644 --- a/include/haproxy/trace-t.h +++ b/include/haproxy/trace-t.h @@ -166,6 +166,8 @@ struct trace_source { const struct trace_source *src, const struct ist where, const struct ist func, const void *a1, const void *a2, const void *a3, const void *a4); + void (*fill_ctx)(struct trace_ctx *ctx, const struct trace_source *src, + const void *a1, const void *a2, const void *a3, const void *a4); uint32_t arg_def; // argument definitions (sum of TRC_ARG{1..4}_*) const struct name_desc *lockon_args; // must be 4 entries if not NULL const struct name_desc *decoding; // null-terminated if not NULL diff --git a/src/trace.c b/src/trace.c index f4f9fa0b58..852397ac7f 100644 --- a/src/trace.c +++ b/src/trace.c @@ -123,6 +123,9 @@ int __trace_enabled(enum trace_level level, uint64_t mask, struct trace_source * if (src->arg_def & TRC_ARGS_APPCTX) ctx.appctx = trace_pick_arg(src->arg_def & TRC_ARGS_APPCTX, a1, a2, a3, a4); + if (src->fill_ctx) + src->fill_ctx(&ctx, src, a1, a2, a3, a4); + #ifdef USE_QUIC if (ctx.qc && !ctx.conn) ctx.conn = ctx.qc->conn;