summaryrefslogtreecommitdiffstats
path: root/metrics
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-03-01 05:42:14 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2023-03-01 17:01:45 +0000
commit7566627f5a6a1230edc2fffa8ad0bf67abc39353 (patch)
treec226aff88cdc370eee9ea748ff184eece8a68633 /metrics
parent488ef94f55b4cc9d1430d02867771d7fd60472fd (diff)
Avoid default arguments.
Diffstat (limited to 'metrics')
-rw-r--r--metrics/src/vespa/metrics/metricmanager.cpp1
-rw-r--r--metrics/src/vespa/metrics/metricmanager.h18
-rw-r--r--metrics/src/vespa/metrics/metricsnapshot.cpp8
-rw-r--r--metrics/src/vespa/metrics/metricsnapshot.h21
4 files changed, 24 insertions, 24 deletions
diff --git a/metrics/src/vespa/metrics/metricmanager.cpp b/metrics/src/vespa/metrics/metricmanager.cpp
index c25c6a31fe7..f6601e710fc 100644
--- a/metrics/src/vespa/metrics/metricmanager.cpp
+++ b/metrics/src/vespa/metrics/metricmanager.cpp
@@ -10,7 +10,6 @@
#include <vespa/vespalib/util/exceptions.h>
#include <vespa/vespalib/util/time.h>
#include <vespa/vespalib/stllike/asciistream.h>
-#include <vespa/vespalib/stllike/hashtable.hpp>
#include <vespa/config/subscription/configsubscriber.hpp>
#include <set>
#include <sstream>
diff --git a/metrics/src/vespa/metrics/metricmanager.h b/metrics/src/vespa/metrics/metricmanager.h
index d771081c1cc..db5bb5090f7 100644
--- a/metrics/src/vespa/metrics/metricmanager.h
+++ b/metrics/src/vespa/metrics/metricmanager.h
@@ -57,8 +57,6 @@
#include <list>
#include <thread>
-template class vespalib::hash_set<metrics::Metric::String>;
-
namespace metrics {
class MetricManager
@@ -103,8 +101,8 @@ private:
std::list<UpdateHook*> _snapshotUpdateHooks;
mutable std::mutex _waiter;
mutable std::condition_variable _cond;
- std::vector<MetricSnapshotSet::SP> _snapshots;
- MetricSnapshot::SP _totalMetrics;
+ std::vector<std::shared_ptr<MetricSnapshotSet>> _snapshots;
+ std::shared_ptr<MetricSnapshot> _totalMetrics;
std::unique_ptr<Timer> _timer;
std::atomic<time_t> _lastProcessedTime;
// Should be added to config, but wont now due to problems with
@@ -147,7 +145,7 @@ public:
* seconds or so. Any value of period >= the smallest snapshot
* time will behave identically as if period is set to 0.
*/
- void addMetricUpdateHook(UpdateHook&, uint32_t period = 0);
+ void addMetricUpdateHook(UpdateHook&, uint32_t period);
/** Remove a metric update hook so it won't get any more updates. */
void removeMetricUpdateHook(UpdateHook&);
@@ -157,7 +155,10 @@ public:
* nice values before reporting something.
* This function can not be called from an update hook callback.
*/
- void updateMetrics(bool includeSnapshotOnlyHooks = false);
+ void updateMetrics(bool includeSnapshotOnlyHooks);
+ void updateMetrics() {
+ updateMetrics(false);
+ }
/**
* Force event logging to happen now.
@@ -199,7 +200,10 @@ public:
* of consumers. readConfig() will start a config subscription. It should
* not be called multiple times.
*/
- void init(const config::ConfigUri & uri, bool startThread = true);
+ void init(const config::ConfigUri & uri, bool startThread);
+ void init(const config::ConfigUri & uri) {
+ init(uri, true);
+ }
/**
* Visit a given snapshot for a given consumer. (Empty consumer name means
diff --git a/metrics/src/vespa/metrics/metricsnapshot.cpp b/metrics/src/vespa/metrics/metricsnapshot.cpp
index d8c87ce52d9..2b2d73b6117 100644
--- a/metrics/src/vespa/metrics/metricsnapshot.cpp
+++ b/metrics/src/vespa/metrics/metricsnapshot.cpp
@@ -31,9 +31,7 @@ MetricSnapshot::MetricSnapshot(const Metric::String& name, uint32_t period, cons
_snapshot(),
_metrics()
{
- Metric* m = source.clone(_metrics, Metric::INACTIVE, 0, copyUnset);
- assert(m->isMetricSet());
- _snapshot.reset(static_cast<MetricSet*>(m));
+ _snapshot.reset(source.clone(_metrics, Metric::INACTIVE, 0, copyUnset));
_metrics.shrink_to_fit();
}
@@ -103,9 +101,7 @@ MetricSnapshotSet::haveCompletedNewPeriod(system_time newFromTime)
// If not time to roll yet, just return
if (++_builderCount < _count) return false;
// Building buffer done. Use that as current and reset current.
- MetricSnapshot::UP tmp(std::move(_current));
- _current = std::move(_building);
- _building = std::move(tmp);
+ std::swap(_current, _building);
_building->reset(newFromTime);
_builderCount = 0;
return true;
diff --git a/metrics/src/vespa/metrics/metricsnapshot.h b/metrics/src/vespa/metrics/metricsnapshot.h
index 6bb37f8223d..08d22c3c588 100644
--- a/metrics/src/vespa/metrics/metricsnapshot.h
+++ b/metrics/src/vespa/metrics/metricsnapshot.h
@@ -34,15 +34,12 @@ class MetricSnapshot
mutable std::vector<Metric::UP> _metrics;
public:
- using UP = std::unique_ptr<MetricSnapshot>;
- using SP = std::shared_ptr<MetricSnapshot>;
-
/** Create a fresh empty top level snapshot. */
MetricSnapshot(const Metric::String& name);
/** Create a snapshot of another metric source. */
MetricSnapshot(const Metric::String& name, uint32_t period,
const MetricSet& source, bool copyUnset);
- virtual ~MetricSnapshot();
+ ~MetricSnapshot();
void addToSnapshot(MetricSnapshot& other, bool reset_, system_time currentTime) {
_snapshot->addToSnapshot(other.getMetrics(), other._metrics);
@@ -78,11 +75,9 @@ class MetricSnapshotSet {
// before we have a full time window.
uint32_t _builderCount; // Number of times we've currently added to the
// building instance.
- MetricSnapshot::UP _current; // The last full period
- MetricSnapshot::UP _building; // The building period
+ std::unique_ptr<MetricSnapshot> _current; // The last full period
+ std::unique_ptr<MetricSnapshot> _building; // The building period
public:
- using SP = std::shared_ptr<MetricSnapshotSet>;
-
MetricSnapshotSet(const Metric::String& name, uint32_t period, uint32_t count,
const MetricSet& source, bool snapshotUnsetMetrics);
@@ -93,10 +88,16 @@ public:
system_time getNextWorkTime() const { return getToTime() + vespalib::from_s(getPeriod()); }
uint32_t getCount() const { return _count; }
uint32_t getBuilderCount() const { return _builderCount; }
- MetricSnapshot& getSnapshot(bool temporary = false) {
+ MetricSnapshot& getSnapshot() {
+ return getSnapshot(false);
+ }
+ MetricSnapshot& getSnapshot(bool temporary) {
return *((temporary && _count > 1) ? _building : _current);
}
- const MetricSnapshot& getSnapshot(bool temporary = false) const {
+ const MetricSnapshot& getSnapshot() const {
+ return getSnapshot(false);
+ }
+ const MetricSnapshot& getSnapshot(bool temporary) const {
return *((temporary && _count > 1) ? _building : _current);
}
MetricSnapshot& getNextTarget();