LCOV - code coverage report
Current view: top level - source/common/stats - stats_matcher_impl.h (source / functions) Hit Total Coverage
Test: coverage.dat Lines: 7 11 63.6 %
Date: 2024-01-05 06:35:25 Functions: 3 4 75.0 %

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include <string>
       4             : 
       5             : #include "envoy/common/optref.h"
       6             : #include "envoy/config/metrics/v3/stats.pb.h"
       7             : #include "envoy/stats/stats_matcher.h"
       8             : 
       9             : #include "source/common/common/matchers.h"
      10             : #include "source/common/protobuf/protobuf.h"
      11             : #include "source/common/stats/symbol_table.h"
      12             : 
      13             : #include "absl/strings/string_view.h"
      14             : 
      15             : namespace Envoy {
      16             : namespace Stats {
      17             : 
      18             : /**
      19             :  * Supplies a stats matcher.
      20             :  */
      21             : class StatsMatcherImpl : public StatsMatcher {
      22             : public:
      23             :   StatsMatcherImpl(const envoy::config::metrics::v3::StatsConfig& config,
      24             :                    SymbolTable& symbol_table);
      25             : 
      26             :   // Default constructor simply allows everything.
      27          98 :   StatsMatcherImpl() = default;
      28             : 
      29             :   // StatsMatcher
      30           0 :   bool rejects(StatName name) const override {
      31           0 :     FastResult fast_result = fastRejects(name);
      32           0 :     return fast_result == FastResult::Rejects || slowRejects(fast_result, name);
      33           0 :   }
      34             :   FastResult fastRejects(StatName name) const override;
      35             :   bool slowRejects(FastResult, StatName name) const override;
      36       51383 :   bool acceptsAll() const override {
      37       51383 :     return is_inclusive_ && matchers_.empty() && prefixes_.empty();
      38       51383 :   }
      39      106454 :   bool rejectsAll() const override {
      40      106454 :     return !is_inclusive_ && matchers_.empty() && prefixes_.empty();
      41      106454 :   }
      42             : 
      43             : private:
      44             :   void optimizeLastMatcher();
      45             :   bool fastRejectMatch(StatName name) const;
      46             :   bool slowRejectMatch(StatName name) const;
      47             : 
      48             :   // Bool indicating whether or not the StatsMatcher is including or excluding stats by default. See
      49             :   // StatsMatcherImpl::rejects() for much more detail.
      50             :   bool is_inclusive_{true};
      51             : 
      52             :   OptRef<SymbolTable> symbol_table_;
      53             :   std::unique_ptr<StatNamePool> stat_name_pool_;
      54             : 
      55             :   std::vector<Matchers::StringMatcherImpl<envoy::type::matcher::v3::StringMatcher>> matchers_;
      56             :   std::vector<StatName> prefixes_;
      57             : };
      58             : 
      59             : } // namespace Stats
      60             : } // namespace Envoy

Generated by: LCOV version 1.15