LCOV - code coverage report
Current view: top level - source/common/stats - null_text_readout.h (source / functions) Hit Total Coverage
Test: coverage.dat Lines: 4 16 25.0 %
Date: 2024-01-05 06:35:25 Functions: 2 11 18.2 %

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include "envoy/stats/stats.h"
       4             : 
       5             : #include "source/common/stats/metric_impl.h"
       6             : 
       7             : namespace Envoy {
       8             : namespace Stats {
       9             : 
      10             : /**
      11             :  * Null text readout implementation.
      12             :  * No-ops on all calls and requires no underlying metric or data.
      13             :  */
      14             : class NullTextReadoutImpl : public MetricImpl<TextReadout> {
      15             : public:
      16             :   explicit NullTextReadoutImpl(SymbolTable& symbol_table)
      17          98 :       : MetricImpl<TextReadout>(symbol_table), symbol_table_(symbol_table) {}
      18          98 :   ~NullTextReadoutImpl() override {
      19           0 :     // MetricImpl must be explicitly cleared() before destruction, otherwise it
      20           0 :     // will not be able to access the SymbolTable& to free the symbols. An RAII
      21           0 :     // alternative would be to store the SymbolTable reference in the
      22           0 :     // MetricImpl, costing 8 bytes per stat.
      23          98 :     MetricImpl::clear(symbol_table_);
      24          98 :   }
      25             : 
      26           0 :   void set(absl::string_view) override {}
      27           0 :   std::string value() const override { return {}; }
      28             : 
      29             :   // Metric
      30           0 :   bool used() const override { return false; }
      31           0 :   bool hidden() const override { return false; }
      32           0 :   SymbolTable& symbolTable() override { return symbol_table_; }
      33             : 
      34             :   // RefcountInterface
      35           0 :   void incRefCount() override { refcount_helper_.incRefCount(); }
      36           0 :   bool decRefCount() override { return refcount_helper_.decRefCount(); }
      37           0 :   uint32_t use_count() const override { return refcount_helper_.use_count(); }
      38             : 
      39             : private:
      40             :   RefcountHelper refcount_helper_;
      41             :   SymbolTable& symbol_table_;
      42             : };
      43             : 
      44             : } // namespace Stats
      45             : } // namespace Envoy

Generated by: LCOV version 1.15