aboutsummaryrefslogtreecommitdiff
path: root/src/zenserver/cache/structuredcachestore.h
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2023-10-25 12:21:51 +0200
committerGitHub <[email protected]>2023-10-25 12:21:51 +0200
commit0b220255724020daea18ddb559f5edf3fdb1621b (patch)
tree7809227752c15d90111c4e600d80b59d90ad25d2 /src/zenserver/cache/structuredcachestore.h
parentNew rotating file logger that keeps on running regardless of errors (#495) (diff)
downloadzen-0b220255724020daea18ddb559f5edf3fdb1621b.tar.xz
zen-0b220255724020daea18ddb559f5edf3fdb1621b.zip
statsd metrics reporting (#496)
added support for reporting metrics via statsd style UDP messaging, which is supported by many monitoring solution providers this change adds reporting only of three cache related metrics (hit/miss/put) but this should be extended to include more metrics after additional evaluation
Diffstat (limited to 'src/zenserver/cache/structuredcachestore.h')
-rw-r--r--src/zenserver/cache/structuredcachestore.h21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/zenserver/cache/structuredcachestore.h b/src/zenserver/cache/structuredcachestore.h
index 02d0e31c0..dacf482d8 100644
--- a/src/zenserver/cache/structuredcachestore.h
+++ b/src/zenserver/cache/structuredcachestore.h
@@ -3,6 +3,7 @@
#pragma once
#include "cachedisklayer.h"
+#include "stats/statsreporter.h"
#include <zencore/compactbinary.h>
#include <zencore/iohash.h>
@@ -18,6 +19,8 @@
namespace zen {
+class StatsDaemonClient;
+
/******************************************************************************
/$$$$$$$$ /$$$$$$ /$$
@@ -126,7 +129,7 @@ private:
*/
-class ZenCacheStore final : public RefCounted
+class ZenCacheStore final : public RefCounted, public StatsProvider
{
public:
static constexpr std::string_view DefaultNamespace =
@@ -161,11 +164,11 @@ public:
struct CacheStoreStats
{
- uint64_t HitCount;
- uint64_t MissCount;
- uint64_t WriteCount;
- uint64_t RejectedWriteCount;
- uint64_t RejectedReadCount;
+ uint64_t HitCount = 0;
+ uint64_t MissCount = 0;
+ uint64_t WriteCount = 0;
+ uint64_t RejectedWriteCount = 0;
+ uint64_t RejectedReadCount = 0;
metrics::RequestStatsSnapshot PutOps;
metrics::RequestStatsSnapshot GetOps;
std::vector<NamedNamespaceStats> NamespaceStats;
@@ -199,7 +202,7 @@ public:
const std::string_view ValueFilter) const;
GcStorageSize StorageSize() const;
- CacheStoreStats Stats();
+ CacheStoreStats Stats(bool IncludeNamespaceStats = true);
Configuration GetConfiguration() const { return m_Configuration; }
void SetLoggingConfig(const Configuration::LogConfig& Loggingconfig);
@@ -212,6 +215,9 @@ public:
std::string_view Bucket,
std::function<void(const IoHash& Key, const CacheValueDetails::ValueDetails& Details)>&& Fn);
+ // StatsProvider
+ virtual void ReportMetrics(StatsDaemonClient& Statsd) override;
+
private:
const ZenCacheNamespace* FindNamespace(std::string_view Namespace) const;
ZenCacheNamespace* GetNamespace(std::string_view Namespace);
@@ -219,6 +225,7 @@ private:
typedef std::unordered_map<std::string, std::unique_ptr<ZenCacheNamespace>> NamespaceMap;
+ CacheStoreStats m_LastReportedMetrics;
const DiskWriteBlocker* m_DiskWriteBlocker = nullptr;
mutable RwLock m_NamespacesLock;
NamespaceMap m_Namespaces;