sapling/eden/fs/inodes/RequestContext.cpp
Saurabh Singh 0b9c2fb148 telemetry: switch to using quantile stats instead of histograms
Summary:
Histograms are memory intensive and require specifying fixed buckets for
instantiation.

Reviewed By: chadaustin

Differential Revision: D26315631

fbshipit-source-id: 6ce5459b8c1c6c25d84285baf96df55ce9119b1a
2021-02-14 16:37:08 -08:00

62 lines
1.7 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 "eden/fs/inodes/RequestContext.h"
#include <folly/logging/xlog.h>
#include "eden/fs/notifications/Notifications.h"
#include "eden/fs/telemetry/RequestMetricsScope.h"
#include "eden/fs/utils/SystemError.h"
using namespace std::chrono;
namespace facebook::eden {
void RequestContext::startRequest(
EdenStats* stats,
ChannelThreadStats::StatPtr stat,
std::shared_ptr<RequestMetricsScope::LockedRequestWatchList>&
requestWatches) {
startTime_ = steady_clock::now();
XDCHECK(latencyStat_ == nullptr);
latencyStat_ = stat;
stats_ = stats;
channelThreadLocalStats_ = requestWatches;
if (channelThreadLocalStats_) {
requestMetricsScope_ = RequestMetricsScope(channelThreadLocalStats_.get());
}
}
void RequestContext::finishRequest() {
const auto now = steady_clock::now();
const auto diff = now - startTime_;
const auto diff_us = duration_cast<microseconds>(diff);
const auto diff_ns = duration_cast<nanoseconds>(diff);
stats_->getChannelStatsForCurrentThread().recordLatency(
latencyStat_, diff_us);
latencyStat_ = nullptr;
stats_ = nullptr;
if (channelThreadLocalStats_) {
{ auto temp = std::move(requestMetricsScope_); }
channelThreadLocalStats_.reset();
}
if (auto pid = getClientPid(); pid.has_value()) {
if (getEdenTopStats().didImportFromBackingStore()) {
auto type = ProcessAccessLog::AccessType::FsChannelBackingStoreImport;
pal_.recordAccess(*pid, type);
}
pal_.recordDuration(*pid, diff_ns);
}
}
} // namespace facebook::eden