aboutsummaryrefslogtreecommitdiff
path: root/src/zenserver/cache/structuredcachestore.h
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2023-09-28 23:57:31 +0200
committerGitHub <[email protected]>2023-09-28 23:57:31 +0200
commitbf20e4c8e63638792e69098d4d9810c1136ff627 (patch)
treefee82fc0d15910902a4a3c24a5564867748b6419 /src/zenserver/cache/structuredcachestore.h
parentadded more context to http response error message (#430) (diff)
downloadzen-bf20e4c8e63638792e69098d4d9810c1136ff627.tar.xz
zen-bf20e4c8e63638792e69098d4d9810c1136ff627.zip
adding more stats (#429)
- Feature: Add detailed stats on requests and data sizes on a per-bucket level, use parameter `cachestorestats=true` on the `/stats/z$` endpoint to enable - Feature: Add detailed stats on requests and data sizes on cidstore, use parameter `cidstorestats=true` on the `/stats/z$` endpoint to enable - Feature: Dashboard now accepts parameters in the URL which is passed on to the `/stats/z$` endpoint
Diffstat (limited to 'src/zenserver/cache/structuredcachestore.h')
-rw-r--r--src/zenserver/cache/structuredcachestore.h45
1 files changed, 42 insertions, 3 deletions
diff --git a/src/zenserver/cache/structuredcachestore.h b/src/zenserver/cache/structuredcachestore.h
index e7b64babe..0dd160a98 100644
--- a/src/zenserver/cache/structuredcachestore.h
+++ b/src/zenserver/cache/structuredcachestore.h
@@ -7,6 +7,7 @@
#include <zencore/compactbinary.h>
#include <zencore/iohash.h>
+#include <zencore/stats.h>
#include <zenstore/gc.h>
#include <zenutil/cache/cache.h>
@@ -66,6 +67,16 @@ public:
ZenCacheMemoryLayer::Info MemoryLayerInfo;
};
+ struct NamespaceStats
+ {
+ uint64_t HitCount;
+ uint64_t MissCount;
+ uint64_t WriteCount;
+ metrics::RequestStatsSnapshot PutOps;
+ metrics::RequestStatsSnapshot GetOps;
+ ZenCacheDiskLayer::DiskStats DiskStats;
+ };
+
ZenCacheNamespace(GcManager& Gc, const std::filesystem::path& RootDir);
~ZenCacheNamespace();
@@ -91,6 +102,7 @@ public:
Info GetInfo() const;
std::optional<BucketInfo> GetBucketInfo(std::string_view Bucket) const;
+ NamespaceStats Stats();
CacheValueDetails::NamespaceDetails GetValueDetails(const std::string_view BucketFilter, const std::string_view ValueFilter) const;
@@ -98,6 +110,11 @@ private:
std::filesystem::path m_RootDir;
ZenCacheMemoryLayer m_MemLayer;
ZenCacheDiskLayer m_DiskLayer;
+ std::atomic<uint64_t> m_HitCount{};
+ std::atomic<uint64_t> m_MissCount{};
+ std::atomic<uint64_t> m_WriteCount{};
+ metrics::RequestStats m_PutOps;
+ metrics::RequestStats m_GetOps;
uint64_t m_DiskLayerSizeThreshold = 1 * 1024;
uint64_t m_LastScrubTime = 0;
@@ -138,6 +155,22 @@ public:
GcStorageSize StorageSize;
};
+ struct NamedNamespaceStats
+ {
+ std::string NamespaceName;
+ ZenCacheNamespace::NamespaceStats Stats;
+ };
+
+ struct CacheStoreStats
+ {
+ uint64_t HitCount;
+ uint64_t MissCount;
+ uint64_t WriteCount;
+ metrics::RequestStatsSnapshot PutOps;
+ metrics::RequestStatsSnapshot GetOps;
+ std::vector<NamedNamespaceStats> NamespaceStats;
+ };
+
ZenCacheStore(GcManager& Gc, const Configuration& Configuration, const DiskWriteBlocker* InDiskWriteBlocker);
~ZenCacheStore();
@@ -160,7 +193,8 @@ public:
const std::string_view BucketFilter,
const std::string_view ValueFilter) const;
- GcStorageSize StorageSize() const;
+ GcStorageSize StorageSize() const;
+ CacheStoreStats Stats();
Configuration GetConfiguration() const { return m_Configuration; }
void SetLoggingConfig(const Configuration::LogConfig& Loggingconfig);
@@ -187,8 +221,13 @@ private:
NamespaceMap m_Namespaces;
std::vector<std::unique_ptr<ZenCacheNamespace>> m_DroppedNamespaces;
- GcManager& m_Gc;
- Configuration m_Configuration;
+ GcManager& m_Gc;
+ Configuration m_Configuration;
+ std::atomic<uint64_t> m_HitCount{};
+ std::atomic<uint64_t> m_MissCount{};
+ std::atomic<uint64_t> m_WriteCount{};
+ metrics::RequestStats m_PutOps;
+ metrics::RequestStats m_GetOps;
struct AccessLogItem
{