Line data Source code
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_redirect) \ 25 : COUNTER(rq_reset_after_downstream_response_started) \ 26 : COUNTER(rq_total) \ 27 : STATNAME(retry) 28 : 29 : MAKE_STAT_NAMES_STRUCT(StatNames, ALL_ROUTER_STATS); 30 : 31 : /** 32 : * Captures router-related structures with cardinality of one per server. 33 : */ 34 : class ContextImpl : public Context { 35 : public: 36 : explicit ContextImpl(Stats::SymbolTable& symbol_table); 37 481 : ~ContextImpl() override = default; 38 : 39 350 : const StatNames& statNames() const override { return stat_names_; } 40 1278 : const VirtualClusterStatNames& virtualClusterStatNames() const override { 41 1278 : return virtual_cluster_stat_names_; 42 1278 : } 43 5 : const RouteStatNames& routeStatNames() const override { return route_stat_names_; } 44 251 : GenericConnPoolFactory& genericConnPoolFactory() override { 45 251 : ASSERT(generic_conn_pool_factory_ != nullptr); 46 251 : return *generic_conn_pool_factory_; 47 251 : } 48 : 49 : private: 50 : const StatNames stat_names_; 51 : const RouteStatNames route_stat_names_; 52 : const VirtualClusterStatNames virtual_cluster_stat_names_; 53 : GenericConnPoolFactory* generic_conn_pool_factory_; 54 : }; 55 : 56 : class RouteStatsContextImpl : public RouteStatsContext { 57 : public: 58 : RouteStatsContextImpl(Stats::Scope& scope, const RouteStatNames& route_stat_names, 59 : const Stats::StatName& vhost_stat_name, const std::string& stat_prefix); 60 : 61 5 : ~RouteStatsContextImpl() override = default; 62 : 63 0 : Stats::StatName statName() const override { return route_stat_name_; } 64 0 : const RouteStats& stats() const override { return route_stats_; } 65 : 66 : private: 67 : const Stats::StatNameManagedStorage route_stat_name_storage_; 68 : Stats::ScopeSharedPtr route_stats_scope_; 69 : Stats::StatName route_stat_name_; 70 : RouteStats route_stats_; 71 : }; 72 : 73 : } // namespace Router 74 : } // namespace Envoy