From 9fa7af39950e1cc30374739141b37628be86f1d0 Mon Sep 17 00:00:00 2001 From: Mo Chen Date: Fri, 26 Jun 2026 16:12:33 -0500 Subject: [PATCH] rate_limit: don't update metrics when a selector has no `metrics:` block A selector configured without a `metrics:` block should be a metrics no-op. It isn't: _metrics is value-initialized to 0, but incrementMetric() only suppresses the update when an entry equals the TS_ERROR (-1) sentinel that metric_helper() uses for "not registered". So the guard never fires and every queue/reject/expire/resume calls TSStatIntIncrement() on an unregistered ID. (It currently lands on the reserved bad_id slot, so it is absorbed rather than fatal -- but the plugin still should not emit anything.) Default _metrics to TS_ERROR in the constructor so incrementMetric() stays a no-op until metrics are actually registered. Co-Authored-By: Claude Opus 4.8 (1M context) --- plugins/experimental/rate_limit/limiter.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/experimental/rate_limit/limiter.h b/plugins/experimental/rate_limit/limiter.h index 2e40d5e140b..6696274fafc 100644 --- a/plugins/experimental/rate_limit/limiter.h +++ b/plugins/experimental/rate_limit/limiter.h @@ -180,7 +180,7 @@ template class RateLimiter using self_type = RateLimiter; public: - RateLimiter() = default; + RateLimiter() { _metrics.fill(TS_ERROR); } RateLimiter(self_type &&) = delete; self_type &operator=(const self_type &) = delete; self_type &operator=(self_type &&) = delete;