/proc/self/cwd/source/extensions/filters/network/mongo_proxy/mongo_stats.h
Line | Count | Source |
1 | | #pragma once |
2 | | |
3 | | #include <memory> |
4 | | #include <string> |
5 | | #include <vector> |
6 | | |
7 | | #include "envoy/stats/scope.h" |
8 | | |
9 | | #include "source/common/stats/symbol_table.h" |
10 | | #include "source/common/stats/utility.h" |
11 | | |
12 | | namespace Envoy { |
13 | | namespace Extensions { |
14 | | namespace NetworkFilters { |
15 | | namespace MongoProxy { |
16 | | |
17 | | class MongoStats { |
18 | | public: |
19 | | MongoStats(Stats::Scope& scope, absl::string_view prefix, |
20 | | const std::vector<std::string>& commands); |
21 | | |
22 | | void incCounter(const Stats::ElementVec& names); |
23 | | void recordHistogram(const Stats::ElementVec& names, Stats::Histogram::Unit unit, |
24 | | uint64_t sample); |
25 | | |
26 | | /** |
27 | | * Finds or creates a StatName by string, taking a global lock if needed. |
28 | | * |
29 | | * TODO(jmarantz): Potential perf issue here with mutex contention for names |
30 | | * that have not been remembered as builtins in the constructor. |
31 | | */ |
32 | 1.96k | Stats::StatName getBuiltin(const std::string& str, Stats::StatName fallback) { |
33 | 1.96k | return stat_name_set_->getBuiltin(str, fallback); |
34 | 1.96k | } |
35 | | |
36 | | private: |
37 | | Stats::ElementVec addPrefix(const Stats::ElementVec& names); |
38 | | |
39 | | Stats::Scope& scope_; |
40 | | Stats::StatNameSetPtr stat_name_set_; |
41 | | |
42 | | public: |
43 | | const Stats::StatName prefix_; |
44 | | const Stats::StatName callsite_; |
45 | | const Stats::StatName cmd_; |
46 | | const Stats::StatName collection_; |
47 | | const Stats::StatName multi_get_; |
48 | | const Stats::StatName reply_num_docs_; |
49 | | const Stats::StatName reply_size_; |
50 | | const Stats::StatName reply_time_ms_; |
51 | | const Stats::StatName time_ms_; |
52 | | const Stats::StatName query_; |
53 | | const Stats::StatName scatter_get_; |
54 | | const Stats::StatName total_; |
55 | | const Stats::StatName unknown_command_; |
56 | | }; |
57 | | using MongoStatsSharedPtr = std::shared_ptr<MongoStats>; |
58 | | |
59 | | } // namespace MongoProxy |
60 | | } // namespace NetworkFilters |
61 | | } // namespace Extensions |
62 | | } // namespace Envoy |