aboutsummaryrefslogtreecommitdiffstats
path: root/storage
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-03-01 08:10:29 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2023-03-01 17:03:02 +0000
commitfeba6c21c8ebe54c649789969b738fade4dbc939 (patch)
treefc0ca7ce54f375d7ac551cc99ce27f6b460699aa /storage
parenta763fc387a1444a425b630498fa9ab051ed8e400 (diff)
Use a typed period.
Diffstat (limited to 'storage')
-rw-r--r--storage/src/vespa/storage/common/statusmetricconsumer.cpp15
-rw-r--r--storage/src/vespa/storage/storageserver/statemanager.cpp6
-rw-r--r--storage/src/vespa/storage/storageserver/statereporter.cpp4
3 files changed, 12 insertions, 13 deletions
diff --git a/storage/src/vespa/storage/common/statusmetricconsumer.cpp b/storage/src/vespa/storage/common/statusmetricconsumer.cpp
index 67c7d375910..68866027cd1 100644
--- a/storage/src/vespa/storage/common/statusmetricconsumer.cpp
+++ b/storage/src/vespa/storage/common/statusmetricconsumer.cpp
@@ -69,21 +69,21 @@ StatusMetricConsumer::reportStatus(std::ostream& out,
if (path.hasAttribute("interval")) {
// Grab the snapshot we want to view more of
- int32_t interval(boost::lexical_cast<int32_t>(path.getAttribute("interval")));
+ int32_t intervalS(boost::lexical_cast<int32_t>(path.getAttribute("interval")));
metrics::MetricLockGuard metricLock(_manager.getMetricLock());
std::unique_ptr<metrics::MetricSnapshot> generated;
const metrics::MetricSnapshot* snapshot;
- if (interval == -2) {
+ if (intervalS == -2) {
snapshot = &_manager.getActiveMetrics(metricLock);
_manager.getActiveMetrics(metricLock).setToTime(currentTime);
- } else if (interval == -1) {
+ } else if (intervalS == -1) {
// "Prime" the metric structure by first fetching the set of active
// metrics (complete with structure) and resetting these. This
// leaves us with an empty metrics set to which we can (in order)
// add the total and the active metrics. If this is not done, non-
// written metrics won't be included even if copyUnset is true.
generated = std::make_unique<metrics::MetricSnapshot>(
- "Total metrics from start until current time", 0,
+ "Total metrics from start until current time", 0s,
_manager.getActiveMetrics(metricLock).getMetrics(),
copyUnset);
generated->reset();
@@ -91,10 +91,10 @@ StatusMetricConsumer::reportStatus(std::ostream& out,
_manager.getActiveMetrics(metricLock).addToSnapshot(*generated, currentTime);
generated->setFromTime(_manager.getTotalMetricSnapshot(metricLock).getFromTime());
snapshot = generated.get();
- } else if (interval == 0) {
+ } else if (intervalS == 0) {
if (copyUnset) {
generated = std::make_unique<metrics::MetricSnapshot>(
- _manager.getTotalMetricSnapshot(metricLock).getName(), 0,
+ _manager.getTotalMetricSnapshot(metricLock).getName(), 0s,
_manager.getActiveMetrics(metricLock).getMetrics(), true);
generated->reset();
_manager.getTotalMetricSnapshot(metricLock).addToSnapshot(*generated, currentTime);
@@ -103,9 +103,10 @@ StatusMetricConsumer::reportStatus(std::ostream& out,
snapshot = &_manager.getTotalMetricSnapshot(metricLock);
}
} else {
+ vespalib::duration interval = vespalib::from_s(intervalS);
if (copyUnset) {
generated = std::make_unique<metrics::MetricSnapshot>(
- _manager.getMetricSnapshot(metricLock, interval).getName(), 0,
+ _manager.getMetricSnapshot(metricLock, interval).getName(), 0s,
_manager.getActiveMetrics(metricLock).getMetrics(), true);
generated->reset();
_manager.getMetricSnapshot(metricLock, interval, temporarySnap)
diff --git a/storage/src/vespa/storage/storageserver/statemanager.cpp b/storage/src/vespa/storage/storageserver/statemanager.cpp
index c59f7797bb8..654fe0e1f5d 100644
--- a/storage/src/vespa/storage/storageserver/statemanager.cpp
+++ b/storage/src/vespa/storage/storageserver/statemanager.cpp
@@ -18,7 +18,6 @@
#include <vespa/vespalib/util/string_escape.h>
#include <vespa/vespalib/util/stringfmt.h>
#include <fstream>
-#include <ranges>
#include <vespa/log/log.h>
LOG_SETUP(".state.manager");
@@ -545,10 +544,9 @@ StateManager::getNodeInfo() const
stream << "metrics";
try {
metrics::MetricLockGuard lock(_metricManager.getMetricLock());
- std::vector<uint32_t> periods(_metricManager.getSnapshotPeriods(lock));
+ auto periods(_metricManager.getSnapshotPeriods(lock));
if (!periods.empty()) {
- uint32_t period = periods[0];
- const metrics::MetricSnapshot& snapshot(_metricManager.getMetricSnapshot(lock, period));
+ const metrics::MetricSnapshot& snapshot(_metricManager.getMetricSnapshot(lock, periods[0]));
metrics::JsonWriter metricJsonWriter(stream);
_metricManager.visit(lock, snapshot, metricJsonWriter, "fleetcontroller");
} else {
diff --git a/storage/src/vespa/storage/storageserver/statereporter.cpp b/storage/src/vespa/storage/storageserver/statereporter.cpp
index 79746f2cd63..d9e79d3b7b4 100644
--- a/storage/src/vespa/storage/storageserver/statereporter.cpp
+++ b/storage/src/vespa/storage/storageserver/statereporter.cpp
@@ -69,11 +69,11 @@ vespalib::string
StateReporter::getMetrics(const vespalib::string &consumer)
{
metrics::MetricLockGuard guard(_manager.getMetricLock());
- std::vector<uint32_t> periods = _manager.getSnapshotPeriods(guard);
+ auto periods = _manager.getSnapshotPeriods(guard);
if (periods.empty()) {
return ""; // no configuration yet
}
- uint32_t interval = periods[0];
+ vespalib::duration interval = periods[0];
// To get unset metrics, we have to copy active metrics, clear them
// and then assign the snapshot