blob: bdf4e87b1f56251fb3d8f4ba788865d172e22911 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include <cstdint>
#include <optional>
namespace storage {
/*
* Stats for active operations at service layer
*/
class ActiveOperationsStats
{
uint64_t _size_samples;
uint64_t _total_size;
uint32_t _active_size;
std::optional<uint32_t> _min_size;
std::optional<uint32_t> _max_size;
uint64_t _latency_samples;
double _total_latency;
std::optional<double> _min_latency;
std::optional<double> _max_latency;
void update_size() noexcept;
public:
ActiveOperationsStats() noexcept;
~ActiveOperationsStats();
ActiveOperationsStats& operator-=(const ActiveOperationsStats& rhs) noexcept;
void merge(const ActiveOperationsStats& rhs) noexcept;
void operation_started() noexcept;
void operation_done(double latency) noexcept;
void reset_min_max() noexcept;
uint64_t get_size_samples() const noexcept { return _size_samples; }
uint64_t get_latency_samples() const noexcept { return _latency_samples; }
uint64_t get_total_size() const noexcept { return _total_size; }
uint32_t get_active_size() const noexcept { return _active_size; }
double get_total_latency() const noexcept { return _total_latency; }
const std::optional<uint32_t>& get_min_size() const noexcept { return _min_size; }
const std::optional<uint32_t>& get_max_size() const noexcept { return _max_size; }
const std::optional<double>& get_min_latency() const noexcept { return _min_latency; }
const std::optional<double>& get_max_latency() const noexcept { return _max_latency; }
};
}
|