1
#pragma once
2

            
3
#ifdef ENVOY_ENABLE_QUIC
4

            
5
#include "envoy/stats/scope.h"
6

            
7
#include "source/common/common/thread.h"
8
#include "source/common/stats/symbol_table.h"
9

            
10
#include "quiche/quic/core/quic_error_codes.h"
11
#include "quiche/quic/core/quic_types.h"
12

            
13
namespace Envoy {
14
namespace Quic {
15

            
16
class QuicStatNames {
17
public:
18
  // This class holds lazily symbolized stat names and is responsible for charging them.
19
  explicit QuicStatNames(Stats::SymbolTable& symbol_table);
20

            
21
  void chargeQuicConnectionCloseStats(Stats::Scope& scope, quic::QuicErrorCode error_code,
22
                                      quic::ConnectionCloseSource source, bool is_upstream);
23

            
24
  void chargeQuicResetStreamErrorStats(Stats::Scope& scope, quic::QuicResetStreamError error_code,
25
                                       bool from_self, bool is_upstream);
26

            
27
private:
28
  // Find the actual counter in |scope| and increment it.
29
  // An example counter name: "http3.downstream.tx.quic_connection_close_error_code_QUIC_NO_ERROR".
30
  void incCounter(Stats::Scope& scope, const Stats::StatNameVec& names);
31

            
32
  Stats::StatName connectionCloseStatName(quic::QuicErrorCode error_code);
33

            
34
  Stats::StatName resetStreamErrorStatName(quic::QuicRstStreamErrorCode error_code);
35

            
36
  Stats::StatNamePool stat_name_pool_;
37
  Stats::SymbolTable& symbol_table_;
38
  const Stats::StatName http3_prefix_;
39
  const Stats::StatName downstream_;
40
  const Stats::StatName upstream_;
41
  const Stats::StatName from_self_;
42
  const Stats::StatName from_peer_;
43
  Thread::AtomicPtrArray<const uint8_t, quic::QUIC_LAST_ERROR + 1,
44
                         Thread::AtomicPtrAllocMode::DoNotDelete>
45
      connection_error_stat_names_;
46
  Thread::AtomicPtrArray<const uint8_t, quic::QUIC_STREAM_LAST_ERROR + 1,
47
                         Thread::AtomicPtrAllocMode::DoNotDelete>
48
      reset_stream_error_stat_names_;
49
};
50

            
51
#else
52

            
53
#include "source/common/stats/symbol_table.h"
54
namespace Envoy {
55
namespace Quic {
56

            
57
class QuicStatNames {
58
public:
59
  explicit QuicStatNames(Stats::SymbolTable& symbol_table);
60
};
61

            
62
#endif
63

            
64
} // namespace Quic
65
} // namespace Envoy