From 7411711688777e39ec39adbcb910de8ed8abbdcf Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Wed, 10 Nov 2021 05:30:49 -0500 Subject: [PATCH] stats: add new metric to track number of signals --- include/villas/stats.hpp | 1 + lib/hooks/stats.cpp | 2 ++ lib/stats.cpp | 12 ++++++++---- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/include/villas/stats.hpp b/include/villas/stats.hpp index 8270756a9..6a3154f61 100644 --- a/include/villas/stats.hpp +++ b/include/villas/stats.hpp @@ -60,6 +60,7 @@ public: GAP_RECEIVED, /**< Histogram for inter sample arrival time (as seen by this instance). */ OWD, /**< Histogram for one-way-delay (OWD) of received samples. */ AGE, /**< Processing time of packets within VILLASnode. */ + SIGNAL_COUNT, /**< Number of signals per sample. */ /* RTP metrics */ RTP_LOSS_FRACTION, /**< Fraction lost since last RTP SR/RR. */ diff --git a/lib/hooks/stats.cpp b/lib/hooks/stats.cpp index 01c8ea694..a53dd795c 100644 --- a/lib/hooks/stats.cpp +++ b/lib/hooks/stats.cpp @@ -268,6 +268,8 @@ Hook::Reason StatsReadHook::process(struct sample *smp) } } + parent->stats->update(Stats::Metric::SIGNAL_COUNT, smp->length); + sample_incref(smp); if (last) diff --git a/lib/stats.cpp b/lib/stats.cpp index bd79845b4..4307d5790 100644 --- a/lib/stats.cpp +++ b/lib/stats.cpp @@ -39,6 +39,7 @@ std::unordered_map Stats::metrics = { { Stats::Metric::GAP_RECEIVED, { "gap_received", "seconds", "Inter-message arrival time (as received by this instance)" }}, { Stats::Metric::OWD, { "owd", "seconds", "One-way-delay (OWD) of received messages" }}, { Stats::Metric::AGE, { "age", "seconds", "Processing time of packets within the from receive to sent" }}, + { Stats::Metric::SIGNAL_COUNT, { "signal_cnt", "signals", "Number of signals per sample" }}, { Stats::Metric::RTP_LOSS_FRACTION, { "rtp.loss_fraction", "percent", "Fraction lost since last RTP SR/RR." }}, { Stats::Metric::RTP_PKTS_LOST, { "rtp.pkts_lost", "packets", "Cumulative number of packtes lost" }}, { Stats::Metric::RTP_JITTER, { "rtp.jitter", "seconds", "Interarrival jitter" }}, @@ -65,7 +66,8 @@ std::vector Stats::columns = { { 10, TableColumn::Alignment::RIGHT, "Rate last", "%lf", "pkt/sec" }, { 10, TableColumn::Alignment::RIGHT, "Rate mean", "%lf", "pkt/sec" }, { 10, TableColumn::Alignment::RIGHT, "Age mean", "%lf", "secs" }, - { 10, TableColumn::Alignment::RIGHT, "Age Max", "%lf", "sec" } + { 10, TableColumn::Alignment::RIGHT, "Age Max", "%lf", "sec" }, + { 8, TableColumn::Alignment::RIGHT, "Signals", "%ju", "signals" } }; enum Stats::Format Stats::lookupFormat(const std::string &str) @@ -172,12 +174,13 @@ void Stats::printPeriodic(FILE *f, enum Format fmt, struct vnode *n) const (double) 1.0 / histograms.at(Metric::GAP_RECEIVED).getLast(), (double) 1.0 / histograms.at(Metric::GAP_RECEIVED).getMean(), (double) histograms.at(Metric::AGE).getMean(), - (double) histograms.at(Metric::AGE).getHighest() + (double) histograms.at(Metric::AGE).getHighest(), + (uintmax_t) histograms.at(Metric::SIGNAL_COUNT).getLast() ); break; case Format::JSON: { - json_t *json_stats = json_pack("{ s: s, s: i, s: i, s: i, s: i, s: f, s: f, s: f, s: f, s: f, s: f }", + json_t *json_stats = json_pack("{ s: s, s: i, s: i, s: i, s: i, s: f, s: f, s: f, s: f, s: f, s: f, s: i }", "node", node_name(n), "recv", histograms.at(Metric::OWD).getTotal(), "sent", histograms.at(Metric::AGE).getTotal(), @@ -188,7 +191,8 @@ void Stats::printPeriodic(FILE *f, enum Format fmt, struct vnode *n) const "rate_last", 1.0 / histograms.at(Metric::GAP_SAMPLE).getLast(), "rate_mean", 1.0 / histograms.at(Metric::GAP_SAMPLE).getMean(), "age_mean", histograms.at(Metric::AGE).getMean(), - "age_max", histograms.at(Metric::AGE).getHighest() + "age_max", histograms.at(Metric::AGE).getHighest(), + "signals", histograms.at(Metric::SIGNAL_COUNT).getLast() ); json_dumpf(json_stats, f, 0); break;