From fb6426127354415505dbedacd63b3a16116dac2f Mon Sep 17 00:00:00 2001 From: Dan Engelbrecht Date: Fri, 22 Aug 2025 18:16:09 +0200 Subject: clean up trace options parsing (#473) * clean up trace command line options explicitly shut down worker pools * some additional startup trace scopes --- src/zenserver/admin/admin.cpp | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'src/zenserver/admin/admin.cpp') diff --git a/src/zenserver/admin/admin.cpp b/src/zenserver/admin/admin.cpp index 8c2e6d771..f6ad14422 100644 --- a/src/zenserver/admin/admin.cpp +++ b/src/zenserver/admin/admin.cpp @@ -594,31 +594,35 @@ HttpAdminService::HttpAdminService(GcScheduler& Scheduler, [this](HttpRouterRequest& Req) { HttpServerRequest& HttpReq = Req.ServerRequest(); const HttpServerRequest::QueryParams Params = HttpReq.GetQueryParams(); - TraceType Type = TraceType::None; - std::string HostOrPath; - if (auto Param = Params.GetValue("file"); Param.empty() == false) + TraceOptions TraceOptions; + + if (!IsTracing()) { - Type = TraceType::File; - HostOrPath = Param; + TraceInit("zenserver"); } - if (auto Param = Params.GetValue("host"); Param.empty() == false) + + if (auto Channels = Params.GetValue("channels"); Channels.empty() == false) { - Type = TraceType::Network; - HostOrPath = Param; + TraceOptions.Channels = Channels; } - if (Type == TraceType::None) + + if (auto File = Params.GetValue("file"); File.empty() == false) { - return Req.ServerRequest().WriteResponse(HttpResponseCode::BadRequest, - HttpContentType::kText, - "Invalid trace type, use `file` or `host`"sv); + TraceOptions.File = File; } - if (IsTracing()) + else if (auto Host = Params.GetValue("host"); Host.empty() == false) + { + TraceOptions.Host = Host; + } + else { return Req.ServerRequest().WriteResponse(HttpResponseCode::BadRequest, HttpContentType::kText, - "Tracing is already enabled"sv); + "Invalid trace type, use `file` or `host`"sv); } - TraceStart("zenserver", HostOrPath.c_str(), Type); + + TraceConfigure(TraceOptions); + return Req.ServerRequest().WriteResponse(HttpResponseCode::OK, HttpContentType::kText, "Tracing started"); }, HttpVerb::kPost); -- cgit v1.2.3