aboutsummaryrefslogtreecommitdiff
path: root/src/zenhttp/httpserver.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2026-03-11 22:28:31 +0100
committerStefan Boberg <[email protected]>2026-03-11 22:28:31 +0100
commit69813b07d031b0ea6db3c6bc21ef6c7d4f547ae4 (patch)
tree5bcc4950d2d01d27a03404e43e4fb643b61831bf /src/zenhttp/httpserver.cpp
parentadd basic HTTPS support for http.sys (diff)
parentMerge branch 'main' into sb/compute-scheduler (diff)
downloadzen-69813b07d031b0ea6db3c6bc21ef6c7d4f547ae4.tar.xz
zen-69813b07d031b0ea6db3c6bc21ef6c7d4f547ae4.zip
Merge branch 'sb/compute-scheduler' of https://github.ol.epicgames.net/ue-foundation/zen into sb/compute-scheduler
Diffstat (limited to 'src/zenhttp/httpserver.cpp')
-rw-r--r--src/zenhttp/httpserver.cpp45
1 files changed, 41 insertions, 4 deletions
diff --git a/src/zenhttp/httpserver.cpp b/src/zenhttp/httpserver.cpp
index 029f7be1b..1a0018908 100644
--- a/src/zenhttp/httpserver.cpp
+++ b/src/zenhttp/httpserver.cpp
@@ -28,6 +28,7 @@
#include <zencore/thread.h>
#include <zenhttp/packageformat.h>
#include <zentelemetry/otlptrace.h>
+#include <zentelemetry/stats.h>
#include <charconv>
#include <mutex>
@@ -1097,6 +1098,39 @@ HttpServer::SetHttpRequestFilter(IHttpRequestFilter* RequestFilter)
OnSetHttpRequestFilter(RequestFilter);
}
+CbObject
+HttpServer::CollectStats()
+{
+ CbObjectWriter Cbo;
+
+ metrics::EmitSnapshot("requests", m_RequestMeter, Cbo);
+
+ Cbo.BeginObject("bytes");
+ {
+ Cbo << "received" << GetTotalBytesReceived();
+ Cbo << "sent" << GetTotalBytesSent();
+ }
+ Cbo.EndObject();
+
+ Cbo.BeginObject("websockets");
+ {
+ Cbo << "active_connections" << GetActiveWebSocketConnectionCount();
+ Cbo << "frames_received" << m_WsFramesReceived.load(std::memory_order_relaxed);
+ Cbo << "frames_sent" << m_WsFramesSent.load(std::memory_order_relaxed);
+ Cbo << "bytes_received" << m_WsBytesReceived.load(std::memory_order_relaxed);
+ Cbo << "bytes_sent" << m_WsBytesSent.load(std::memory_order_relaxed);
+ }
+ Cbo.EndObject();
+
+ return Cbo.Save();
+}
+
+void
+HttpServer::HandleStatsRequest(HttpServerRequest& Request)
+{
+ Request.WriteResponse(HttpResponseCode::OK, CollectStats());
+}
+
//////////////////////////////////////////////////////////////////////////
HttpRpcHandler::HttpRpcHandler()
@@ -1121,10 +1155,13 @@ CreateHttpServerClass(const std::string_view ServerClass, const HttpServerConfig
if (ServerClass == "asio"sv)
{
ZEN_INFO("using asio HTTP server implementation")
- return CreateHttpAsioServer(AsioConfig{.ThreadCount = Config.ThreadCount,
- .ForceLoopback = Config.ForceLoopback,
- .IsDedicatedServer = Config.IsDedicatedServer,
- .UnixSocketPath = Config.UnixSocketPath});
+ return CreateHttpAsioServer(AsioConfig {
+ .ThreadCount = Config.ThreadCount, .ForceLoopback = Config.ForceLoopback, .IsDedicatedServer = Config.IsDedicatedServer,
+ .UnixSocketPath = Config.UnixSocketPath,
+#if ZEN_USE_OPENSSL
+ .HttpsPort = Config.HttpsPort, .CertFile = Config.CertFile, .KeyFile = Config.KeyFile,
+#endif
+ });
}
#if ZEN_WITH_HTTPSYS
else if (ServerClass == "httpsys"sv)