diff options
| author | Stefan Boberg <[email protected]> | 2021-09-30 21:26:21 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-09-30 21:27:27 +0200 |
| commit | 941bcce13fbef35d08fc44a84632625bd7087dc0 (patch) | |
| tree | 68e8d1e8f752940899ca7ae87319b89f8a98c530 /zenserver/testing | |
| parent | structured cache: Rewrote metrics tracking using OperationTiming (diff) | |
| download | zen-941bcce13fbef35d08fc44a84632625bd7087dc0.tar.xz zen-941bcce13fbef35d08fc44a84632625bd7087dc0.zip | |
structured cache: fixed how HEAD requests are handled
the SetSuppressResponseBody() is currently sensitive to ordering and would end up getting called too late to apply
fixes UE-129788, UE-129793
Diffstat (limited to 'zenserver/testing')
| -rw-r--r-- | zenserver/testing/httptest.cpp | 17 | ||||
| -rw-r--r-- | zenserver/testing/httptest.h | 6 |
2 files changed, 21 insertions, 2 deletions
diff --git a/zenserver/testing/httptest.cpp b/zenserver/testing/httptest.cpp index 18d63a6ef..01866a63b 100644 --- a/zenserver/testing/httptest.cpp +++ b/zenserver/testing/httptest.cpp @@ -15,6 +15,23 @@ HttpTestingService::HttpTestingService() HttpVerb::kGet); m_Router.RegisterRoute( + "metrics", + [this](HttpRouterRequest& Req) { + metrics::OperationTiming::Scope _(m_TimingStats); + Req.ServerRequest().WriteResponse(HttpResponseCode::OK); + }, + HttpVerb::kGet); + + m_Router.RegisterRoute( + "get_metrics", + [this](HttpRouterRequest& Req) { + CbObjectWriter Cbo; + EmitSnapshot("requests", m_TimingStats, Cbo); + Req.ServerRequest().WriteResponse(HttpResponseCode::OK, Cbo.Save()); + }, + HttpVerb::kGet); + + m_Router.RegisterRoute( "json", [this](HttpRouterRequest& Req) { CbObjectWriter Obj; diff --git a/zenserver/testing/httptest.h b/zenserver/testing/httptest.h index f55780d05..f7ea0c31c 100644 --- a/zenserver/testing/httptest.h +++ b/zenserver/testing/httptest.h @@ -3,6 +3,7 @@ #pragma once #include <zencore/logging.h> +#include <zencore/stats.h> #include <zenhttp/httpserver.h> #include <atomic> @@ -39,8 +40,9 @@ public: }; private: - HttpRequestRouter m_Router; - std::atomic<uint32_t> m_Counter{0}; + HttpRequestRouter m_Router; + std::atomic<uint32_t> m_Counter{0}; + metrics::OperationTiming m_TimingStats; RwLock m_RwLock; std::unordered_map<uint32_t, Ref<PackageHandler>> m_HandlerMap; |