]> git.kaiwu.me - haproxy.git/commit
BUG/MINOR: sample: adjust dependencies for channel output bytes counters
authorWilly Tarreau <w@1wt.eu>
Mon, 20 Apr 2026 15:40:25 +0000 (17:40 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 21 Apr 2026 06:01:07 +0000 (08:01 +0200)
commit9141d87830700085ca2e8ea3fdc340350a9a870d
tree877d8ba5bbb683e9aa3a61c4a84b7d3fad6f647b
parent6df10d080275f855717f6b8ed275d97a2a7c134b
BUG/MINOR: sample: adjust dependencies for channel output bytes counters

The bytes_in, bytes_out, {req,res}.bytes_{in,out} sample fetch functions
are marked as internal dependencies only. But that's not exact, they are
statistics. Request traffic (bytes_in, req.bytes*) is usable starting
from the request, while response traffic (bytes_out, res.bytes*) is usable
as soon as a response begins to be received, and all are valid till the
end of the transaction.

The impact is that the log-format below:

  log-format "req.bytes_in=%[req.bytes_in] req.bytes_out=%[req.bytes_out] res.bytes_in=%[res.bytes_in] res.bytes_out=%[res.bytes_out]"

is emitted too early and only logs zeroes when uploading 1MB and
downloading 1MB:

  req.bytes_in=0 req.bytes_out=0 res.bytes_in=15288 res.bytes_out=0

This patch marks the request stats RQFIN and the response stats RSFIN,
so that they're valid at any moment and the logs backend knows it must
wait for the latest moment to emit such a line. With this change, the
line above now correctly produces:

  req.bytes_in=1000157 req.bytes_out=1000157 res.bytes_in=1048629 res.bytes_out=1048629

This should be backported as far as the latest LTS probably, along with
these 2 previous patches:

  BUG/MINOR: log: consider format expression dependencies to decide when to log
  MINOR: sample: make RQ/RS stats available everywhere
src/sample.c