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 Http1 { 12 : 13 : /** 14 : * All stats for the HTTP/1 codec. @see stats_macros.h 15 : */ 16 : #define ALL_HTTP1_CODEC_STATS(COUNTER) \ 17 326 : COUNTER(dropped_headers_with_underscores) \ 18 326 : COUNTER(metadata_not_supported_error) \ 19 326 : COUNTER(requests_rejected_with_underscores_in_headers) \ 20 326 : 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 326 : ALL_HTTP1_CODEC_STATS(GENERATE_CONSTRUCTOR_INIT_LIST) {} 31 : 32 3112 : static CodecStats& atomicGet(AtomicPtr& ptr, Stats::Scope& scope) { 33 3112 : return *ptr.get([&scope]() -> CodecStats* { 34 326 : return new CodecStats{ALL_HTTP1_CODEC_STATS(POOL_COUNTER_PREFIX(scope, "http1."))}; 35 326 : }); 36 3112 : } 37 : 38 0 : 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