ztsdb
stats.hpp
1 // (C) 2016 Leonardo Silvestri
2 //
3 // This file is part of ztsdb.
4 //
5 // ztsdb is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // ztsdb is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with ztsdb. If not, see <http://www.gnu.org/licenses/>.
17 
18 
19 #ifndef STATS_HPP
20 #define STATS_HPP
21 
22 
23 #include <cstdint>
24 #include <atomic>
25 
26 
27 namespace zcore {
28 
29  struct NetStats {
30  NetStats() { reset(); }
31 
32  std::atomic_uint_fast64_t nbInConn;
33  std::atomic_uint_fast64_t nbOutConn;
34  std::atomic_uint_fast64_t nbCloseInConn;
35  std::atomic_uint_fast64_t nbCloseOutConn;
36  std::atomic_uint_fast64_t nbOutBuffers;
37  std::atomic_uint_fast64_t nbSendFail;
38  std::atomic_uint_fast64_t nbInBuffers;
39  std::atomic_uint_fast64_t nbInBuffersDrop;
40  std::atomic_uint_fast64_t bytesTimedOut;
41  std::atomic_uint_fast64_t nbFailInCtx;
42  std::atomic_uint_fast64_t nbReadFail;
43  std::atomic_uint_fast64_t nbInMalformed;
44  std::atomic_uint_fast64_t readbuflistmax;
45 
46  inline void reset() {
47  nbInConn.store(0);
48  nbOutConn.store(0);
49  nbCloseInConn.store(0);
50  nbCloseOutConn.store(0);
51  nbOutBuffers.store(0);
52  nbSendFail.store(0);
53  nbInBuffers.store(0);
54  bytesTimedOut.store(0);
55  nbInBuffersDrop.store(0);
56  nbFailInCtx.store(0);
57  nbReadFail.store(0);
58  nbInMalformed.store(0);
59  readbuflistmax.store(0);
60  }
61  };
62 
63 
64  struct MsgStats {
65  MsgStats() { reset(); }
66 
67  std::atomic_uint_fast64_t bytesOutREQ;
68  std::atomic_uint_fast64_t bytesOutRSP;
69  std::atomic_uint_fast64_t bytesInREQ;
70  std::atomic_uint_fast64_t bytesInRSP;
71  std::atomic_uint_fast64_t bytesAppend;
72  std::atomic_uint_fast64_t bytesAppendVector;
73  std::atomic_uint_fast64_t nbInREQ;
74  std::atomic_uint_fast64_t nbInRSP;
75  std::atomic_uint_fast64_t nbAppend;
76  std::atomic_uint_fast64_t nbAppendVector;
77  std::atomic_uint_fast64_t nbAppendFail;
78  std::atomic_uint_fast64_t nbAppendVectorFail;
79 
80  inline void reset() {
81  bytesOutREQ.store(0);
82  bytesOutRSP.store(0);
83  bytesInREQ.store(0);
84  bytesInRSP.store(0);
85  bytesAppend.store(0);
86  bytesAppendVector.store(0);
87  nbInREQ.store(0);
88  nbInRSP.store(0);
89  nbAppend.store(0);
90  nbAppendVector.store(0);
91  nbAppendFail.store(0);
92  nbAppendVectorFail.store(0);
93  }
94  };
95 
96  struct CtxStats {
97  CtxStats() { reset(); }
98 
99  std::atomic_uint_fast64_t nbOutREQ;
100  std::atomic_uint_fast64_t nbOutRSP;
101  std::atomic_uint_fast64_t nbInREQ;
102  std::atomic_uint_fast64_t nbInRSP;
103  std::atomic_uint_fast64_t nbAppend;
104  std::atomic_uint_fast64_t nbAppendVector;
105  std::atomic_uint_fast64_t bytesOutREQ;
106  std::atomic_uint_fast64_t bytesOutRSP;
107  std::atomic_uint_fast64_t bytesInREQ;
108  std::atomic_uint_fast64_t bytesInRSP;
109  std::atomic_uint_fast64_t bytesAppend;
110  std::atomic_uint_fast64_t bytesAppendVector;
111 
112  inline void reset() {
113  nbOutREQ.store(0);
114  nbOutRSP.store(0);
115  nbInREQ.store(0);
116  nbInRSP.store(0);
117  nbAppend.store(0);
118  nbAppendVector.store(0);
119  bytesOutREQ.store(0);
120  bytesOutRSP.store(0);
121  bytesInREQ.store(0);
122  bytesInRSP.store(0);
123  bytesAppend.store(0);
124  bytesAppendVector.store(0);
125  }
126  };
127 }
128 
129 
130 #endif
zcore::CtxStats
Definition: stats.hpp:96
zcore::NetStats
Definition: stats.hpp:29
zcore::MsgStats
Definition: stats.hpp:64