/proc/self/cwd/source/common/router/context_impl.h
Line | Count | Source (jump to first uncovered line) |
1 | | #pragma once |
2 | | |
3 | | #include "envoy/router/context.h" |
4 | | #include "envoy/router/router.h" |
5 | | #include "envoy/stats/stats_macros.h" |
6 | | |
7 | | #include "source/common/common/assert.h" |
8 | | |
9 | | namespace Envoy { |
10 | | namespace Router { |
11 | | |
12 | | /** |
13 | | * All router filter stats. @see stats_macros.h |
14 | | */ |
15 | | #define ALL_ROUTER_STATS(COUNTER, GAUGE, HISTOGRAM, TEXT_READOUT, STATNAME) \ |
16 | | COUNTER(no_cluster) \ |
17 | | COUNTER(no_route) \ |
18 | | COUNTER(passthrough_internal_redirect_bad_location) \ |
19 | | COUNTER(passthrough_internal_redirect_no_route) \ |
20 | | COUNTER(passthrough_internal_redirect_predicate) \ |
21 | | COUNTER(passthrough_internal_redirect_too_many_redirects) \ |
22 | | COUNTER(passthrough_internal_redirect_unsafe_scheme) \ |
23 | | COUNTER(rq_direct_response) \ |
24 | | COUNTER(rq_overload_local_reply) \ |
25 | | COUNTER(rq_redirect) \ |
26 | | COUNTER(rq_reset_after_downstream_response_started) \ |
27 | | COUNTER(rq_total) \ |
28 | | STATNAME(retry) |
29 | | |
30 | | MAKE_STAT_NAMES_STRUCT(StatNames, ALL_ROUTER_STATS); |
31 | | |
32 | | /** |
33 | | * Captures router-related structures with cardinality of one per server. |
34 | | */ |
35 | | class ContextImpl : public Context { |
36 | | public: |
37 | | explicit ContextImpl(Stats::SymbolTable& symbol_table); |
38 | 26.5k | ~ContextImpl() override = default; |
39 | | |
40 | 4.95k | const StatNames& statNames() const override { return stat_names_; } |
41 | 30.1k | const VirtualClusterStatNames& virtualClusterStatNames() const override { |
42 | 30.1k | return virtual_cluster_stat_names_; |
43 | 30.1k | } |
44 | 31.8k | const RouteStatNames& routeStatNames() const override { return route_stat_names_; } |
45 | 1.81k | GenericConnPoolFactory& genericConnPoolFactory() override { |
46 | 1.81k | ASSERT(generic_conn_pool_factory_ != nullptr); |
47 | 1.81k | return *generic_conn_pool_factory_; |
48 | 1.81k | } |
49 | | |
50 | | private: |
51 | | const StatNames stat_names_; |
52 | | const RouteStatNames route_stat_names_; |
53 | | const VirtualClusterStatNames virtual_cluster_stat_names_; |
54 | | GenericConnPoolFactory* generic_conn_pool_factory_; |
55 | | }; |
56 | | |
57 | | class RouteStatsContextImpl : public RouteStatsContext { |
58 | | public: |
59 | | RouteStatsContextImpl(Stats::Scope& scope, const RouteStatNames& route_stat_names, |
60 | | const Stats::StatName& vhost_stat_name, const std::string& stat_prefix); |
61 | | |
62 | 31.8k | ~RouteStatsContextImpl() override = default; |
63 | | |
64 | 0 | Stats::StatName statName() const override { return route_stat_name_; } |
65 | 0 | const RouteStats& stats() const override { return route_stats_; } |
66 | | |
67 | | private: |
68 | | const Stats::StatNameManagedStorage route_stat_name_storage_; |
69 | | Stats::ScopeSharedPtr route_stats_scope_; |
70 | | Stats::StatName route_stat_name_; |
71 | | RouteStats route_stats_; |
72 | | }; |
73 | | |
74 | | } // namespace Router |
75 | | } // namespace Envoy |