summaryrefslogtreecommitdiffstats
path: root/metrics
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-01-06 23:38:41 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2023-01-06 23:38:41 +0000
commit2f61fa944cfd1e57719c93348ffc35a32a8d2bc8 (patch)
tree677ed560a12f8b3ec4a7c09480ff330ba384d358 /metrics
parent92845e2859655920607519ffe6c81ade2f59566c (diff)
reduce usage of default values.
Diffstat (limited to 'metrics')
-rw-r--r--metrics/src/tests/metrictest.cpp6
-rw-r--r--metrics/src/vespa/metrics/countmetric.h11
-rw-r--r--metrics/src/vespa/metrics/metricmanager.cpp24
-rw-r--r--metrics/src/vespa/metrics/metricmanager.h4
-rw-r--r--metrics/src/vespa/metrics/metricset.cpp3
-rw-r--r--metrics/src/vespa/metrics/metricset.h25
-rw-r--r--metrics/src/vespa/metrics/metricsnapshot.cpp8
-rw-r--r--metrics/src/vespa/metrics/summetric.h6
-rw-r--r--metrics/src/vespa/metrics/valuemetric.h7
9 files changed, 40 insertions, 54 deletions
diff --git a/metrics/src/tests/metrictest.cpp b/metrics/src/tests/metrictest.cpp
index dc86e9ec281..f6f65780aa4 100644
--- a/metrics/src/tests/metrictest.cpp
+++ b/metrics/src/tests/metrictest.cpp
@@ -54,19 +54,19 @@ TEST(MetricTest, mangled_name_lists_dimensions_in_lexicographic_order)
{
LongValueMetric m("test",
{{"xyz", "bar"}, {"abc", "foo"}, {"def", "baz"}},
- "");
+ "", nullptr);
EXPECT_EQ(vespalib::string("test{abc:foo,def:baz,xyz:bar}"), m.getMangledName());
}
TEST(MetricTest, mangling_does_not_change_original_metric_name)
{
- LongValueMetric m("test", {{"foo", "bar"}}, "");
+ LongValueMetric m("test", {{"foo", "bar"}}, "", nullptr);
EXPECT_EQ(vespalib::string("test"), m.getName());
}
TEST(MetricTest, legacy_tags_do_not_create_mangled_name)
{
- LongValueMetric m("test", {{"foo"},{"bar"}}, "");
+ LongValueMetric m("test", {{"foo"},{"bar"}}, "", nullptr);
EXPECT_EQ(vespalib::string("test"), m.getName());
EXPECT_EQ(vespalib::string("test"), m.getMangledName());
}
diff --git a/metrics/src/vespa/metrics/countmetric.h b/metrics/src/vespa/metrics/countmetric.h
index 90ad3a26c8d..5225cd58f12 100644
--- a/metrics/src/vespa/metrics/countmetric.h
+++ b/metrics/src/vespa/metrics/countmetric.h
@@ -29,7 +29,7 @@ struct AbstractCountMetric : public Metric {
protected:
AbstractCountMetric(const String& name, Tags dimensions,
- const String& description, MetricSet* owner = 0)
+ const String& description, MetricSet* owner)
: Metric(name, std::move(dimensions), description, owner)
{ }
@@ -47,9 +47,10 @@ class CountMetric : public AbstractCountMetric
MetricValueSet<Values> _values;
public:
- CountMetric(const String& name, Tags dimensions,
- const String& description, MetricSet* owner = 0);
-
+ CountMetric(const String& name, Tags dimensions, const String& description)
+ : CountMetric(name, std::move(dimensions), description, nullptr)
+ {}
+ CountMetric(const String& name, Tags dimensions, const String& description, MetricSet* owner);
CountMetric(const CountMetric<T, SumOnAdd>& other, MetricSet* owner);
~CountMetric() override;
@@ -69,8 +70,6 @@ public:
CountMetric t(a); t -= b; return t;
}
-
-
CountMetric * clone(std::vector<Metric::UP> &, CopyType, MetricSet* owner, bool) const override {
return new CountMetric<T, SumOnAdd>(*this, owner);
}
diff --git a/metrics/src/vespa/metrics/metricmanager.cpp b/metrics/src/vespa/metrics/metricmanager.cpp
index 2fd09094f4c..ae75968e605 100644
--- a/metrics/src/vespa/metrics/metricmanager.cpp
+++ b/metrics/src/vespa/metrics/metricmanager.cpp
@@ -77,7 +77,7 @@ MetricManager::MetricManager(std::unique_ptr<Timer> timer)
_lastProcessedTime(0),
_snapshotUnsetMetrics(false),
_consumerConfigChanged(false),
- _metricManagerMetrics("metricmanager", {}, "Metrics for the metric manager upkeep tasks"),
+ _metricManagerMetrics("metricmanager", {}, "Metrics for the metric manager upkeep tasks", nullptr),
_periodicHookLatency("periodichooklatency", {}, "Time in ms used to update a single periodic hook", &_metricManagerMetrics),
_snapshotHookLatency("snapshothooklatency", {}, "Time in ms used to update a single snapshot hook", &_metricManagerMetrics),
_resetLatency("resetlatency", {}, "Time in ms used to reset all metrics.", &_metricManagerMetrics),
@@ -383,11 +383,9 @@ MetricManager::handleMetricsAltered(const MetricLockGuard & guard)
configMap[consumer.name] = std::make_shared<ConsumerSpec>(std::move(consumerMetricBuilder._matchedMetrics));
}
LOG(debug, "Recreating snapshots to include altered metrics");
- _totalMetrics->recreateSnapshot(_activeMetrics.getMetrics(),
- _snapshotUnsetMetrics);
+ _totalMetrics->recreateSnapshot(_activeMetrics.getMetrics(), _snapshotUnsetMetrics);
for (uint32_t i=0; i<_snapshots.size(); ++i) {
- _snapshots[i]->recreateSnapshot(_activeMetrics.getMetrics(),
- _snapshotUnsetMetrics);
+ _snapshots[i]->recreateSnapshot(_activeMetrics.getMetrics(), _snapshotUnsetMetrics);
}
LOG(debug, "Setting new consumer config. Clearing dirty flag");
_consumerConfig.swap(configMap);
@@ -395,8 +393,7 @@ MetricManager::handleMetricsAltered(const MetricLockGuard & guard)
}
namespace {
- bool setSnapshotName(std::ostream& out, const char* name,
- uint32_t length, uint32_t period)
+ bool setSnapshotName(std::ostream& out, const char* name, uint32_t length, uint32_t period)
{
if (length % period != 0) return false;
out << (length / period) << ' ' << name;
@@ -412,9 +409,8 @@ MetricManager::createSnapshotPeriods(const Config& config)
try{
for (uint32_t i=0; i<config.snapshot.periods.size(); ++i) {
uint32_t length = config.snapshot.periods[i];
- if (length < 1) throw vespalib::IllegalStateException(
- "Snapshot periods must be positive numbers",
- VESPA_STRLOC);
+ if (length < 1)
+ throw vespalib::IllegalStateException("Snapshot periods must be positive numbers", VESPA_STRLOC);
std::ostringstream name;
if (setSnapshotName(name, "week", length, 60 * 60 * 24 * 7)) {
} else if (setSnapshotName(name, "day", length, 60 * 60 * 24)) {
@@ -483,15 +479,13 @@ MetricManager::configure(const MetricLockGuard & , std::unique_ptr<Config> confi
VESPA_STRLOC);
}
}
- _snapshots.push_back(MetricSnapshotSet::SP(new MetricSnapshotSet(
+ _snapshots.push_back(std::make_shared<MetricSnapshotSet>(
snapshotPeriods[i].second, snapshotPeriods[i].first, count,
- _activeMetrics.getMetrics(), _snapshotUnsetMetrics)));
+ _activeMetrics.getMetrics(), _snapshotUnsetMetrics));
count = nextCount;
}
// Add all time snapshot.
- _totalMetrics = MetricSnapshot::SP(new MetricSnapshot(
- "All time snapshot", 0, _activeMetrics.getMetrics(),
- _snapshotUnsetMetrics));
+ _totalMetrics = std::make_shared<MetricSnapshot>("All time snapshot", 0, _activeMetrics.getMetrics(), _snapshotUnsetMetrics);
_totalMetrics->reset(currentTime);
}
if (_config.get() == 0
diff --git a/metrics/src/vespa/metrics/metricmanager.h b/metrics/src/vespa/metrics/metricmanager.h
index 323e90253b9..5f35c349f7f 100644
--- a/metrics/src/vespa/metrics/metricmanager.h
+++ b/metrics/src/vespa/metrics/metricmanager.h
@@ -104,7 +104,6 @@ private:
std::list<UpdateHook*> _snapshotUpdateHooks;
mutable std::mutex _waiter;
mutable std::condition_variable _cond;
- using PeriodTimePair = std::pair<uint32_t, time_t>;
std::vector<MetricSnapshotSet::SP> _snapshots;
MetricSnapshot::SP _totalMetrics;
std::unique_ptr<Timer> _timer;
@@ -195,8 +194,7 @@ public:
* of consumers. readConfig() will start a config subscription. It should
* not be called multiple times.
*/
- void init(const config::ConfigUri & uri, FastOS_ThreadPool&,
- bool startThread = true);
+ void init(const config::ConfigUri & uri, FastOS_ThreadPool&, bool startThread = true);
/**
* Visit a given snapshot for a given consumer. (Empty consumer name means
diff --git a/metrics/src/vespa/metrics/metricset.cpp b/metrics/src/vespa/metrics/metricset.cpp
index bc04674ead5..f583d2f4716 100644
--- a/metrics/src/vespa/metrics/metricset.cpp
+++ b/metrics/src/vespa/metrics/metricset.cpp
@@ -43,8 +43,7 @@ MetricSet::MetricSet(const MetricSet& other,
MetricSet::~MetricSet() = default;
MetricSet*
-MetricSet::clone(std::vector<Metric::UP> &ownerList, CopyType type,
- MetricSet* owner, bool includeUnused) const
+MetricSet::clone(std::vector<Metric::UP> &ownerList, CopyType type, MetricSet* owner, bool includeUnused) const
{
return new MetricSet(*this, ownerList, type, owner, includeUnused);
}
diff --git a/metrics/src/vespa/metrics/metricset.h b/metrics/src/vespa/metrics/metricset.h
index 9789fe789f4..ca4df1ceb58 100644
--- a/metrics/src/vespa/metrics/metricset.h
+++ b/metrics/src/vespa/metrics/metricset.h
@@ -22,11 +22,15 @@ class MetricSet : public Metric
// it was reset
public:
- MetricSet(const String& name, Tags dimensions,
- const String& description, MetricSet* owner = 0);
-
- MetricSet(const MetricSet&, std::vector<Metric::UP> &ownerList,
- CopyType, MetricSet* owner = 0, bool includeUnused = false);
+ MetricSet(const String& name, Tags dimensions, const String& description) :
+ MetricSet(name, std::move(dimensions), description, nullptr)
+ {}
+ MetricSet(const String& name, Tags dimensions, const String& description, MetricSet* owner);
+ MetricSet(const MetricSet&, std::vector<Metric::UP> &ownerList, CopyType, MetricSet* owner, bool includeUnused);
+ // Do not generate default copy constructor or assignment operator
+ // These would screw up metric registering
+ MetricSet(const MetricSet&) = delete;
+ MetricSet& operator=(const MetricSet&) = delete;
~MetricSet();
// If no path, this metric is not registered within another
@@ -44,8 +48,7 @@ public:
void registerMetric(Metric& m);
void unregisterMetric(Metric& m);
- MetricSet* clone(std::vector<Metric::UP> &ownerList, CopyType type,
- MetricSet* owner, bool includeUnused = false) const override;
+ MetricSet* clone(std::vector<Metric::UP> &ownerList, CopyType type, MetricSet* owner, bool includeUnused) const override;
void reset() override;
@@ -59,8 +62,7 @@ public:
const Metric* getMetric(stringref name) const;
Metric* getMetric(stringref name) {
- return const_cast<Metric*>(
- const_cast<const MetricSet*>(this)->getMetric(name));
+ return const_cast<Metric*>(const_cast<const MetricSet*>(this)->getMetric(name));
}
void addToSnapshot(Metric& m, std::vector<Metric::UP> &o) const override { addTo(m, &o); }
@@ -75,11 +77,6 @@ public:
void addToPart(Metric& m) const override { addTo(m, 0); }
private:
- // Do not generate default copy constructor or assignment operator
- // These would screw up metric registering
- MetricSet(const MetricSet&);
- MetricSet& operator=(const MetricSet&);
-
void tagRegistrationAltered();
const Metric* getMetricInternal(stringref name) const;
diff --git a/metrics/src/vespa/metrics/metricsnapshot.cpp b/metrics/src/vespa/metrics/metricsnapshot.cpp
index 34ba32e9d95..1580f340f0e 100644
--- a/metrics/src/vespa/metrics/metricsnapshot.cpp
+++ b/metrics/src/vespa/metrics/metricsnapshot.cpp
@@ -13,14 +13,12 @@ MetricSnapshot::MetricSnapshot(const Metric::String& name)
_period(0),
_fromTime(0),
_toTime(0),
- _snapshot(new MetricSet("top", {}, "")),
+ _snapshot(new MetricSet("top", {}, "", nullptr)),
_metrics()
{
}
-MetricSnapshot::MetricSnapshot(
- const Metric::String& name, uint32_t period, const MetricSet& source,
- bool copyUnset)
+MetricSnapshot::MetricSnapshot(const Metric::String& name, uint32_t period, const MetricSet& source, bool copyUnset)
: _name(name),
_period(period),
_fromTime(0),
@@ -34,7 +32,7 @@ MetricSnapshot::MetricSnapshot(
_metrics.shrink_to_fit();
}
-MetricSnapshot::~MetricSnapshot() { }
+MetricSnapshot::~MetricSnapshot() = default;
void
MetricSnapshot::reset(time_t currentTime)
diff --git a/metrics/src/vespa/metrics/summetric.h b/metrics/src/vespa/metrics/summetric.h
index b94c4b791ec..0906ade5cc9 100644
--- a/metrics/src/vespa/metrics/summetric.h
+++ b/metrics/src/vespa/metrics/summetric.h
@@ -43,11 +43,11 @@ private:
std::vector<const AddendMetric*> _metricsToSum;
public:
- SumMetric(const String& name, Tags tags, const String& description, MetricSet* owner = 0);
- SumMetric(const SumMetric<AddendMetric>& other, std::vector<Metric::UP> & ownerList, MetricSet* owner = 0);
+ SumMetric(const String& name, Tags tags, const String& description, MetricSet* owner);
+ SumMetric(const SumMetric<AddendMetric>& other, std::vector<Metric::UP> & ownerList, MetricSet* owner);
~SumMetric();
- Metric* clone( std::vector<Metric::UP> &, CopyType, MetricSet* owner, bool includeUnused = false) const override;
+ Metric* clone( std::vector<Metric::UP> &, CopyType, MetricSet* owner, bool includeUnused) const override;
/**
* If you want to support sums of collections of metrics that may
diff --git a/metrics/src/vespa/metrics/valuemetric.h b/metrics/src/vespa/metrics/valuemetric.h
index 90f09bef24c..0211fcf6974 100644
--- a/metrics/src/vespa/metrics/valuemetric.h
+++ b/metrics/src/vespa/metrics/valuemetric.h
@@ -77,9 +77,10 @@ class ValueMetric : public AbstractValueMetric {
public:
ValueMetric(const ValueMetric<AvgVal, TotVal, SumOnAdd> &, MetricSet *owner);
-
- ValueMetric(const String &name, Tags dimensions,
- const String &description, MetricSet *owner = 0);
+ ValueMetric(const String &name, Tags dimensions, const String &description)
+ : ValueMetric(name, std::move(dimensions), description, nullptr)
+ {}
+ ValueMetric(const String &name, Tags dimensions, const String &description, MetricSet *owner);
~ValueMetric() override;