feat: add OTEL metrics and tracing to cert_webhook plugin#6
Merged
Conversation
This comment has been minimized.
This comment has been minimized.
Kody Review CompleteGreat news! 🎉 Keep up the excellent work! 🚀 Kody Guide: Usage and ConfigurationInteracting with Kody
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
Metrics: 4 Prometheus counters (webhook_deliveries, cert_events, throttled,
tls_get_cert) registered via Caddy's metrics registry (ctx.GetMetricsRegistry).
Caddy bridges these to OTLP when metrics { otlp } is enabled in the Caddyfile.
Tracing: spans on Handle, handleCertEvent, handleTLSGetCertificateEvent, and
deliverAsync using otel.Tracer(), which Caddy's tracing directive configures
via the global tracer provider.
Record functions at all decision points: event processed, throttled, webhook
success/failure, tls_get_cert. initMetrics/initTracer called in Provision.
97ebc6e to
ad57aa4
Compare
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.
Changes
Adds OpenTelemetry metrics and distributed tracing to the cert_webhook Caddy plugin.
Metrics (4 counters)
cert_webhook_deliveries_total- webhook delivery success/failure (labels: domain, status, result)cert_webhook_cert_events_total- cert events processed (labels: event_type, domain)cert_webhook_throttled_total- events throttled by dedup (labels: domain, source)cert_webhook_tls_get_cert_total- tls_get_certificate events (labels: domain, status)Tracing
Handle,handleCertEvent,handleTLSGetCertificateEvent,deliverAsynccodes.ErrorviaendSpanWithErrorWiring
initMetrics()andinitTracer()called inProvision()alongside existing setupmock.Anythingfor context args (span-wrapped contexts no longer matchcontext.Background()exactly)OTEL env vars
Set via standard OTEL environment variables on the Caddy container. No code changes needed.
Test results
43 tests pass, clean build.
Pull Request Description
This PR adds OpenTelemetry (OTEL) metrics and tracing to the
cert_webhookCaddy plugin, providing observability into webhook delivery, certificate event processing, throttling, and TLS certificate request handling.Metrics Added
Four new counters are registered under the
cert_webhookmeter:cert_webhook_deliveries_total— Tracks webhook delivery attempts to the portal API, with attributes for domain, SSL status, and result (success/failure).cert_webhook_cert_events_total— Tracks processed certificate events (obtained, renewed, expired), with attributes for event type and domain.cert_webhook_throttled_total— Tracks events suppressed by the throttle/dedup mechanism, with attributes for domain and source (cert_eventortls_get_cert).cert_webhook_tls_get_cert_total— Trackstls_get_certificateevents processed, with attributes for domain and SSL status.Tracing Added
Spans are created for the following operations, with relevant attributes (domain, status, event type) and error recording on failure:
cert_webhook.handle_event)cert_webhook.handle_cert_event)cert_webhook.handle_tls_get_cert)cert_webhook.deliver_webhook)Integration Changes
handler.go. Metric initialization failures are logged as warnings without blocking startup.Handle→handleCertEvent/handleTLSGetCertificateEvent) to support distributed tracing.delivery.gonow uses the traced context for the API call and records success/failure metrics.context.Background()to modified method signatures and to usemock.Anythingfor context arguments in mock expectations.