]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: trace: add a per-source helper to pre-fill the context
authorWilly Tarreau <w@1wt.eu>
Tue, 6 Aug 2024 16:09:18 +0000 (18:09 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 7 Aug 2024 14:02:59 +0000 (16:02 +0200)
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).

include/haproxy/trace-t.h
src/trace.c

index 0c9452cc212f7ed6f1e8de9c8d94bbed66922bfd..73bec5b899f0ac2e6ba381223c050aad7470889d 100644 (file)
@@ -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
index f4f9fa0b58d2cd33e0561201ede44896c0b7d4e8..852397ac7fe6f1a16a6f5d279e114cac00a368d3 100644 (file)
@@ -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;