Browse Source

HPCC-25601 - Review use of default parameters in metric methods

Removed use of default parameters in favor of explicitly providing values

Signed-off-by: Ken Rowland kenneth.rowland@lexisnexisrisk.com
Ken Rowland 3 years ago
parent
commit
ad077d823b

+ 5 - 4
devdoc/Metrics.rst

@@ -346,13 +346,14 @@ The following convention defines how metric names are formed:
 
 * Names consist of parts separated by a period (.)
 * Each part shall use snake case (allows for compound names in each part)
-* Names for metric types shall be named as follows:
+* Each name shall begin with a prefix representing the scop of the metric
+* Names for metric types shall be named as follows (followed by examples):
 
-  Gauges: <plural-noun>.<state>   requests.waiting, status_requests.waiting
+  Gauges: <scope>.<plural-noun>.<state>   esp.requests.waiting, esp.status_requests.waiting
 
-  Counters:  <plural-noun>.<past-tense-verb>   requests.failed, gateway_requests.queued
+  Counters:  <scope>.<plural-noun>.<past-tense-verb>   thor.requests.failed, esp.gateway_requests.queued
 
-  Time:    <singular-noun>.<state or active-verb>.time  request.blocked.time, request.process.time
+  Time:    <scope>.<singular-noun>.<state or active-verb>.time  dali.request.blocked.time, dali.request.process.time
 
 Meta Data
 =========

+ 2 - 2
system/jlib/jmetrics.hpp

@@ -151,12 +151,12 @@ class jlib_decl CounterMetric : public MetricVal
 public:
     CounterMetric(const char *name, const char *description, StatisticMeasure _units, const MetricMetaData &_metaData = MetricMetaData()) :
         MetricVal{name, description, MetricType::METRICS_COUNTER, _units, _metaData}  { }
-    void inc(uint64_t val = 1)
+    void inc(uint64_t val)
     {
         value.fetch_add(val);
     }
 
-    void fastInc(uint16_t val = 1)
+    void fastInc(uint16_t val)
     {
         value.fastAdd(val);
     }

+ 1 - 1
testing/unittests/metrics/MetricFrameworkTests.cpp

@@ -87,7 +87,7 @@ protected:
 
         //
         // Test default increment (by 1)
-        pCounter->inc();
+        pCounter->inc(1);
         expectedValue++;
         int counterValue = pCounter->queryValue();
         CPPUNIT_ASSERT_EQUAL(expectedValue, counterValue);