Repository navigation
Description
Hello there 👋,
After some discussions with @StevenLeRoux, @BlackYoup and @Wonshtrum.
We found out that Sōzu need to provides a little more information about request and response.
So, I use this issue to make a summary of what we need.
Firstly, I will remember that we have to tackle the issue #641, #892 and #804.
What we already have
Access logs
Currently, when we handle request (TCP, HTTP[s] or WS[s]) will write following access logs.
01H0FXZVQK7RK3W55X7V26M259 TcpTest TcpTest-0-127.0.0.1:4000 127.0.0.1:52378 -> 127.0.0.1:4000 19ms 168μs 79 68522 owner=John, uuid=3f740af1-45fd-45ce-b61f-17bf1a51505f TCP -
01H0FXX3VTR8T3B1K0ZHXQZZNQ MyCluster the-backend-to-my-app 127.0.0.1:50444 -> 127.0.0.1:1026 61ms 4959μs 79 68535 key=value HTTPS-TLS1.3 lolcatho.st:8443 200 GET /Below, an explanation of the above access logs:
| request id | cluster id | backend id | client socket address -> backend socket address | response time | service time | bytes in | bytes out | metadata | protocol | hostname | status | verb | path |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
01H0FXX3VTR8T3B1K0ZHXQZZNQ |
MyCluster |
the-backend-to-my-app |
127.0.0.1:50444 -> 127.0.0.1:1026 |
61ms |
4959μs |
79 |
68535 |
key=value |
HTTPS-TLS1.3 |
lolcatho.st:8443 |
200 |
GET |
/ |
| request id | cluster id | backend id | client socket address -> backend socket address | response time | service time | bytes in | bytes out | metadata | protocol | websocket context |
|---|---|---|---|---|---|---|---|---|---|---|
01H0FXZVQK7RK3W55X7V26M259 |
TcpTest |
TcpTest-0-127.0.0.1:4000 |
127.0.0.1:52378 -> 127.0.0.1:4000 |
19ms |
168μs |
79 |
68522 |
owner=John, uuid=3f740af1-45fd-45ce-b61f-17bf1a51505f |
TCP |
- |
response time: the total duration of the request
service time: the total duration that Sozu took to treat the request
websocket context: the value is-if the protocol isTCP
You can find the code source that output those logs here:
TCP or WS
Lines 275 to 287 in 3aea15c
| info_access!( | |
| "{}{} -> {}\t{} {} {} {}\t{}\t{} {}", | |
| self.log_ctx, | |
| session_addr, | |
| backend, | |
| LogDuration(response_time), | |
| LogDuration(service_time), | |
| metrics.bin, | |
| metrics.bout, | |
| OptionalString::from(tags.as_ref()), | |
| proto, | |
| self.websocket_context.as_deref().unwrap_or("-") | |
| ); |
Lines 328 to 340 in 3aea15c
| error_access!( | |
| "{}{} -> {}\t{} {} {} {}\t{} {} | {}", | |
| self.log_ctx, | |
| session, | |
| backend, | |
| LogDuration(response_time), | |
| LogDuration(service_time), | |
| metrics.bin, | |
| metrics.bout, | |
| proto, | |
| self.websocket_context.as_deref().unwrap_or("-"), | |
| message | |
| ); |
HTTP
sozu/lib/src/protocol/http/mod.rs
Lines 614 to 628 in 3aea15c
| info_access!( | |
| "{}{} -> {}\t{} {} {} {}\t{}\t{} {} {}\t{}", | |
| self.log_context(), | |
| session, | |
| backend, | |
| LogDuration(response_time), | |
| LogDuration(service_time), | |
| metrics.bin, | |
| metrics.bout, | |
| OptionalString::from(tags.as_ref()), | |
| proto, | |
| host, | |
| status_line, | |
| request_line | |
| ); |
sozu/lib/src/protocol/http/mod.rs
Lines 682 to 696 in 3aea15c
| info_access!( | |
| "{}{} -> {}\t{} {} {} {}\t{}\t{} {} {}\t{}", | |
| self.log_context(), | |
| session, | |
| backend, | |
| LogDuration(response_time), | |
| LogDuration(service_time), | |
| metrics.bin, | |
| metrics.bout, | |
| OptionalString::from(tags.as_ref()), | |
| proto, | |
| host, | |
| status_line, | |
| request_line | |
| ); |
sozu/lib/src/protocol/http/mod.rs
Lines 758 to 773 in 3aea15c
| error_access!( | |
| "{}{} -> {}\t{} {} {} {}\t{} {} {}\t{} | {} {}", | |
| self.log_context(), | |
| session, | |
| backend, | |
| LogDuration(response_time), | |
| LogDuration(service_time), | |
| metrics.bin, | |
| metrics.bout, | |
| proto, | |
| host, | |
| request_line, | |
| status_line, | |
| message, | |
| OptionalString::from(tags.as_ref()) | |
| ); |
Metrics
Today, we have a bunch of metrics and we do not use all of them.
We should investigate.
To do so, we have to:
- make a proper list of metrics (classname+labels+kind+description).
- Then, establish the cardinality of each one and segregate them in two parts:
- The one that are Sōzu-related (event loop, worker, etc..)
- The one that are cluster-related (status code, response time, service time, cluster response time, data transfer, etc..)
- The cluster-related have to be labeled with the cluster identifier and optionaly the backend identifier.
What is missing
Access logs
To us, it miss some informations in access logs as :
- client rtt: the time in millisecond to establish a connection between the client and Sōzu
- server rtt: the time in millisecond to establish a connection between Sōzu and the backend
- cluster response time: the time in millisecond between the end of the transfer of the request body and the response header betweend Sōzu and the backend
- data transfer time: the total duration in millisecond of transfering data between the client to the backend and vice-versa
- user-agent
Metrics
We should investigate first the item above.
Registry:
- Reference around logs: https://www.haproxy.com/blog/introduction-to-haproxy-logging/
- TCP log format: https://www.haproxy.com/documentation/hapee/1-8r1/onepage/#8.2.2
- HTTP log format: https://www.haproxy.com/documentation/hapee/1-8r1/onepage/#8.2.3
- What is round trip time: https://www.cloudflare.com/learning/cdn/glossary/round-trip-time-rtt/
Update — 2026-04-24
Partial progress on feat/h2-mux (PR #1209). The original umbrella is broad; the items below are shipped on this branch, with the remainder still outstanding.
Access logs (request-scoped)
c9ec90cf feat(http): propagate x-request-id and log it on access log— Sōzu now preserves an inboundx-request-idheader or injects one from the request ULID, forwards it to the backend, and records it in thex_request_idaccess-log field (ProtobufAccessLogtag 24). Counters:http.x_request_id.propagatedandhttp.x_request_id.generated.29c3f834 feat(logging): surface TLS metadata and XFF chain on access logs— five additional access-log fields (ProtobufAccessLogtags 25–29) carry negotiated TLS metadata (version, cipher, SNI, ALPN) and the upstream-attestedX-Forwarded-Forchain, populated end-to-end on H1 and H2.db7c33ec feat(h2): propagate OTel trace context from H2 headers to access logs—traceparentpassthrough (W3C Trace Context) records trace identifiers in access logs when theopentelemetryfeature is enabled (propagator only, no SDK or exporter).- Correlation header name is now configurable per listener (
f76c5d5b feat(listener): configurable Sozu-Id correlation header name) — see also make Sozu-Id header field name configurable #1145.
Metrics correctness and documentation
deeba79c fix(metrics): restore missing backend metrics in mux layera650ad69 fix(mux): prevent gauge underflow and error counter inflation5f884551 fix(mux): fix service_time inflation, gauge leak, and WebSocket upgr...5a60da82 refactor(metrics): replace mem::uninitialized with MaybeUninit::zeroed868fc227 docs(metrics): comprehensive metrics, OpenTelemetry, and traces referencef0127aa3 docs(configure): document 2 emitted-but-undocumented metrics, fix Op...c0d03425 docs(configure): document h2.signal.writable.rearmed.* and ready_incremental gauge— new H2 scheduler-rearm counters and theh2.streams.ready_incremental.by_urgencygauge are now documented indoc/configure.md.
Severity classification
07a83e92 fix(proxy): harmonise backend retry-budget-exhaustion log severity024390a1 docs(configure): classify TLS handshake log severities440a9ee1 chore(pipe): demote idle-timeout tear-downs from error! to debug!
Audit log (control plane, not request access log — moved out of scope but related)
The refactor(command): audit log series (2200fc2a, 0c2dc869, 53b51e03, 6b21c9c4, e7a5e29d) enriches the command-socket audit log (ucred, actor/role, timestamps, fanout, MUX Session(...) layout) and raises it to info!. This is the operator-action trail, distinct from the request access log above.
Still outstanding
- Client/server RTT, cluster response time, data-transfer time, and user-agent fields in the request access log.
- Metric registry + cardinality classification (the three checkboxes above).
- Per-cluster/per-backend labelling for cluster-scoped metrics.
Keep this issue open; consider splitting the residual work (access-log fields, metric registry) into dedicated child issues once priorities are set.
Activity
Wonshtrum commentedon May 26, 2023
The first draft can be found on the latest commit of #904.
Keksoj commentedon Jun 15, 2023
In the spirit of the request counter of #947, we could keep track of how many access logs were produced. See #950
Keksoj commentedon Jun 16, 2023
Oh and we should do something about this:
Notice that many
.countare actually gauges. This is wrong.feat(metrics): add HTTP status code distribution, per-backend error t…
feat(metrics): add HTTP status code distribution, per-backend error t…
feat(metrics): per-code HTTP status counters across H1 and H2
feat(metrics): event-loop buffer / connection / slab gauges + rename
feat(metrics): per-code HTTP status counters across H1 and H2
feat(metrics): event-loop buffer / connection / slab gauges + rename
FlorentinDUBOIS commentedon May 2, 2026
Status update — 2026-05-02 (HEAD =
main@8c883bb5)PR #1209 (
feat/h2-mux) merged intomainon 2026-04-27, and the access-log + metrics commits referenced in my 2026-04-24 update above are now inmain. The companion metrics-only PR #1196 (feat/metrics-gaps) was closed unmerged on 2026-04-28 because its scope had already been folded into the H2-mux series — its sub-issues #597, #1146 and #641 were closed on 2026-05-02. The original umbrella here can now be narrowed considerably; tracking what's left below.Already shipped on
mainAccess-log fields (
command/src/command.proto:1456+,ProtobufAccessLogtags 9–29):client_rtt(tag 9)kawa_h1/mod.rs:1045mux/stream.rs:289pipe.rs:322tcp.rs:282server_rtt(tag 10)kawa_h1/mod.rs:1046mux/stream.rs:290pipe.rs:323user_agent(tag 16)x_request_id(tag 24)tls_version/cipher/sni/alpn(tags 25–28)xff_chain(tag 29)traceparent(otel feature)Originating commits:
ed1966e1(x-request-id),2e7d9434(TLS+XFF),db7c33ec(OTel propagation),f76c5d5b(configurable correlation header — closes #1145).Metrics:
12be94c0per-status-code HTTP counters across H1+H2 (closed Metrics related to Http status code #1146).36d9cffbevent-loop buffer / connection / slab gauge rename + new gauges (closed add metrics for backend servers #597).13f8f296http.errorscluster + backend label.deeba79crestored mux backend metric parity with H1.a650ad69,5f884551gauge underflow + service-time inflation fixes (closed "metric connections underflow: previous value: 0, adding: -1" #641).868fc227comprehensive metrics reference, 137 metrics catalogued indoc/configure.md.Cluster + backend metric labelling is broader than the original umbrella suggested. The infrastructure (
MetricDetailLevel::{Process,Frontend,Cluster,Backend}atcommand/src/config.rs:1116-1120, filter atlib/src/metrics/mod.rs:43) is in place and is consumed by therecord_backend_metrics!macro atlib/src/metrics/mod.rs:474-490(coversbytes_in,bytes_out,backend_response_time,backend_connection_time,requests), thehttp.errorsandhttp.status.*counters, the default-answer counters inkawa_h1/mod.rs:1104-1165andmux/answers.rs:224-239, plus theconnections_per_backend/backend.up/backend.down/backend.connections.error/backend.connect.retries_exhaustedfamily acrosstcp.rs:559-641,914-943,kawa_h1/mod.rs:1310-1333,1664-1742,mux/router.rs:119-123,479-518,mux/mod.rs:815-819,931-947,1704-1708,mux/connection.rs:380-385.request_time/service_time(lib.rs:1273-1275),frontend_matching_time(http.rs:665-666,https.rs:860-861) andaccess_logs.count(lib.rs:1293) are all cluster-labelled.Outstanding under this umbrella
H2/mux access-log
client_rtt/server_rtt.lib/src/protocol/mux/stream.rs:289-290has the call wired but commented out (f27a449d). MuxStreamhas no directbackend_socketfield; the socket is reachable viaStream::state == StreamState::Linked(token)→Context.backend_streams(mux/mod.rs:342-350,471-486) →Router.backends: HashMap<Token, Connection<SessionTcpStream>>(mux/router.rs:70-72) →Connection::{H1,H2}.socket(mux/connection.rs:54-57,mux/h1.rs:108-115,mux/h2.rs:1251-1269). Deciding between per-stream snapshot and per-connection RTT, and plumbing that intoStream::generate_access_log, is the residual concrete work. This is the single largest visible asymmetry between H1 and H2 access logs today.data_transfer_time. Not in the schema. Current proxy isrequest_time - service_time. Needs a decision: add an explicit field (and a populator that subtracts the two), or document the derivation and leave it out.cluster_response_time. Maps semantically tobackend_response_time, already emitted as a metric and as theresponse_timeaccess-log field (tag 21) populated frommetrics.backend_response_time()atmux/stream.rs:292andkawa_h1/mod.rs:1048. If we want HAProxy-parity wording, that's a doc/alias decision indoc/configure.md, not new instrumentation.Cardinality classification table. The 137-metric reference at
doc/configure.mdlists metrics but doesn't yet present them as the explicit "Sōzu-related vs cluster-related" cardinality table the original issue called for. Doc work, not code.Per-cluster/backend label residual sweep. Most cluster-scoped metrics now carry labels (see infrastructure paragraph above). What remains is an audit pass to identify any cluster-scoped metric still emitted unlabelled. Likely a short list, not a wholesale conversion.
Linked issues — re-checked against
mainlib/src/health_check.rs:461-492logs UP/DOWN transitions and emitshealth_check.up/health_check.down; server wires it atserver.rs:889-890,1448-1457,1547. Retry-policy paths log transitions independently attcp.rs:580-641,kawa_h1/mod.rs:1683-1742,mux/mod.rs:807-819,929-947. Probably closeable — proposing to close as completed once @StevenLeRoux / @BlackYoup confirm the existing log lines satisfy what they need.regex_matching_timeis emitted for domain and path regexes atlib/src/router/mod.rs:580-584,660-664;frontend_matching_timeathttp.rs:665-666andhttps.rs:860-861. Only a dedicatedrouter.lookup_time/ non-regex matching-time metric is missing.Proposed next steps
I'd like to close out this umbrella in two passes:
response_timeto the HAProxycluster_response_timenotion, presents the cardinality table (item 4), and decides ondata_transfer_timeeither way (item 2).Once those land, the residual is just (5) — an audit pass — and the linked issues #892/#804 can be re-scoped to their respective small remnants. Happy to keep this issue open as the meta-tracker until those land, or split off a successor — whichever you prefer.
feat(mux): populate client_rtt and server_rtt on the H2 access log
feat(mux): populate client_rtt and server_rtt on the H2 access log
feat(mux): populate client_rtt and server_rtt on the H2 access log
FlorentinDUBOIS commentedon May 5, 2026
Closing — covered by #1245 (per-cluster availability + access-log timeout discriminator), #1242 (H2 client/server RTT on access log), #1225 (H2 flood/frame/error counters + TLS handshake + access-log enrichment), and #1233 (metrics gaps rewrite). Reopen for a specific gap still open.
feat(metrics): per-code HTTP status counters across H1 and H2
feat(metrics): event-loop buffer / connection / slab gauges + rename
feat(mux): populate client_rtt and server_rtt on the H2 access log