RateLimiter::initializeMetrics() takes the tag before the prefix:
void initializeMetrics(uint type, std::string tag, std::string prefix = RATE_LIMITER_METRIC_PREFIX)
The remap path passes them in that order (txn_limiter.cc:182). The YAML path
does not (limiter.h:228):
std::string prefix = metrics["prefix"] ? metrics["prefix"].as<std::string>() : RATE_LIMITER_METRIC_PREFIX;
std::string tag = metrics["tag"] ? metrics["tag"].as<std::string>() : name();
initializeMetrics(RATE_LIMITER_TYPE_SNI, prefix, tag);
metric_helper() builds the name as prefix + "." + type + "." + tag
(limiter.cc:60-74), so the two halves come out reversed. Every SNI limiter
configured with a metrics node gets the wrong metric name, including when
only one of the two keys is set, because the defaults get swapped along with
them.
Reproduce
selector:
- sni: example.com
limit: 100
metrics:
prefix: myprefix
tag: mytag
traffic_ctl metric match rate reports:
mytag.sni.myprefix.queued
instead of myprefix.sni.mytag.queued.
With only tag: mytag set, the name is mytag.sni.plugin.rate_limiter.queued
rather than plugin.rate_limiter.sni.mytag.queued. With only
prefix: myprefix set it is example.com.sni.myprefix.queued rather than
myprefix.sni.example.com.queued.
Present on master (a2011c2), dating to #10559. No autest covers the metric
names, which is why it has gone unnoticed.
RateLimiter::initializeMetrics()takes the tag before the prefix:The remap path passes them in that order (
txn_limiter.cc:182). The YAML pathdoes not (
limiter.h:228):metric_helper()builds the name asprefix + "." + type + "." + tag(
limiter.cc:60-74), so the two halves come out reversed. Every SNI limiterconfigured with a
metricsnode gets the wrong metric name, including whenonly one of the two keys is set, because the defaults get swapped along with
them.
Reproduce
traffic_ctl metric match ratereports:instead of
myprefix.sni.mytag.queued.With only
tag: mytagset, the name ismytag.sni.plugin.rate_limiter.queuedrather than
plugin.rate_limiter.sni.mytag.queued. With onlyprefix: myprefixset it isexample.com.sni.myprefix.queuedrather thanmyprefix.sni.example.com.queued.Present on master (a2011c2), dating to #10559. No autest covers the metric
names, which is why it has gone unnoticed.