blob: ff276def0c9ec3f59a6dec3f85c886b77844cc47 (
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
46
47
48
49
50
51
52
53
54
55
56
|
#pragma once
#include <atomic>
#include <base/types.h>
#include <memory>
#include <cstdint>
namespace DB
{
/// Request statistics for connection or dispatcher
class KeeperConnectionStats
{
public:
KeeperConnectionStats()
{
reset();
}
uint64_t getMinLatency() const;
uint64_t getMaxLatency() const;
uint64_t getAvgLatency() const;
uint64_t getLastLatency() const;
uint64_t getPacketsReceived() const;
uint64_t getPacketsSent() const;
void incrementPacketsReceived();
void incrementPacketsSent();
void updateLatency(uint64_t latency_ms);
void reset();
private:
void resetLatency();
void resetRequestCounters();
/// all response with watch response included
std::atomic_uint64_t packets_sent;
/// All user requests
std::atomic_uint64_t packets_received;
/// For consistent with zookeeper measured by millisecond,
/// otherwise maybe microsecond is better
std::atomic_uint64_t total_latency;
std::atomic_uint64_t max_latency;
std::atomic_uint64_t min_latency;
/// last operation latency
std::atomic_uint64_t last_latency;
std::atomic_uint64_t count;
};
}
|