summaryrefslogtreecommitdiffstats
path: root/configd/src/apps/sentinel/config-handler.cpp
diff options
context:
space:
mode:
authorArne Juul <arnej@yahoo-inc.com>2017-12-04 14:46:13 +0000
committerArne Juul <arnej@yahoo-inc.com>2017-12-07 11:02:00 +0000
commit6a2f714b2a740a05a709e290079fd18014244462 (patch)
tree8df93c64c231305e56f5ca1ef0e750ffcc095f56 /configd/src/apps/sentinel/config-handler.cpp
parent3509f17b3ba18a96dc1f52e7b0e23d679e020e8c (diff)
use vespalib metrics library
Diffstat (limited to 'configd/src/apps/sentinel/config-handler.cpp')
-rw-r--r--configd/src/apps/sentinel/config-handler.cpp55
1 files changed, 3 insertions, 52 deletions
diff --git a/configd/src/apps/sentinel/config-handler.cpp b/configd/src/apps/sentinel/config-handler.cpp
index e5222b0350b..03ea1da9617 100644
--- a/configd/src/apps/sentinel/config-handler.cpp
+++ b/configd/src/apps/sentinel/config-handler.cpp
@@ -395,61 +395,12 @@ ConfigHandler::handleCommand(CommandConnection *c)
}
}
-namespace {
-
-void
-fillRestarts(vespalib::SimpleMetricSnapshot &snapshot, unsigned long restarts)
-{
- snapshot.addCount("sentinel.restarts",
- "how many times sentinel restarted a service",
- restarts);
-}
-
-void
-fillTotalRestarts(vespalib::SimpleMetricSnapshot &snapshot,
- unsigned long totalRestarts)
-{
- snapshot.addGauge("sentinel.totalRestarts",
- "how many times sentinel restarted a service since "
- "sentinel start",
- totalRestarts);
-}
-
-void
-fillRunning(vespalib::SimpleMetricSnapshot &snapshot, unsigned long running)
-{
- snapshot.addGauge("sentinel.running",
- "how many services the sentinel has running currently",
- running);
-}
-
-void
-fillUptime(vespalib::SimpleMetricSnapshot &snapshot, long uptime)
-{
- snapshot.addGauge("sentinel.uptime",
- "how many seconds has the sentinel been running",
- uptime);
-}
-
-} // namespace <unnamed>
-
void
ConfigHandler::updateMetrics()
{
- time_t now = time(nullptr);
- vespalib::SimpleMetricSnapshot snapshot(_startMetrics.snapshotStart, _startMetrics.snapshotEnd);
- fillRestarts(snapshot, _startMetrics.totalRestartsLastSnapshot);
- fillTotalRestarts(snapshot, _startMetrics.totalRestartsCounter);
- fillRunning(snapshot, _startMetrics.currentlyRunningServices);
- fillUptime(snapshot, now - _startMetrics.startedTime);
- _stateApi.myMetrics.setMetrics(snapshot.asString());
-
- vespalib::SimpleMetricSnapshot totals(_startMetrics.startedTime, now);
- fillRestarts(totals, _startMetrics.totalRestartsCounter);
- fillRunning(totals, _startMetrics.currentlyRunningServices);
- fillUptime(totals, now - _startMetrics.startedTime);
- _stateApi.myMetrics.setTotalMetrics(totals.asString());
-
+ _startMetrics.maybeLog();
+ _stateApi.myMetrics.setMetrics(_startMetrics.producer.getMetrics(""));
+ _stateApi.myMetrics.setTotalMetrics(_startMetrics.producer.getTotalMetrics(""));
}
void