diff options
| author | Stefan Boberg <[email protected]> | 2021-10-04 17:54:21 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-10-04 17:54:21 +0200 |
| commit | f4c6f75ed3620e777d8194bf59a24b7d6dc4200a (patch) | |
| tree | 7c3f77c7907e091270847602fc76371755f105ab /zenserver/cache/structuredcache.h | |
| parent | filesystem: Added comment for future optimization opportunities in CreateDire... (diff) | |
| download | zen-f4c6f75ed3620e777d8194bf59a24b7d6dc4200a.tar.xz zen-f4c6f75ed3620e777d8194bf59a24b7d6dc4200a.zip | |
stats: Implemented new stats endpoint
Stats are exposed under /stats/{id}, so for example structured cache stats are exposed under /stats/z$
The separate endpoint makes it easier to separate request handling to ensure stats/status endpoints still respond if the regular request queue is somehow saturated or otherwise not behaving
There is also a /status endpoint which is similar and is targeted towards lightweight health monitoring
Diffstat (limited to 'zenserver/cache/structuredcache.h')
| -rw-r--r-- | zenserver/cache/structuredcache.h | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/zenserver/cache/structuredcache.h b/zenserver/cache/structuredcache.h index a360878bd..703e24ed3 100644 --- a/zenserver/cache/structuredcache.h +++ b/zenserver/cache/structuredcache.h @@ -5,6 +5,9 @@ #include <zencore/stats.h> #include <zenhttp/httpserver.h> +#include "monitoring/httpstats.h" +#include "monitoring/httpstatus.h" + #include <memory> namespace spdlog { @@ -47,12 +50,14 @@ enum class CachePolicy : uint8_t; * */ -class HttpStructuredCacheService : public zen::HttpService +class HttpStructuredCacheService : public HttpService, public IHttpStatsProvider, public IHttpStatusProvider { public: HttpStructuredCacheService(ZenCacheStore& InCacheStore, - zen::CasStore& InCasStore, - zen::CidStore& InCidStore, + CasStore& InCasStore, + CidStore& InCidStore, + HttpStatsService& StatsService, + HttpStatusService& StatusService, std::unique_ptr<UpstreamCache> UpstreamCache); ~HttpStructuredCacheService(); @@ -86,13 +91,16 @@ private: void HandleGetCachePayload(zen::HttpServerRequest& Request, const CacheRef& Ref, CachePolicy Policy); void HandlePutCachePayload(zen::HttpServerRequest& Request, const CacheRef& Ref, CachePolicy Policy); void HandleCacheBucketRequest(zen::HttpServerRequest& Request, std::string_view Bucket); - void HandleStatusRequest(zen::HttpServerRequest& Request); + virtual void HandleStatsRequest(zen::HttpServerRequest& Request) override; + virtual void HandleStatusRequest(zen::HttpServerRequest& Request) override; spdlog::logger& Log() { return m_Log; } spdlog::logger& m_Log; - zen::ZenCacheStore& m_CacheStore; - zen::CasStore& m_CasStore; - zen::CidStore& m_CidStore; + ZenCacheStore& m_CacheStore; + HttpStatsService& m_StatsService; + HttpStatusService& m_StatusService; + CasStore& m_CasStore; + CidStore& m_CidStore; std::unique_ptr<UpstreamCache> m_UpstreamCache; uint64_t m_LastScrubTime = 0; metrics::OperationTiming m_HttpRequests; |