Coverage Report

Created: 2024-09-19 09:45

/proc/self/cwd/source/common/stats/timespan_impl.h
Line
Count
Source
1
#pragma once
2
3
#include "envoy/common/time.h"
4
#include "envoy/stats/histogram.h"
5
#include "envoy/stats/stats.h"
6
#include "envoy/stats/timespan.h"
7
8
namespace Envoy {
9
namespace Stats {
10
11
/**
12
 * An individual timespan that flushes its measured value to the histogram on completion.
13
 * The start time is captured on construction. The timespan must be
14
 * completed via complete() for it to be stored. If the timespan is deleted this will be treated as
15
 * a cancellation. The target histogram must represent a quantity of time.
16
 */
17
class HistogramCompletableTimespanImpl : public CompletableTimespan {
18
public:
19
  HistogramCompletableTimespanImpl(Histogram& histogram, TimeSource& time_source);
20
21
  // Stats::CompletableTimespan
22
  std::chrono::milliseconds elapsed() const override;
23
  void complete() override;
24
25
private:
26
  void ensureTimeHistogram(const Histogram& histogram) const;
27
14.5k
  template <typename TimeUnit> TimeUnit elapsedDuration() const {
28
14.5k
    return std::chrono::duration_cast<TimeUnit>(time_source_.monotonicTime() - start_);
29
14.5k
  }
std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000l> > Envoy::Stats::HistogramCompletableTimespanImpl::elapsedDuration<std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000l> > >() const
Line
Count
Source
27
14.5k
  template <typename TimeUnit> TimeUnit elapsedDuration() const {
28
14.5k
    return std::chrono::duration_cast<TimeUnit>(time_source_.monotonicTime() - start_);
29
14.5k
  }
Unexecuted instantiation: std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000l> > Envoy::Stats::HistogramCompletableTimespanImpl::elapsedDuration<std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000l> > >() const
30
  uint64_t tickCount() const;
31
32
  TimeSource& time_source_;
33
  Histogram& histogram_;
34
  const MonotonicTime start_;
35
};
36
37
} // namespace Stats
38
} // namespace Envoy