aboutsummaryrefslogtreecommitdiff
path: root/src/zenserver/monitoring
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2023-05-02 13:23:42 +0200
committerGitHub <[email protected]>2023-05-02 13:23:42 +0200
commitfc53dd4bd6737f4e1c406f24cd66b4255f383e60 (patch)
tree56bf06028ddae6ed2ff445a78db6a781538949f4 /src/zenserver/monitoring
parentmove auth code from zenserver into zenhttp (#265) (diff)
downloadzen-fc53dd4bd6737f4e1c406f24cd66b4255f383e60.tar.xz
zen-fc53dd4bd6737f4e1c406f24cd66b4255f383e60.zip
move testing and observability code to zenhttp (#266)
Diffstat (limited to 'src/zenserver/monitoring')
-rw-r--r--src/zenserver/monitoring/httpstats.cpp62
-rw-r--r--src/zenserver/monitoring/httpstats.h38
-rw-r--r--src/zenserver/monitoring/httpstatus.cpp62
-rw-r--r--src/zenserver/monitoring/httpstatus.h38
4 files changed, 0 insertions, 200 deletions
diff --git a/src/zenserver/monitoring/httpstats.cpp b/src/zenserver/monitoring/httpstats.cpp
deleted file mode 100644
index 4d985f8c2..000000000
--- a/src/zenserver/monitoring/httpstats.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-// Copyright Epic Games, Inc. All Rights Reserved.
-
-#include "httpstats.h"
-
-namespace zen {
-
-HttpStatsService::HttpStatsService() : m_Log(logging::Get("stats"))
-{
-}
-
-HttpStatsService::~HttpStatsService()
-{
-}
-
-const char*
-HttpStatsService::BaseUri() const
-{
- return "/stats/";
-}
-
-void
-HttpStatsService::RegisterHandler(std::string_view Id, IHttpStatsProvider& Provider)
-{
- RwLock::ExclusiveLockScope _(m_Lock);
- m_Providers.insert_or_assign(std::string(Id), &Provider);
-}
-
-void
-HttpStatsService::UnregisterHandler(std::string_view Id, IHttpStatsProvider& Provider)
-{
- ZEN_UNUSED(Provider);
-
- RwLock::ExclusiveLockScope _(m_Lock);
- m_Providers.erase(std::string(Id));
-}
-
-void
-HttpStatsService::HandleRequest(HttpServerRequest& Request)
-{
- using namespace std::literals;
-
- std::string_view Key = Request.RelativeUri();
-
- switch (Request.RequestVerb())
- {
- case HttpVerb::kHead:
- case HttpVerb::kGet:
- {
- RwLock::SharedLockScope _(m_Lock);
- if (auto It = m_Providers.find(std::string{Key}); It != end(m_Providers))
- {
- return It->second->HandleStatsRequest(Request);
- }
- }
-
- [[fallthrough]];
- default:
- return;
- }
-}
-
-} // namespace zen
diff --git a/src/zenserver/monitoring/httpstats.h b/src/zenserver/monitoring/httpstats.h
deleted file mode 100644
index 732815a9a..000000000
--- a/src/zenserver/monitoring/httpstats.h
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright Epic Games, Inc. All Rights Reserved.
-
-#pragma once
-
-#include <zencore/logging.h>
-#include <zenhttp/httpserver.h>
-
-#include <map>
-
-namespace zen {
-
-struct IHttpStatsProvider
-{
- virtual void HandleStatsRequest(HttpServerRequest& Request) = 0;
-};
-
-class HttpStatsService : public HttpService
-{
-public:
- HttpStatsService();
- ~HttpStatsService();
-
- virtual const char* BaseUri() const override;
- virtual void HandleRequest(HttpServerRequest& Request) override;
- void RegisterHandler(std::string_view Id, IHttpStatsProvider& Provider);
- void UnregisterHandler(std::string_view Id, IHttpStatsProvider& Provider);
-
-private:
- spdlog::logger& m_Log;
- HttpRequestRouter m_Router;
-
- inline spdlog::logger& Log() { return m_Log; }
-
- RwLock m_Lock;
- std::map<std::string, IHttpStatsProvider*> m_Providers;
-};
-
-} // namespace zen \ No newline at end of file
diff --git a/src/zenserver/monitoring/httpstatus.cpp b/src/zenserver/monitoring/httpstatus.cpp
deleted file mode 100644
index 8b10601dd..000000000
--- a/src/zenserver/monitoring/httpstatus.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-// Copyright Epic Games, Inc. All Rights Reserved.
-
-#include "httpstatus.h"
-
-namespace zen {
-
-HttpStatusService::HttpStatusService() : m_Log(logging::Get("status"))
-{
-}
-
-HttpStatusService::~HttpStatusService()
-{
-}
-
-const char*
-HttpStatusService::BaseUri() const
-{
- return "/status/";
-}
-
-void
-HttpStatusService::RegisterHandler(std::string_view Id, IHttpStatusProvider& Provider)
-{
- RwLock::ExclusiveLockScope _(m_Lock);
- m_Providers.insert_or_assign(std::string(Id), &Provider);
-}
-
-void
-HttpStatusService::UnregisterHandler(std::string_view Id, IHttpStatusProvider& Provider)
-{
- ZEN_UNUSED(Provider);
-
- RwLock::ExclusiveLockScope _(m_Lock);
- m_Providers.erase(std::string(Id));
-}
-
-void
-HttpStatusService::HandleRequest(HttpServerRequest& Request)
-{
- using namespace std::literals;
-
- std::string_view Key = Request.RelativeUri();
-
- switch (Request.RequestVerb())
- {
- case HttpVerb::kHead:
- case HttpVerb::kGet:
- {
- RwLock::SharedLockScope _(m_Lock);
- if (auto It = m_Providers.find(std::string{Key}); It != end(m_Providers))
- {
- return It->second->HandleStatusRequest(Request);
- }
- }
-
- [[fallthrough]];
- default:
- return;
- }
-}
-
-} // namespace zen
diff --git a/src/zenserver/monitoring/httpstatus.h b/src/zenserver/monitoring/httpstatus.h
deleted file mode 100644
index b04e45324..000000000
--- a/src/zenserver/monitoring/httpstatus.h
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright Epic Games, Inc. All Rights Reserved.
-
-#pragma once
-
-#include <zencore/logging.h>
-#include <zenhttp/httpserver.h>
-
-#include <map>
-
-namespace zen {
-
-struct IHttpStatusProvider
-{
- virtual void HandleStatusRequest(HttpServerRequest& Request) = 0;
-};
-
-class HttpStatusService : public HttpService
-{
-public:
- HttpStatusService();
- ~HttpStatusService();
-
- virtual const char* BaseUri() const override;
- virtual void HandleRequest(HttpServerRequest& Request) override;
- void RegisterHandler(std::string_view Id, IHttpStatusProvider& Provider);
- void UnregisterHandler(std::string_view Id, IHttpStatusProvider& Provider);
-
-private:
- spdlog::logger& m_Log;
- HttpRequestRouter m_Router;
-
- RwLock m_Lock;
- std::map<std::string, IHttpStatusProvider*> m_Providers;
-
- inline spdlog::logger& Log() { return m_Log; }
-};
-
-} // namespace zen \ No newline at end of file