feat: mtls handshake metrics + yoq cert service cli - #443
Merged
Conversation
four counters, one per side+outcome combo:
yoq_service_mtls_handshakes_total{side="client",outcome="ok"}
yoq_service_mtls_handshakes_total{side="client",outcome="failed"}
yoq_service_mtls_handshakes_total{side="server",outcome="ok"}
yoq_service_mtls_handshakes_total{side="server",outcome="failed"}
the client side bumps on every doHandshake (mtls always — the client
only runs when ca_cert_pem is set). the server side bumps only when
MtlsOpts was passed, keeping non-mtls TLS termination out of these
counters. tracked in a small mutex-protected fixed-size bucket array
to keep contention bounded.
reads the raft-replicated row from the certificates table (where the cert_issuer in #434 writes mtls leafs) and prints subject, identity URI, issued/expires timestamps, and a human-friendly remaining-hours status. --json variant via the shared JsonWriter for tooling. useful for debugging issuance / rotation without sqlite access.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
summary
fourth PR-5 chunk (after #440, #441, #442). lands the two reviewer-
friendly extras that don't depend on the L7 data-plane refactor:
yoq_service_mtls_handshakes_total{side, outcome}counter surfacedin
/metricsyoq cert service <name>cli — read-only inspector for theraft-replicated leaf cert
both immediately useful even before the proxy switches to mtls for
outbound traffic.
what's in here
tls/mtls_metrics.zig— four-bucket mutex-protected counter(client/server × ok/failed) plus tests
client_session.doHandshakebumps the client side (always; theclient only runs when ca_cert_pem is set in the caller's options)
session_runtime.acceptServerHandshakebumps the server side onlywhen
MtlsOptswas passed — keeps the existing plain-TLStermination path out of the counter
metrics_routes.zigemits the four bucket lines next to theexisting
yoq_service_mtls_*family from feat: per-service mtls leaf issuance + rotation (shadow) #434tls/cli/service_cert_command.zig+commands.zigwiring +usage-string update. text and
--jsonoutput paths.what isn't in this PR (and why)
the L7 reverse proxy's outbound mTLS swap — i.e. teaching
forwardSingleAttemptto consumeclient_dial.Outcome.sessioninsteadof a raw fd — is the one PR-5 piece intentionally split out. doing it
cleanly requires:
peer_modetoServiceSnapshot/Upstream(cross-cutting)and sequence counters — can't be pooled as bare fds)
forwardSingleAttempt's read/write/pool/discard paths tomatch on the union
that's its own design pass + load-bearing review. landing it here
would either be unsafe (sharing pools across encryption states) or
hidden inside a 1500-LOC PR. the helper from #442 (
client_dial.dial)is the clean target it will consume; the metrics counters in this PR
will start producing real data the moment it lands.
verification
mtls_metricsround-trip tested (4-way bucket increments)metric hooks didn't disturb the handshake
still no auto-merge — security-sensitive instrumentation.