20 #include <ripple/basics/BasicConfig.h>
21 #include <ripple/basics/impl/PerfLogImp.h>
22 #include <ripple/beast/core/CurrentThreadName.h>
23 #include <ripple/beast/utility/Journal.h>
24 #include <ripple/json/json_writer.h>
25 #include <ripple/json/to_string.h>
26 #include <boost/optional.hpp>
49 auto const inserted =
rpc_.emplace(label,
Rpc()).second;
60 for (
auto const& [jobType, jobTypeInfo] : jobTypes)
62 auto const inserted =
jq_.emplace(jobType,
Jq(jobTypeInfo.name())).second;
78 for (
auto const& proc : rpc_)
83 [&proc]() ->boost::optional<Counters::Rpc::Sync> {
85 if (!proc.second.sync.started &&
86 !proc.second.sync.finished &&
87 !proc.second.sync.errored)
91 return proc.second.sync;
105 rpcobj[proc.first] = p;
116 rpcobj[jss::total] = totalRpcJson;
122 for (
auto const& proc : jq_)
127 [&proc]() ->boost::optional<Counters::Jq::Sync> {
129 if (!proc.second.sync.queued &&
130 !proc.second.sync.started &&
131 !proc.second.sync.finished)
135 return proc.second.sync;
147 sync->queuedDuration.count());
150 sync->runningDuration.count());
153 jqobj[proc.second.label] = j;
166 jqobj[jss::total] = totalJqJson;
172 counters[jss::rpc] = rpcobj;
173 counters[jss::job_queue] = jqobj;
183 auto const jobs = [
this]{
188 for (
auto const& j : jobs)
193 auto const e = jq_.find(j.first);
200 jobj[jss::job] = e->second.label;
202 std::chrono::duration_cast<microseconds>(
203 present - j.second).count());
211 methods.
reserve(methods_.size());
212 for (
auto const& m : methods_)
215 for (
auto m : methods)
218 methodobj[jss::method] = m.first;
220 std::chrono::duration_cast<microseconds>(
221 present - m.second).count());
222 methodsArray.
append(methodobj);
226 current[jss::jobs] = jobsArray;
227 current[jss::methods] = methodsArray;
242 if (!boost::filesystem::is_directory(logDir))
244 boost::system::error_code ec;
245 boost::filesystem::create_directories(logDir, ec);
248 JLOG(
j_.
fatal()) <<
"Unable to create performance log "
249 "directory " << logDir <<
": " << ec.message();
259 JLOG(
j_.
fatal()) <<
"Unable to open performance log " <<
343 ++counter->second.sync.started;
347 counter->first.c_str(),
369 startTime = e->second.second;
379 ++counter->second.sync.finished;
381 ++counter->second.sync.errored;
382 counter->second.sync.duration +=
383 std::chrono::duration_cast<microseconds>(
397 ++counter->second.sync.queued;
414 ++counter->second.sync.started;
415 counter->second.sync.queuedDuration += dur;
434 ++counter->second.sync.finished;
435 counter->second.sync.runningDuration += dur;
499 set(perfLog,
"perf_log", section);
502 setup.
perfLog = boost::filesystem::path(perfLog);
503 if (setup.
perfLog.is_relative())
505 setup.
perfLog = boost::filesystem::absolute(
523 return std::make_unique<PerfLogImp>(
524 setup, parent, journal, std::move(signalStop));