Repository navigation
caddytls: add certificate operation and on-demand ask metrics - #8186
Open
IslamElsayed wants to merge 2 commits into
Open
IslamElsayed wants to merge 2 commits into
IslamElsayed wants to merge 2 commits into
Conversation
Adds two counters to the tls app, for caddyserver#1683: caddy_tls_certificate_operations_total{operation, issuer, result, error_type} caddy_tls_on_demand_ask_total{result} operation is obtain or renew, result is success or failure, and error_type categorizes a failure by its ACME problem type as challenge_failed, rate_limited or other. issuer is the configured issuer's key; on a failure it is the last issuer tried, whose error is the one returned. The ask counter records allowed, denied or error for every call to the on-demand permission module. No certificate name, SAN, account or ask URL is used as a label, since with on-demand TLS those are chosen by clients. The counters are fed by the cert_obtained and cert_failed events CertMagic emits through onEvent, and are counted before the events app decides whether anything observes them. The tls app also reports these events as wanted through ShouldEmitFunc, so the metrics keep working even if CertMagic starts gating them. The collectors are created once per process and registered unconditionally with each config's registry.
steadytao
requested changes
Oct 9, 2026
Exercise TLS.onEvent and the on-demand permission callback built by makeCertMagicConfig, and assert the counter deltas, instead of calling the observers directly.
steadytao
approved these changes
Oct 10, 2026
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.
Part of #1683: the two counters from the agreed contract. The expiry gauge follows once the CertMagic method it needs is released (caddyserver/certmagic#413).
operationisobtainorrenew, andresultissuccessorfailure. On failure,error_typecomes from the ACME problem type:rate_limited,challenge_failed(connection, dns, unauthorized, incorrectResponse, tls, caa) orother.issueris the configured issuer's key. On a failure it's the last issuer tried, whose error is the one returned.allowed,deniedorerrorfor every call to the on-demand permission module.The counters are fed by the
cert_obtainedandcert_failedevents throughonEvent, and are counted before the events app'sEmitdecides whether anything observes them. OnShouldEmit: CertMagic currently consultsShouldEmitFunconly fortls_get_certificate, so these events already reachonEventeither way. The tls app now reports them as wanted anyway, so the metrics keep working if CertMagic starts gating them.Tested with unit tests, and with a caddy binary at INFO log level:
local_certs:{operation="obtain",issuer="local",result="success"} 1{operation="obtain",issuer="127.0.0.1:1-directory",result="failure",error_type="other"} 1askendpoint: oneallowedand onedenied(I used AI assistance, Claude, while preparing this; I reviewed and tested it myself.)