diff options
| author | Stefan Boberg <[email protected]> | 2023-10-25 12:21:51 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-10-25 12:21:51 +0200 |
| commit | 0b220255724020daea18ddb559f5edf3fdb1621b (patch) | |
| tree | 7809227752c15d90111c4e600d80b59d90ad25d2 /src/zenserver/zenserver.cpp | |
| parent | New rotating file logger that keeps on running regardless of errors (#495) (diff) | |
| download | zen-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/zenserver.cpp')
| -rw-r--r-- | src/zenserver/zenserver.cpp | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/src/zenserver/zenserver.cpp b/src/zenserver/zenserver.cpp index e5346abf0..d7fc2d069 100644 --- a/src/zenserver/zenserver.cpp +++ b/src/zenserver/zenserver.cpp @@ -41,7 +41,6 @@ ZEN_THIRD_PARTY_INCLUDES_START #include <fmt/format.h> #include <asio.hpp> -#include <lua.hpp> ZEN_THIRD_PARTY_INCLUDES_END #include <exception> @@ -197,7 +196,14 @@ ZenServer::Initialize(const ZenServerOptions& ServerOptions, ZenServerState::Zen m_Http->RegisterService(*m_AuthService); m_Http->RegisterService(m_HealthService); + m_Http->RegisterService(m_StatsService); + m_StatsReporter.Initialize(ServerOptions.StatsConfig); + if (ServerOptions.StatsConfig.Enabled) + { + EnqueueStatsReportingTimer(); + } + m_Http->RegisterService(m_StatusService); m_StatusService.RegisterHandler("status", *this); @@ -260,10 +266,12 @@ ZenServer::Initialize(const ZenServerOptions& ServerOptions, ZenServerState::Zen m_Http->RegisterService(*m_ObjStoreService); } +#if ZEN_WITH_VFS m_VfsService = std::make_unique<VfsService>(); m_VfsService->AddService(Ref<ProjectStore>(m_ProjectStore)); m_VfsService->AddService(Ref<ZenCacheStore>(m_CacheStore)); m_Http->RegisterService(*m_VfsService); +#endif ZEN_INFO("initializing GC, enabled '{}', interval {}, lightweight interval {}", ServerOptions.GcConfig.Enabled, @@ -514,6 +522,8 @@ ZenServer::InitializeStructuredCache(const ZenServerOptions& ServerOptions) m_Http->RegisterService(*m_StructuredCacheService); m_Http->RegisterService(*m_UpstreamService); + + m_StatsReporter.AddProvider(m_CacheStore.Get()); } void @@ -598,6 +608,8 @@ ZenServer::Cleanup() m_JobQueue->Stop(); } + m_StatsReporter.Shutdown(); + m_GcScheduler.Shutdown(); m_AdminService.reset(); m_VfsService.reset(); @@ -661,6 +673,20 @@ ZenServer::EnqueueSigIntTimer() } void +ZenServer::EnqueueStatsReportingTimer() +{ + m_StatsReportingTimer.expires_after(std::chrono::milliseconds(500)); + m_StatsReportingTimer.async_wait([this](const asio::error_code& Ec) { + if (!Ec) + { + m_StatsReporter.ReportStats(); + EnqueueStatsReportingTimer(); + } + }); + EnsureIoRunner(); +} + +void ZenServer::CheckStateMarker() { std::filesystem::path StateMarkerPath = m_DataRoot / "state_marker"; |