sapling/eden/fs/telemetry/Tracing.cpp
Chad Austin 65c93484e2 rename tracing to telemetry
Summary: Tracing was not an accurate name for what this directory had become. So rename it to telemetry.

Reviewed By: wez

Differential Revision: D17923303

fbshipit-source-id: fca07e8447d9b9b3ea5d860809a2d377e3c4f9f2
2019-10-15 13:39:41 -07:00

41 lines
1.0 KiB
C++

/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
#include "Tracing.h"
namespace facebook {
namespace eden {
namespace detail {
Tracer globalTracer;
void ThreadLocalTracePoints::flush() {
auto points = globalTracer.tracepoints_.wlock();
auto state = state_.lock();
size_t npoints = std::min(kBufferPoints, state->currNum_);
points->insert(
points->end(),
state->tracePoints_.begin(),
state->tracePoints_.begin() + npoints);
state->currNum_ = 0;
}
folly::RequestToken tracingToken("eden_tracing");
std::vector<CompactTracePoint> Tracer::getAllTracepoints() {
for (auto& tltp : tltp_.accessAllThreads()) {
tltp.flush();
}
auto points = tracepoints_.wlock();
std::sort(points->begin(), points->end(), [](const auto& a, const auto& b) {
return a.timestamp < b.timestamp;
});
return std::move(*points);
}
} // namespace detail
} // namespace eden
} // namespace facebook