sinhaparth5 opened a new issue, #13599:
URL: https://github.com/apache/trafficserver/issues/13599

   `RateLimiter::initializeMetrics()` takes the tag before the prefix:
   
   ```cpp
   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`):
   
   ```cpp
   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
   
   ```yaml
   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 (a2011c2fc), dating to #10559. No autest covers the metric
   names, which is why it has gone unnoticed.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to