/
sandesh_statistics.h
61 lines (47 loc) · 2.02 KB
/
sandesh_statistics.h
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
57
58
59
60
61
/*
* Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
*/
#ifndef __SANDESH_STATISTICS_H__
#define __SANDESH_STATISTICS_H__
#include <boost/ptr_container/ptr_map.hpp>
#include <sandesh/sandesh_uve_types.h>
class SandeshMessageStatistics {
public:
SandeshMessageStatistics() {}
void UpdateSend(const std::string &msg_name, uint64_t bytes);
void UpdateSendFailed(const std::string &msg_name, uint64_t bytes,
SandeshTxDropReason::type dreason);
void UpdateRecv(const std::string &msg_name, uint64_t bytes);
void UpdateRecvFailed(const std::string &msg_name, uint64_t bytes,
SandeshRxDropReason::type dreason);
void Clear();
// Detail statistics
typedef boost::ptr_map<std::string, SandeshMessageTypeStats>
DetailStatsMap;
typedef std::vector<SandeshMessageTypeStats> DetailStatsList;
void Get(DetailStatsList *v_detail_type_stats,
SandeshMessageStats *detail_agg_stats) const;
void Get(DetailStatsMap *m_detail_type_stats,
SandeshMessageStats *detail_agg_stats) const;
// Basic statistics
typedef std::vector<SandeshMessageTypeBasicStats> BasicStatsList;
void Get(BasicStatsList *v_basic_type_stats,
SandeshMessageBasicStats *basic_agg_stats) const;
private:
void UpdateInternal(const std::string &msg_name,
uint64_t bytes, bool is_tx, bool dropped,
SandeshTxDropReason::type send_dreason,
SandeshRxDropReason::type recv_dreason);
DetailStatsMap detail_type_stats_map_;
SandeshMessageStats detail_agg_stats_;
};
class SandeshEventStatistics {
public:
SandeshEventStatistics() {}
void Update(std::string &event_name, bool enqueue, bool fail);
void Get(std::vector<SandeshStateMachineEvStats> *ev_stats) const;
typedef boost::ptr_map<std::string, SandeshStateMachineEvStats> EventStatsMap;
EventStatsMap event_stats_;
SandeshStateMachineEvStats agg_stats_;
};
#endif // __SANDESH_STATISTICS_H__