aboutsummaryrefslogtreecommitdiff
path: root/zencore/include
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-09-30 11:52:05 +0200
committerStefan Boberg <[email protected]>2021-09-30 11:52:05 +0200
commit8a48929c2212c830cf54d2c874e1a55a8f68e09e (patch)
tree4822d0f33a3f86d993e534cb862103605e9e1b4e /zencore/include
parentstructured cache: Added stats test code (needs additional work / metrics) (diff)
downloadzen-8a48929c2212c830cf54d2c874e1a55a8f68e09e.tar.xz
zen-8a48929c2212c830cf54d2c874e1a55a8f68e09e.zip
stats: Added EmitSnapshot functions to emit metrics into CbObjects
Diffstat (limited to 'zencore/include')
-rw-r--r--zencore/include/zencore/stats.h20
1 files changed, 14 insertions, 6 deletions
diff --git a/zencore/include/zencore/stats.h b/zencore/include/zencore/stats.h
index 7665d0cf5..f61184ced 100644
--- a/zencore/include/zencore/stats.h
+++ b/zencore/include/zencore/stats.h
@@ -7,6 +7,10 @@
#include <atomic>
#include <random>
+namespace zen {
+class CbObjectWriter;
+}
+
namespace zen::metrics {
template<typename T>
@@ -77,18 +81,19 @@ public:
Meter();
~Meter();
- double Rate1(); // One-minute rate
- double Rate5(); // Five-minute rate
- double Rate15(); // Fifteen-minute rate
- double MeanRate(); // Mean rate since instantiation of this meter
- void Mark(uint64_t Count = 1); // Register one or more events
+ inline uint64_t Count() const { return m_TotalCount; }
+ double Rate1(); // One-minute rate
+ double Rate5(); // Five-minute rate
+ double Rate15(); // Fifteen-minute rate
+ double MeanRate() const; // Mean rate since instantiation of this meter
+ void Mark(uint64_t Count = 1); // Register one or more events
private:
std::atomic<uint64_t> m_TotalCount{0}; // Accumulator counting number of marks since beginning
std::atomic<uint64_t> m_PendingCount{0}; // Pending EWMA update accumulator
std::atomic<uint64_t> m_StartTick{0}; // Time this was instantiated (for mean)
std::atomic<uint64_t> m_LastTick{0}; // Timestamp of last EWMA tick
- std::atomic<int64_t> m_Remain{0}; // Tracks the "modulo" of tick time
+ std::atomic<int64_t> m_Remainder{0}; // Tracks the "modulo" of tick time
bool m_IsFirstTick = true;
RawEWMA m_RateM1;
RawEWMA m_RateM5;
@@ -175,6 +180,9 @@ private:
std::atomic<int64_t> m_Count{0};
};
+void EmitSnapshot(std::string_view Tag, const Histogram& Stat, CbObjectWriter& Cbo);
+void EmitSnapshot(std::string_view Tag, Meter& Stat, CbObjectWriter& Cbo);
+
} // namespace zen::metrics
namespace zen {