Coverage Report

Created: 2023-11-12 09:30

/proc/self/cwd/source/common/http/http1/codec_stats.h
Line
Count
Source (jump to first uncovered line)
1
#pragma once
2
3
#include "envoy/http/header_validator.h"
4
#include "envoy/stats/scope.h"
5
#include "envoy/stats/stats_macros.h"
6
7
#include "source/common/common/thread.h"
8
9
namespace Envoy {
10
namespace Http {
11
namespace Http1 {
12
13
/**
14
 * All stats for the HTTP/1 codec. @see stats_macros.h
15
 */
16
#define ALL_HTTP1_CODEC_STATS(COUNTER)                                                             \
17
12.7k
  COUNTER(dropped_headers_with_underscores)                                                        \
18
12.7k
  COUNTER(metadata_not_supported_error)                                                            \
19
12.7k
  COUNTER(requests_rejected_with_underscores_in_headers)                                           \
20
12.7k
  COUNTER(response_flood)
21
22
/**
23
 * Wrapper struct for the HTTP/1 codec stats. @see stats_macros.h
24
 */
25
struct CodecStats : public ::Envoy::Http::HeaderValidatorStats {
26
  using AtomicPtr = Thread::AtomicPtr<CodecStats, Thread::AtomicPtrAllocMode::DeleteOnDestruct>;
27
28
  CodecStats(ALL_HTTP1_CODEC_STATS(GENERATE_CONSTRUCTOR_COUNTER_PARAM)...)
29
      : ::Envoy::Http::HeaderValidatorStats()
30
12.7k
            ALL_HTTP1_CODEC_STATS(GENERATE_CONSTRUCTOR_INIT_LIST) {}
31
32
56.4k
  static CodecStats& atomicGet(AtomicPtr& ptr, Stats::Scope& scope) {
33
56.4k
    return *ptr.get([&scope]() -> CodecStats* {
34
12.7k
      return new CodecStats{ALL_HTTP1_CODEC_STATS(POOL_COUNTER_PREFIX(scope, "http1."))};
35
12.7k
    });
36
56.4k
  }
37
38
17.0k
  void incDroppedHeadersWithUnderscores() override { dropped_headers_with_underscores_.inc(); }
39
0
  void incRequestsRejectedWithUnderscoresInHeaders() override {
40
0
    requests_rejected_with_underscores_in_headers_.inc();
41
0
  }
42
  // TODO(yanavlasov): add corresponding counter for H/1 codec.
43
0
  void incMessagingError() override {}
44
45
  ALL_HTTP1_CODEC_STATS(GENERATE_COUNTER_STRUCT)
46
};
47
48
} // namespace Http1
49
} // namespace Http
50
} // namespace Envoy