summaryrefslogtreecommitdiffstats
path: root/metrics
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-08-28 15:25:49 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2023-08-28 15:25:49 +0000
commit40a3b832873d167485a8a4e796512446ae55787c (patch)
treebaccb18b63c7f05eb65c2fbc144a64a2ead12c56 /metrics
parent3a5aa92006f876f5faf57bb0859b159ca841d60b (diff)
Modernize code
Diffstat (limited to 'metrics')
-rw-r--r--metrics/src/vespa/metrics/countmetric.h2
-rw-r--r--metrics/src/vespa/metrics/jsonwriter.h5
-rw-r--r--metrics/src/vespa/metrics/metricmanager.cpp6
-rw-r--r--metrics/src/vespa/metrics/metricmanager.h4
-rw-r--r--metrics/src/vespa/metrics/metricsnapshot.cpp6
5 files changed, 11 insertions, 12 deletions
diff --git a/metrics/src/vespa/metrics/countmetric.h b/metrics/src/vespa/metrics/countmetric.h
index 5225cd58f12..fe1f613fbf7 100644
--- a/metrics/src/vespa/metrics/countmetric.h
+++ b/metrics/src/vespa/metrics/countmetric.h
@@ -19,7 +19,7 @@
namespace metrics {
struct AbstractCountMetric : public Metric {
- bool visit(MetricVisitor& visitor, bool tagAsAutoGenerated = false) const override
+ bool visit(MetricVisitor& visitor, bool tagAsAutoGenerated) const override
{
return visitor.visitCountMetric(*this, tagAsAutoGenerated);
}
diff --git a/metrics/src/vespa/metrics/jsonwriter.h b/metrics/src/vespa/metrics/jsonwriter.h
index e4a2e7ca10b..379ed215198 100644
--- a/metrics/src/vespa/metrics/jsonwriter.h
+++ b/metrics/src/vespa/metrics/jsonwriter.h
@@ -18,7 +18,7 @@ class JsonWriter : public MetricVisitor, public vespalib::JsonStreamTypes {
uint64_t _period;
public:
- JsonWriter(vespalib::JsonStream&);
+ explicit JsonWriter(vespalib::JsonStream&);
private:
bool visitSnapshot(const MetricSnapshot&) override;
@@ -29,7 +29,6 @@ private:
bool visitValueMetric(const AbstractValueMetric&, bool autoGenerated) override;
void doneVisiting() override;
- void checkIfArrayNeedsToBeStarted();
void writeCommonPrefix(const Metric& m);
void writeCommonPostfix(const Metric& m);
@@ -37,7 +36,7 @@ private:
void writeInheritedDimensions();
void writeMetricSpecificDimensions(const Metric&);
- bool isLeafMetric(const Metric& m) const { return !m.isMetricSet(); }
+ static bool isLeafMetric(const Metric& m) { return !m.isMetricSet(); }
};
}
diff --git a/metrics/src/vespa/metrics/metricmanager.cpp b/metrics/src/vespa/metrics/metricmanager.cpp
index 2f04096e86a..e399a23b0b9 100644
--- a/metrics/src/vespa/metrics/metricmanager.cpp
+++ b/metrics/src/vespa/metrics/metricmanager.cpp
@@ -200,7 +200,7 @@ namespace {
struct Path {
vespalib::StringTokenizer _path;
- Path(vespalib::stringref fullpath) : _path(fullpath, ".") { }
+ explicit Path(vespalib::stringref fullpath) : _path(fullpath, ".") { }
vespalib::string toString() const {
vespalib::asciistream ost;
@@ -246,7 +246,7 @@ struct ConsumerMetricBuilder : public MetricVisitor {
};
std::list<Result> result;
- ConsumerMetricBuilder(const Config::Consumer& c) __attribute__((noinline));
+ explicit ConsumerMetricBuilder(const Config::Consumer& c) __attribute__((noinline));
~ConsumerMetricBuilder() __attribute__((noinline));
bool tagAdded(const Metric& metric) {
@@ -553,7 +553,7 @@ MetricManager::visit(const MetricLockGuard & guard, const MetricSnapshot& snapsh
MetricVisitor& visitor, const std::string& consumer) const
{
if (visitor.visitSnapshot(snapshot)) {
- if (consumer == "") {
+ if (consumer.empty()) {
snapshot.getMetrics().visit(visitor);
} else {
const ConsumerSpec * consumerSpec = getConsumerSpec(guard, consumer);
diff --git a/metrics/src/vespa/metrics/metricmanager.h b/metrics/src/vespa/metrics/metricmanager.h
index 6f40e7961f4..81d0c581370 100644
--- a/metrics/src/vespa/metrics/metricmanager.h
+++ b/metrics/src/vespa/metrics/metricmanager.h
@@ -123,7 +123,7 @@ private:
public:
MetricManager();
- MetricManager(std::unique_ptr<Timer> timer);
+ explicit MetricManager(std::unique_ptr<Timer> timer);
~MetricManager();
void stop();
@@ -218,7 +218,7 @@ public:
* snapshots while you are accessing them.
*/
MetricLockGuard getMetricLock() const {
- return MetricLockGuard(_waiter);
+ return {_waiter};
}
/** While accessing the active metrics you should have the metric lock. */
diff --git a/metrics/src/vespa/metrics/metricsnapshot.cpp b/metrics/src/vespa/metrics/metricsnapshot.cpp
index 6bcdcc60995..08ab1be3033 100644
--- a/metrics/src/vespa/metrics/metricsnapshot.cpp
+++ b/metrics/src/vespa/metrics/metricsnapshot.cpp
@@ -32,7 +32,7 @@ MetricSnapshot::MetricSnapshot(const Metric::String& name, system_time::duration
_snapshot(),
_metrics()
{
- _snapshot.reset(source.clone(_metrics, Metric::INACTIVE, 0, copyUnset));
+ _snapshot.reset(source.clone(_metrics, Metric::INACTIVE, nullptr, copyUnset));
_metrics.shrink_to_fit();
}
@@ -54,7 +54,7 @@ void
MetricSnapshot::recreateSnapshot(const MetricSet& metrics, bool copyUnset)
{
std::vector<Metric::UP> newMetrics;
- Metric* m = metrics.clone(newMetrics, Metric::INACTIVE, 0, copyUnset);
+ Metric* m = metrics.clone(newMetrics, Metric::INACTIVE, nullptr, copyUnset);
assert(m->isMetricSet());
std::unique_ptr<MetricSet> newSnapshot(static_cast<MetricSet*>(m));
newSnapshot->reset();
@@ -81,7 +81,7 @@ MetricSnapshotSet::MetricSnapshotSet(const Metric::String& name, system_time::du
_building(count == 1 ? nullptr : new MetricSnapshot(name, period, source, snapshotUnsetMetrics))
{
_current->reset();
- if (_building.get()) _building->reset();
+ if (_building) _building->reset();
}
MetricSnapshot&