Line data Source code
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 Http3 { 12 : 13 : /** 14 : * All stats for the HTTP/3 codec. @see stats_macros.h 15 : */ 16 : #define ALL_HTTP3_CODEC_STATS(COUNTER, GAUGE) \ 17 0 : COUNTER(dropped_headers_with_underscores) \ 18 0 : COUNTER(requests_rejected_with_underscores_in_headers) \ 19 0 : COUNTER(rx_reset) \ 20 0 : COUNTER(tx_reset) \ 21 0 : COUNTER(metadata_not_supported_error) \ 22 0 : COUNTER(quic_version_h3_29) \ 23 0 : COUNTER(quic_version_rfc_v1) \ 24 0 : COUNTER(tx_flush_timeout) 25 : 26 : /** 27 : * Wrapper struct for the HTTP/3 codec stats. @see stats_macros.h 28 : */ 29 : struct CodecStats : public ::Envoy::Http::HeaderValidatorStats { 30 : using AtomicPtr = Thread::AtomicPtr<CodecStats, Thread::AtomicPtrAllocMode::DeleteOnDestruct>; 31 : 32 : CodecStats(ALL_HTTP3_CODEC_STATS(GENERATE_CONSTRUCTOR_COUNTER_PARAM, 33 : GENERATE_CONSTRUCTOR_GAUGE_PARAM)...) 34 : : ::Envoy::Http::HeaderValidatorStats() 35 1 : ALL_HTTP3_CODEC_STATS(GENERATE_CONSTRUCTOR_INIT_LIST, GENERATE_CONSTRUCTOR_INIT_LIST) {} 36 : 37 0 : static CodecStats& atomicGet(AtomicPtr& ptr, Stats::Scope& scope) { 38 0 : return *ptr.get([&scope]() -> CodecStats* { 39 0 : return new CodecStats{ALL_HTTP3_CODEC_STATS(POOL_COUNTER_PREFIX(scope, "http3."), 40 0 : POOL_GAUGE_PREFIX(scope, "http3."))}; 41 0 : }); 42 0 : } 43 : 44 0 : void incDroppedHeadersWithUnderscores() override { dropped_headers_with_underscores_.inc(); } 45 0 : void incRequestsRejectedWithUnderscoresInHeaders() override { 46 0 : requests_rejected_with_underscores_in_headers_.inc(); 47 0 : } 48 : // TODO(yanavlasov): add corresponding counter for H/3 codec. 49 0 : void incMessagingError() override {} 50 : 51 : ALL_HTTP3_CODEC_STATS(GENERATE_COUNTER_STRUCT, GENERATE_GAUGE_STRUCT) 52 : }; 53 : 54 : } // namespace Http3 55 : } // namespace Http 56 : } // namespace Envoy