diff options
| -rw-r--r-- | src/zennet/include/zennet/statsdclient.h | 9 | ||||
| -rw-r--r-- | src/zenserver/cache/structuredcachestore.cpp | 2 | ||||
| -rw-r--r-- | src/zenserver/cache/structuredcachestore.h | 2 | ||||
| -rw-r--r-- | src/zenserver/stats/statsreporter.h | 9 | ||||
| -rw-r--r-- | src/zenserver/zenserver.cpp | 1 | ||||
| -rw-r--r-- | src/zenstore/cidstore.cpp | 20 | ||||
| -rw-r--r-- | src/zenstore/include/zenstore/cidstore.h | 23 | ||||
| -rw-r--r-- | src/zenutil/include/zenutil/statsreporter.h | 34 |
8 files changed, 73 insertions, 27 deletions
diff --git a/src/zennet/include/zennet/statsdclient.h b/src/zennet/include/zennet/statsdclient.h index a429286ae..c378e49ce 100644 --- a/src/zennet/include/zennet/statsdclient.h +++ b/src/zennet/include/zennet/statsdclient.h @@ -3,6 +3,7 @@ #pragma once #include <zencore/zencore.h> +#include <zenutil/statsreporter.h> #include <memory> #include <string_view> @@ -16,7 +17,7 @@ public: virtual void SendMessage(const void* Data, size_t Size) = 0; }; -class StatsDaemonClient +class StatsDaemonClient : public StatsMetrics { public: virtual ~StatsDaemonClient() = 0; @@ -24,12 +25,6 @@ public: virtual void SetMessageSize(size_t MessageSize, bool UseThreads) = 0; virtual void Flush() = 0; - virtual void Increment(std::string_view Metric) = 0; - virtual void Decrement(std::string_view Metric) = 0; - virtual void Count(std::string_view Metric, int64_t CountDelta) = 0; - virtual void Gauge(std::string_view Metric, uint64_t CurrentValue) = 0; - virtual void Meter(std::string_view Metric, uint64_t IncrementValue) = 0; - // Not (yet) implemented: Set,Timing }; diff --git a/src/zenserver/cache/structuredcachestore.cpp b/src/zenserver/cache/structuredcachestore.cpp index 55ab6bf31..09c9f1468 100644 --- a/src/zenserver/cache/structuredcachestore.cpp +++ b/src/zenserver/cache/structuredcachestore.cpp @@ -693,7 +693,7 @@ ZenCacheStore::Stats(bool IncludeNamespaceStats) } void -ZenCacheStore::ReportMetrics(StatsDaemonClient& Statsd) +ZenCacheStore::ReportMetrics(StatsMetrics& Statsd) { const bool IncludeNamespaceStats = false; const CacheStoreStats Now = Stats(IncludeNamespaceStats); diff --git a/src/zenserver/cache/structuredcachestore.h b/src/zenserver/cache/structuredcachestore.h index a3cac0d44..4ab8f90f0 100644 --- a/src/zenserver/cache/structuredcachestore.h +++ b/src/zenserver/cache/structuredcachestore.h @@ -220,7 +220,7 @@ public: std::function<void(const IoHash& Key, const CacheValueDetails::ValueDetails& Details)>&& Fn); // StatsProvider - virtual void ReportMetrics(StatsDaemonClient& Statsd) override; + virtual void ReportMetrics(StatsMetrics& Statsd) override; private: const ZenCacheNamespace* FindNamespace(std::string_view Namespace) const; diff --git a/src/zenserver/stats/statsreporter.h b/src/zenserver/stats/statsreporter.h index ed6ec6c55..2f93aa8bb 100644 --- a/src/zenserver/stats/statsreporter.h +++ b/src/zenserver/stats/statsreporter.h @@ -5,17 +5,12 @@ #include "config.h" #include <zencore/thread.h> +#include <zenutil/statsreporter.h> namespace zen { class StatsDaemonClient; -class StatsProvider -{ -public: - virtual void ReportMetrics(StatsDaemonClient& Statsd) = 0; -}; - class StatsReporter { public: @@ -27,8 +22,8 @@ public: void Initialize(const ZenStatsConfig& Config); void Shutdown(); - void AddProvider(StatsProvider* Provider); void ReportStats(); + void AddProvider(StatsProvider* Provider); private: RwLock m_Lock; diff --git a/src/zenserver/zenserver.cpp b/src/zenserver/zenserver.cpp index f40602769..282dc73cf 100644 --- a/src/zenserver/zenserver.cpp +++ b/src/zenserver/zenserver.cpp @@ -525,6 +525,7 @@ ZenServer::InitializeStructuredCache(const ZenServerOptions& ServerOptions) m_Http->RegisterService(*m_UpstreamService); m_StatsReporter.AddProvider(m_CacheStore.Get()); + m_StatsReporter.AddProvider(m_CidStore.get()); } void diff --git a/src/zenstore/cidstore.cpp b/src/zenstore/cidstore.cpp index f6560fcff..67b7e95ac 100644 --- a/src/zenstore/cidstore.cpp +++ b/src/zenstore/cidstore.cpp @@ -99,13 +99,26 @@ struct CidStore::Impl }; } + void ReportMetrics(StatsMetrics& Statsd) + { + const CidStoreStats Now = Stats(); + const CidStoreStats& Old = m_LastReportedMetrics; + + Statsd.Meter("zen.cas_hits", Now.HitCount - Old.HitCount); + Statsd.Meter("zen.cas_misses", Now.MissCount - Old.MissCount); + Statsd.Meter("zen.cas_writes", Now.WriteCount - Old.WriteCount); + + m_LastReportedMetrics = Now; + } + std::atomic_uint64_t m_HitCount{}; std::atomic_uint64_t m_MissCount{}; std::atomic_uint64_t m_WriteCount{}; metrics::RequestStats m_AddChunkOps; metrics::RequestStats m_FindChunkOps; - // metrics::OperationTiming m_ContainChunkOps; + + CidStoreStats m_LastReportedMetrics; uint64_t m_LastScrubTime = 0; }; @@ -174,4 +187,9 @@ CidStore::Stats() const return m_Impl->Stats(); } +void +CidStore::ReportMetrics(StatsMetrics& Statsd) +{ + return m_Impl->ReportMetrics(Statsd); +} } // namespace zen diff --git a/src/zenstore/include/zenstore/cidstore.h b/src/zenstore/include/zenstore/cidstore.h index 1c8d79158..319683dcb 100644 --- a/src/zenstore/include/zenstore/cidstore.h +++ b/src/zenstore/include/zenstore/cidstore.h @@ -7,6 +7,7 @@ #include <zencore/iohash.h> #include <zencore/stats.h> #include <zenstore/hashkeyset.h> +#include <zenutil/statsreporter.h> ZEN_THIRD_PARTY_INCLUDES_START #include <tsl/robin_map.h> @@ -60,7 +61,7 @@ struct CidStoreConfiguration * */ -class CidStore final : public ChunkResolver +class CidStore final : public ChunkResolver, public StatsProvider { public: CidStore(GcManager& Gc); @@ -76,15 +77,17 @@ public: kMayBeMovedInPlace }; - void Initialize(const CidStoreConfiguration& Config); - InsertResult AddChunk(const IoBuffer& ChunkData, const IoHash& RawHash, InsertMode Mode = InsertMode::kMayBeMovedInPlace); - IoBuffer FindChunkByCid(const IoHash& DecompressedId); - bool ContainsChunk(const IoHash& DecompressedId); - void FilterChunks(HashKeySet& InOutChunks); - void Flush(); - void ScrubStorage(ScrubContext& Ctx); - CidStoreSize TotalSize() const; - CidStoreStats Stats() const; + void Initialize(const CidStoreConfiguration& Config); + InsertResult AddChunk(const IoBuffer& ChunkData, const IoHash& RawHash, InsertMode Mode = InsertMode::kMayBeMovedInPlace); + virtual IoBuffer FindChunkByCid(const IoHash& DecompressedId) override; + bool ContainsChunk(const IoHash& DecompressedId); + void FilterChunks(HashKeySet& InOutChunks); + void Flush(); + void ScrubStorage(ScrubContext& Ctx); + CidStoreSize TotalSize() const; + CidStoreStats Stats() const; + + virtual void ReportMetrics(StatsMetrics& Statsd) override; private: struct Impl; diff --git a/src/zenutil/include/zenutil/statsreporter.h b/src/zenutil/include/zenutil/statsreporter.h new file mode 100644 index 000000000..a25e5d353 --- /dev/null +++ b/src/zenutil/include/zenutil/statsreporter.h @@ -0,0 +1,34 @@ +// Copyright Epic Games, Inc. All Rights Reserved. + +#pragma once + +#include <zencore/zencore.h> + +namespace zen { + +class StatsProvider; + +class StatsMetrics +{ +public: + virtual void Increment(std::string_view Metric) = 0; + virtual void Decrement(std::string_view Metric) = 0; + virtual void Count(std::string_view Metric, int64_t CountDelta) = 0; + virtual void Gauge(std::string_view Metric, uint64_t CurrentValue) = 0; + virtual void Meter(std::string_view Metric, uint64_t IncrementValue) = 0; + + // Not (yet) implemented: Set,Timing +protected: + virtual ~StatsMetrics() = default; +}; + +class StatsProvider +{ +public: + virtual void ReportMetrics(StatsMetrics& Statsd) = 0; + +protected: + virtual ~StatsProvider() = default; +}; + +} // namespace zen |