diff --git a/docs/root/configuration/upstream/cluster_manager/cluster_stats.rst b/docs/root/configuration/upstream/cluster_manager/cluster_stats.rst index 055240a77172b..17b5e2da387ce 100644 --- a/docs/root/configuration/upstream/cluster_manager/cluster_stats.rst +++ b/docs/root/configuration/upstream/cluster_manager/cluster_stats.rst @@ -105,6 +105,18 @@ Every cluster has a statistics tree rooted at *cluster..* with the followi assignment_timeout_received, Counter, Total assignments received with endpoint lease information. assignment_stale, Counter, Number of times the received assignments went stale before new assignments arrived. +HTTP/3 protocol statistics +-------------------------- + +HTTP/3 protocol stats are global with the following statistics: + +.. csv-table:: + :header: Name, Type, Description + :widths: 1, 1, 2 + + .quic_connection_close_error_code_, Counter, A collection of counters that are lazily initialized to record each QUIC connection close's error code. + + Health check statistics ----------------------- diff --git a/source/common/http/BUILD b/source/common/http/BUILD index db231bbd66b07..ebc5bdcf0cf67 100644 --- a/source/common/http/BUILD +++ b/source/common/http/BUILD @@ -190,6 +190,7 @@ envoy_cc_library( ":http3_status_tracker", ":mixed_conn_pool", "//source/common/http/http3:conn_pool_lib", + "//source/common/quic:quic_stat_names_lib", ], ) diff --git a/source/common/http/conn_pool_grid.cc b/source/common/http/conn_pool_grid.cc index 28ce8d1c89c30..071088f1b871e 100644 --- a/source/common/http/conn_pool_grid.cc +++ b/source/common/http/conn_pool_grid.cc @@ -193,11 +193,13 @@ ConnectivityGrid::ConnectivityGrid( const Network::TransportSocketOptionsConstSharedPtr& transport_socket_options, Upstream::ClusterConnectivityState& state, TimeSource& time_source, AlternateProtocolsCacheSharedPtr alternate_protocols, - std::chrono::milliseconds next_attempt_duration, ConnectivityOptions connectivity_options) + std::chrono::milliseconds next_attempt_duration, ConnectivityOptions connectivity_options, + Quic::QuicStatNames& quic_stat_names, Stats::Scope& scope) : dispatcher_(dispatcher), random_generator_(random_generator), host_(host), priority_(priority), options_(options), transport_socket_options_(transport_socket_options), state_(state), next_attempt_duration_(next_attempt_duration), time_source_(time_source), - http3_status_tracker_(dispatcher_), alternate_protocols_(alternate_protocols) { + http3_status_tracker_(dispatcher_), alternate_protocols_(alternate_protocols), + quic_stat_names_(quic_stat_names), scope_(scope) { // ProdClusterManagerFactory::allocateConnPool verifies the protocols are HTTP/1, HTTP/2 and // HTTP/3. // TODO(#15649) support v6/v4, WiFi/cellular. @@ -225,7 +227,7 @@ absl::optional ConnectivityGrid::createNextPool( if (pools_.empty()) { pools_.push_back(Http3::allocateConnPool(dispatcher_, random_generator_, host_, priority_, options_, transport_socket_options_, state_, - time_source_)); + time_source_, quic_stat_names_, scope_)); return pools_.begin(); } pools_.push_back(std::make_unique(dispatcher_, random_generator_, host_, diff --git a/source/common/http/conn_pool_grid.h b/source/common/http/conn_pool_grid.h index 5adf47dd4f7c3..e658b5ed1123c 100644 --- a/source/common/http/conn_pool_grid.h +++ b/source/common/http/conn_pool_grid.h @@ -3,6 +3,7 @@ #include "source/common/http/alternate_protocols_cache_impl.h" #include "source/common/http/conn_pool_base.h" #include "source/common/http/http3_status_tracker.h" +#include "source/common/quic/quic_stat_names.h" #include "absl/container/flat_hash_map.h" @@ -134,7 +135,8 @@ class ConnectivityGrid : public ConnectionPool::Instance, Upstream::ClusterConnectivityState& state, TimeSource& time_source, AlternateProtocolsCacheSharedPtr alternate_protocols, std::chrono::milliseconds next_attempt_duration, - ConnectivityOptions connectivity_options); + ConnectivityOptions connectivity_options, Quic::QuicStatNames& quic_stat_names, + Stats::Scope& scope); ~ConnectivityGrid() override; // Http::ConnPool::Instance @@ -210,6 +212,9 @@ class ConnectivityGrid : public ConnectionPool::Instance, // Wrapped callbacks are stashed in the wrapped_callbacks_ for ownership. std::list wrapped_callbacks_; + + Quic::QuicStatNames& quic_stat_names_; + Stats::Scope& scope_; }; } // namespace Http diff --git a/source/common/http/http3/conn_pool.cc b/source/common/http/http3/conn_pool.cc index ff7f39f21feeb..49ed2e1a7b3c4 100644 --- a/source/common/http/http3/conn_pool.cc +++ b/source/common/http/http3/conn_pool.cc @@ -59,10 +59,12 @@ allocateConnPool(Event::Dispatcher& dispatcher, Random::RandomGenerator& random_ Upstream::HostConstSharedPtr host, Upstream::ResourcePriority priority, const Network::ConnectionSocket::OptionsSharedPtr& options, const Network::TransportSocketOptionsConstSharedPtr& transport_socket_options, - Upstream::ClusterConnectivityState& state, TimeSource& time_source) { + Upstream::ClusterConnectivityState& state, TimeSource& time_source, + Quic::QuicStatNames& quic_stat_names, Stats::Scope& scope) { return std::make_unique( host, priority, dispatcher, options, transport_socket_options, random_generator, state, - [](HttpConnPoolImplBase* pool) -> ::Envoy::ConnectionPool::ActiveClientPtr { + [&quic_stat_names, + &scope](HttpConnPoolImplBase* pool) -> ::Envoy::ConnectionPool::ActiveClientPtr { // If there's no ssl context, the secrets are not loaded. Fast-fail by returning null. auto factory = &pool->host()->transportSocketFactory(); ASSERT(dynamic_cast(factory) != nullptr); @@ -77,8 +79,9 @@ allocateConnPool(Event::Dispatcher& dispatcher, Random::RandomGenerator& random_ if (!source_address.get()) { source_address = Network::Utility::getLocalAddress(host_address->ip()->version()); } - data.connection_ = Quic::createQuicNetworkConnection( - h3_pool->quicInfo(), pool->dispatcher(), host_address, source_address); + data.connection_ = + Quic::createQuicNetworkConnection(h3_pool->quicInfo(), pool->dispatcher(), host_address, + source_address, quic_stat_names, scope); return std::make_unique(*pool, data); }, [](Upstream::Host::CreateConnectionData& data, HttpConnPoolImplBase* pool) { diff --git a/source/common/http/http3/conn_pool.h b/source/common/http/http3/conn_pool.h index 3eaf625609db6..0886d4ddaf7ae 100644 --- a/source/common/http/http3/conn_pool.h +++ b/source/common/http/http3/conn_pool.h @@ -66,7 +66,8 @@ allocateConnPool(Event::Dispatcher& dispatcher, Random::RandomGenerator& random_ Upstream::HostConstSharedPtr host, Upstream::ResourcePriority priority, const Network::ConnectionSocket::OptionsSharedPtr& options, const Network::TransportSocketOptionsConstSharedPtr& transport_socket_options, - Upstream::ClusterConnectivityState& state, TimeSource& time_source); + Upstream::ClusterConnectivityState& state, TimeSource& time_source, + Quic::QuicStatNames& quic_stat_names, Stats::Scope& scope); } // namespace Http3 } // namespace Http diff --git a/source/common/quic/BUILD b/source/common/quic/BUILD index 435a1ac486b95..24ad4b8453ea9 100644 --- a/source/common/quic/BUILD +++ b/source/common/quic/BUILD @@ -265,6 +265,7 @@ envoy_cc_library( ":envoy_quic_stream_lib", ":envoy_quic_utils_lib", ":quic_filter_manager_connection_lib", + ":quic_stat_names_lib", "//source/common/buffer:buffer_lib", "//source/common/common:assert_lib", "//source/common/http:codes_lib", diff --git a/source/common/quic/client_connection_factory_impl.cc b/source/common/quic/client_connection_factory_impl.cc index e8af0afeb2d59..2e796745a4ca4 100644 --- a/source/common/quic/client_connection_factory_impl.cc +++ b/source/common/quic/client_connection_factory_impl.cc @@ -55,7 +55,8 @@ PersistentQuicInfoImpl::PersistentQuicInfoImpl( std::unique_ptr createQuicNetworkConnection(Http::PersistentQuicInfo& info, Event::Dispatcher& dispatcher, Network::Address::InstanceConstSharedPtr server_addr, - Network::Address::InstanceConstSharedPtr local_addr) { + Network::Address::InstanceConstSharedPtr local_addr, + QuicStatNames& quic_stat_names, Stats::Scope& scope) { // This flag fix a QUICHE issue which may crash Envoy during connection close. SetQuicReloadableFlag(quic_single_ack_in_packet2, true); PersistentQuicInfoImpl* info_impl = reinterpret_cast(&info); @@ -74,7 +75,7 @@ createQuicNetworkConnection(Http::PersistentQuicInfo& info, Event::Dispatcher& d auto ret = std::make_unique( info_impl->quic_config_, info_impl->supported_versions_, std::move(connection), info_impl->server_id_, std::move(config), &info_impl->push_promise_index_, dispatcher, - info_impl->buffer_limit_, info_impl->crypto_stream_factory_); + info_impl->buffer_limit_, info_impl->crypto_stream_factory_, quic_stat_names, scope); return ret; } diff --git a/source/common/quic/client_connection_factory_impl.h b/source/common/quic/client_connection_factory_impl.h index 269d4bb180733..5267c67b8fd0f 100644 --- a/source/common/quic/client_connection_factory_impl.h +++ b/source/common/quic/client_connection_factory_impl.h @@ -54,7 +54,8 @@ struct PersistentQuicInfoImpl : public Http::PersistentQuicInfo { std::unique_ptr createQuicNetworkConnection(Http::PersistentQuicInfo& info, Event::Dispatcher& dispatcher, Network::Address::InstanceConstSharedPtr server_addr, - Network::Address::InstanceConstSharedPtr local_addr); + Network::Address::InstanceConstSharedPtr local_addr, + QuicStatNames& quic_stat_names, Stats::Scope& scope); } // namespace Quic } // namespace Envoy diff --git a/source/common/quic/envoy_quic_client_session.cc b/source/common/quic/envoy_quic_client_session.cc index 6525b085bca1d..e300b820f873e 100644 --- a/source/common/quic/envoy_quic_client_session.cc +++ b/source/common/quic/envoy_quic_client_session.cc @@ -10,13 +10,15 @@ EnvoyQuicClientSession::EnvoyQuicClientSession( std::unique_ptr connection, const quic::QuicServerId& server_id, std::shared_ptr crypto_config, quic::QuicClientPushPromiseIndex* push_promise_index, Event::Dispatcher& dispatcher, - uint32_t send_buffer_limit, EnvoyQuicCryptoClientStreamFactoryInterface& crypto_stream_factory) + uint32_t send_buffer_limit, EnvoyQuicCryptoClientStreamFactoryInterface& crypto_stream_factory, + QuicStatNames& quic_stat_names, Stats::Scope& scope) : QuicFilterManagerConnectionImpl(*connection, connection->connection_id(), dispatcher, send_buffer_limit), quic::QuicSpdyClientSession(config, supported_versions, connection.release(), server_id, crypto_config.get(), push_promise_index), host_name_(server_id.host()), crypto_config_(crypto_config), - crypto_stream_factory_(crypto_stream_factory) {} + crypto_stream_factory_(crypto_stream_factory), quic_stat_names_(quic_stat_names), + scope_(scope) {} EnvoyQuicClientSession::~EnvoyQuicClientSession() { ASSERT(!connection()->connected()); @@ -35,6 +37,7 @@ void EnvoyQuicClientSession::connect() { void EnvoyQuicClientSession::OnConnectionClosed(const quic::QuicConnectionCloseFrame& frame, quic::ConnectionCloseSource source) { quic::QuicSpdyClientSession::OnConnectionClosed(frame, source); + quic_stat_names_.chargeQuicConnectionCloseStats(scope_, frame.quic_error_code, source, true); onConnectionCloseEvent(frame, source, version()); } diff --git a/source/common/quic/envoy_quic_client_session.h b/source/common/quic/envoy_quic_client_session.h index 955dbe0ef40f4..307a191e36225 100644 --- a/source/common/quic/envoy_quic_client_session.h +++ b/source/common/quic/envoy_quic_client_session.h @@ -17,6 +17,7 @@ #include "source/common/quic/envoy_quic_client_connection.h" #include "source/common/quic/quic_filter_manager_connection_impl.h" #include "source/common/quic/envoy_quic_crypto_stream_factory.h" +#include "source/common/quic/quic_stat_names.h" namespace Envoy { namespace Quic { @@ -38,7 +39,8 @@ class EnvoyQuicClientSession : public QuicFilterManagerConnectionImpl, std::shared_ptr crypto_config, quic::QuicClientPushPromiseIndex* push_promise_index, Event::Dispatcher& dispatcher, uint32_t send_buffer_limit, - EnvoyQuicCryptoClientStreamFactoryInterface& crypto_stream_factory); + EnvoyQuicCryptoClientStreamFactoryInterface& crypto_stream_factory, + QuicStatNames& quic_stat_names, Stats::Scope& scope); ~EnvoyQuicClientSession() override; @@ -102,6 +104,8 @@ class EnvoyQuicClientSession : public QuicFilterManagerConnectionImpl, const absl::string_view host_name_; std::shared_ptr crypto_config_; EnvoyQuicCryptoClientStreamFactoryInterface& crypto_stream_factory_; + QuicStatNames& quic_stat_names_; + Stats::Scope& scope_; }; } // namespace Quic diff --git a/source/common/upstream/BUILD b/source/common/upstream/BUILD index 901d530d882df..13dcb3846af3b 100644 --- a/source/common/upstream/BUILD +++ b/source/common/upstream/BUILD @@ -87,6 +87,7 @@ envoy_cc_library( "//source/common/tcp:conn_pool_lib", "//source/common/upstream:priority_conn_pool_map_impl_lib", "//source/common/upstream:upstream_lib", + "//source/common/quic:quic_stat_names_lib", "@envoy_api//envoy/admin/v3:pkg_cc_proto", "@envoy_api//envoy/config/bootstrap/v3:pkg_cc_proto", "@envoy_api//envoy/config/cluster/v3:pkg_cc_proto", diff --git a/source/common/upstream/cluster_manager_impl.cc b/source/common/upstream/cluster_manager_impl.cc index 63d0cf5c798fd..24343d13af833 100644 --- a/source/common/upstream/cluster_manager_impl.cc +++ b/source/common/upstream/cluster_manager_impl.cc @@ -1550,7 +1550,8 @@ Http::ConnectionPool::InstancePtr ProdClusterManagerFactory::allocateConnPool( Envoy::Http::ConnectivityGrid::ConnectivityOptions coptions{protocols}; return std::make_unique( dispatcher, api_.randomGenerator(), host, priority, options, transport_socket_options, - state, source, alternate_protocols_cache, std::chrono::milliseconds(300), coptions); + state, source, alternate_protocols_cache, std::chrono::milliseconds(300), coptions, + quic_stat_names_, stats_); #else // Should be blocked by configuration checking at an earlier point. NOT_REACHED_GCOVR_EXCL_LINE; @@ -1571,7 +1572,8 @@ Http::ConnectionPool::InstancePtr ProdClusterManagerFactory::allocateConnPool( runtime_.snapshot().featureEnabled("upstream.use_http3", 100)) { #ifdef ENVOY_ENABLE_QUIC return Http::Http3::allocateConnPool(dispatcher, api_.randomGenerator(), host, priority, - options, transport_socket_options, state, source); + options, transport_socket_options, state, source, + quic_stat_names_, stats_); #else UNREFERENCED_PARAMETER(source); // Should be blocked by configuration checking at an earlier point. diff --git a/source/common/upstream/cluster_manager_impl.h b/source/common/upstream/cluster_manager_impl.h index c3d436eb3f9ac..d03ea3c439626 100644 --- a/source/common/upstream/cluster_manager_impl.h +++ b/source/common/upstream/cluster_manager_impl.h @@ -32,6 +32,7 @@ #include "source/common/http/alternate_protocols_cache_impl.h" #include "source/common/http/alternate_protocols_cache_manager_impl.h" #include "source/common/http/async_client_impl.h" +#include "source/common/quic/quic_stat_names.h" #include "source/common/upstream/load_stats_reporter.h" #include "source/common/upstream/priority_conn_pool_map.h" #include "source/common/upstream/upstream_impl.h" @@ -44,23 +45,21 @@ namespace Upstream { */ class ProdClusterManagerFactory : public ClusterManagerFactory { public: - ProdClusterManagerFactory(Server::Admin& admin, Runtime::Loader& runtime, Stats::Store& stats, - ThreadLocal::Instance& tls, Network::DnsResolverSharedPtr dns_resolver, - Ssl::ContextManager& ssl_context_manager, - Event::Dispatcher& main_thread_dispatcher, - const LocalInfo::LocalInfo& local_info, - Secret::SecretManager& secret_manager, - ProtobufMessage::ValidationContext& validation_context, Api::Api& api, - Http::Context& http_context, Grpc::Context& grpc_context, - Router::Context& router_context, - AccessLog::AccessLogManager& log_manager, - Singleton::Manager& singleton_manager, const Server::Options& options) + ProdClusterManagerFactory( + Server::Admin& admin, Runtime::Loader& runtime, Stats::Store& stats, + ThreadLocal::Instance& tls, Network::DnsResolverSharedPtr dns_resolver, + Ssl::ContextManager& ssl_context_manager, Event::Dispatcher& main_thread_dispatcher, + const LocalInfo::LocalInfo& local_info, Secret::SecretManager& secret_manager, + ProtobufMessage::ValidationContext& validation_context, Api::Api& api, + Http::Context& http_context, Grpc::Context& grpc_context, Router::Context& router_context, + AccessLog::AccessLogManager& log_manager, Singleton::Manager& singleton_manager, + const Server::Options& options, Quic::QuicStatNames& quic_stat_names) : main_thread_dispatcher_(main_thread_dispatcher), validation_context_(validation_context), api_(api), http_context_(http_context), grpc_context_(grpc_context), router_context_(router_context), admin_(admin), runtime_(runtime), stats_(stats), tls_(tls), dns_resolver_(dns_resolver), ssl_context_manager_(ssl_context_manager), local_info_(local_info), secret_manager_(secret_manager), log_manager_(log_manager), - singleton_manager_(singleton_manager), options_(options), + singleton_manager_(singleton_manager), options_(options), quic_stat_names_(quic_stat_names), alternate_protocols_cache_manager_factory_(singleton_manager, main_thread_dispatcher.timeSource(), tls_), alternate_protocols_cache_manager_(alternate_protocols_cache_manager_factory_.get()) {} @@ -108,6 +107,7 @@ class ProdClusterManagerFactory : public ClusterManagerFactory { AccessLog::AccessLogManager& log_manager_; Singleton::Manager& singleton_manager_; const Server::Options& options_; + Quic::QuicStatNames& quic_stat_names_; Http::AlternateProtocolsCacheManagerFactoryImpl alternate_protocols_cache_manager_factory_; Http::AlternateProtocolsCacheManagerSharedPtr alternate_protocols_cache_manager_; }; diff --git a/source/server/BUILD b/source/server/BUILD index 9c893e5444288..3e6f60ab88002 100644 --- a/source/server/BUILD +++ b/source/server/BUILD @@ -411,8 +411,8 @@ envoy_cc_library( "//source/common/network:utility_lib", "//source/common/protobuf:utility_lib", "//source/common/stream_info:stream_info_lib", - "//source/extensions/filters/network/http_connection_manager:config", "//source/common/quic:quic_stat_names_lib", + "//source/extensions/filters/network/http_connection_manager:config", "//source/extensions/upstreams/http/generic:config", "@envoy_api//envoy/admin/v3:pkg_cc_proto", "@envoy_api//envoy/config/core/v3:pkg_cc_proto", @@ -520,6 +520,7 @@ envoy_cc_library( "//source/common/memory:heap_shrinker_lib", "//source/common/memory:stats_lib", "//source/common/protobuf:utility_lib", + "//source/common/quic:quic_stat_names_lib", "//source/common/router:rds_lib", "//source/common/runtime:runtime_lib", "//source/common/secret:secret_manager_impl_lib", diff --git a/source/server/config_validation/BUILD b/source/server/config_validation/BUILD index f1c14f54e4f0d..f33cd523ce856 100644 --- a/source/server/config_validation/BUILD +++ b/source/server/config_validation/BUILD @@ -90,6 +90,7 @@ envoy_cc_library( "//source/common/grpc:common_lib", "//source/common/local_info:local_info_lib", "//source/common/protobuf:utility_lib", + "//source/common/quic:quic_stat_names_lib", "//source/common/router:context_lib", "//source/common/router:rds_lib", "//source/common/runtime:runtime_lib", diff --git a/source/server/config_validation/cluster_manager.h b/source/server/config_validation/cluster_manager.h index 60c801a5260da..0cfc3fa31dff6 100644 --- a/source/server/config_validation/cluster_manager.h +++ b/source/server/config_validation/cluster_manager.h @@ -28,11 +28,11 @@ class ValidationClusterManagerFactory : public ProdClusterManagerFactory { ProtobufMessage::ValidationContext& validation_context, Api::Api& api, Http::Context& http_context, Grpc::Context& grpc_context, Router::Context& router_context, AccessLog::AccessLogManager& log_manager, Singleton::Manager& singleton_manager, - const Server::Options& options) - : ProdClusterManagerFactory(admin, runtime, stats, tls, dns_resolver, ssl_context_manager, - main_thread_dispatcher, local_info, secret_manager, - validation_context, api, http_context, grpc_context, - router_context, log_manager, singleton_manager, options), + const Server::Options& options, Quic::QuicStatNames& quic_stat_names) + : ProdClusterManagerFactory( + admin, runtime, stats, tls, dns_resolver, ssl_context_manager, main_thread_dispatcher, + local_info, secret_manager, validation_context, api, http_context, grpc_context, + router_context, log_manager, singleton_manager, options, quic_stat_names), grpc_context_(grpc_context), router_context_(router_context) {} ClusterManagerPtr diff --git a/source/server/config_validation/server.cc b/source/server/config_validation/server.cc index 98014fbd614f6..3d37c7ac56c49 100644 --- a/source/server/config_validation/server.cc +++ b/source/server/config_validation/server.cc @@ -53,7 +53,8 @@ ValidationInstance::ValidationInstance( store), mutex_tracer_(nullptr), grpc_context_(stats_store_.symbolTable()), http_context_(stats_store_.symbolTable()), router_context_(stats_store_.symbolTable()), - time_system_(time_system), server_contexts_(*this) { + time_system_(time_system), server_contexts_(*this), + quic_stat_names_(stats_store_.symbolTable()) { TRY_ASSERT_MAIN_THREAD { initialize(options, local_address, component_factory); } END_TRY catch (const EnvoyException& e) { @@ -94,7 +95,8 @@ void ValidationInstance::initialize(const Options& options, Configuration::InitialImpl initial_config(bootstrap, options); initial_config.initAdminAccessLog(bootstrap, *this); admin_ = std::make_unique(initial_config.admin().address()); - listener_manager_ = std::make_unique(*this, *this, *this, false); + listener_manager_ = + std::make_unique(*this, *this, *this, false, quic_stat_names_); thread_local_.registerThread(*dispatcher_, true); runtime_singleton_ = std::make_unique( component_factory.createRuntime(*this, initial_config)); @@ -103,7 +105,8 @@ void ValidationInstance::initialize(const Options& options, cluster_manager_factory_ = std::make_unique( admin(), runtime(), stats(), threadLocal(), dnsResolver(), sslContextManager(), dispatcher(), localInfo(), *secret_manager_, messageValidationContext(), *api_, http_context_, - grpc_context_, router_context_, accessLogManager(), singletonManager(), options); + grpc_context_, router_context_, accessLogManager(), singletonManager(), options, + quic_stat_names_); config_.initialize(bootstrap, *this, *cluster_manager_factory_); runtime().initialize(clusterManager()); clusterManager().setInitializedCb([this]() -> void { init_manager_.initialize(init_watcher_); }); diff --git a/source/server/config_validation/server.h b/source/server/config_validation/server.h index a569f76a1fdf1..356769f2b5962 100644 --- a/source/server/config_validation/server.h +++ b/source/server/config_validation/server.h @@ -16,6 +16,7 @@ #include "source/common/common/random_generator.h" #include "source/common/grpc/common.h" #include "source/common/protobuf/message_validator_impl.h" +#include "source/common/quic/quic_stat_names.h" #include "source/common/router/context_impl.h" #include "source/common/router/rds_impl.h" #include "source/common/runtime/runtime_impl.h" @@ -213,6 +214,7 @@ class ValidationInstance final : Logger::Loggable, Router::ContextImpl router_context_; Event::TimeSystem& time_system_; ServerFactoryContextImpl server_contexts_; + Quic::QuicStatNames quic_stat_names_; }; } // namespace Server diff --git a/source/server/listener_manager_impl.cc b/source/server/listener_manager_impl.cc index 98814eea12918..5fd3db577d6b8 100644 --- a/source/server/listener_manager_impl.cc +++ b/source/server/listener_manager_impl.cc @@ -243,7 +243,8 @@ DrainingFilterChainsManager::DrainingFilterChainsManager(ListenerImplPtr&& drain ListenerManagerImpl::ListenerManagerImpl(Instance& server, ListenerComponentFactory& listener_factory, WorkerFactory& worker_factory, - bool enable_dispatcher_stats) + bool enable_dispatcher_stats, + Quic::QuicStatNames& quic_stat_names) : server_(server), factory_(listener_factory), scope_(server.stats().createScope("listener_manager.")), stats_(generateStats(*scope_)), config_tracker_entry_(server.admin().getConfigTracker().add( @@ -251,8 +252,7 @@ ListenerManagerImpl::ListenerManagerImpl(Instance& server, [this](const Matchers::StringMatcher& name_matcher) { return dumpListenerConfigs(name_matcher); })), - enable_dispatcher_stats_(enable_dispatcher_stats), - quic_stat_names_(server_.stats().symbolTable()) { + enable_dispatcher_stats_(enable_dispatcher_stats), quic_stat_names_(quic_stat_names) { for (uint32_t i = 0; i < server.options().concurrency(); i++) { workers_.emplace_back( worker_factory.createWorker(i, server.overloadManager(), absl::StrCat("worker_", i))); diff --git a/source/server/listener_manager_impl.h b/source/server/listener_manager_impl.h index a98e8fbfe56c4..ad85054671954 100644 --- a/source/server/listener_manager_impl.h +++ b/source/server/listener_manager_impl.h @@ -177,7 +177,8 @@ class DrainingFilterChainsManager { class ListenerManagerImpl : public ListenerManager, Logger::Loggable { public: ListenerManagerImpl(Instance& server, ListenerComponentFactory& listener_factory, - WorkerFactory& worker_factory, bool enable_dispatcher_stats); + WorkerFactory& worker_factory, bool enable_dispatcher_stats, + Quic::QuicStatNames& quic_stat_names); void onListenerWarmed(ListenerImpl& listener); void inPlaceFilterChainUpdate(ListenerImpl& listener); @@ -323,7 +324,7 @@ class ListenerManagerImpl : public ListenerManager, Logger::Loggable> error_state_tracker_; FailureStates overall_error_state_; - Quic::QuicStatNames quic_stat_names_; + Quic::QuicStatNames& quic_stat_names_; }; class ListenerFilterChainFactoryBuilder : public FilterChainFactoryBuilder { diff --git a/source/server/server.cc b/source/server/server.cc index b82655a58b360..d8bc98da42ef2 100644 --- a/source/server/server.cc +++ b/source/server/server.cc @@ -88,7 +88,8 @@ InstanceImpl::InstanceImpl( : nullptr), grpc_context_(store.symbolTable()), http_context_(store.symbolTable()), router_context_(store.symbolTable()), process_context_(std::move(process_context)), - hooks_(hooks), server_contexts_(*this), stats_flush_in_progress_(false) { + hooks_(hooks), quic_stat_names_(store.symbolTable()), server_contexts_(*this), + stats_flush_in_progress_(false) { TRY_ASSERT_MAIN_THREAD { if (!options.logPath().empty()) { TRY_ASSERT_MAIN_THREAD { @@ -517,8 +518,9 @@ void InstanceImpl::initialize(const Options& options, } // Workers get created first so they register for thread local updates. - listener_manager_ = std::make_unique( - *this, listener_component_factory_, worker_factory_, bootstrap_.enable_dispatcher_stats()); + listener_manager_ = + std::make_unique(*this, listener_component_factory_, worker_factory_, + bootstrap_.enable_dispatcher_stats(), quic_stat_names_); // The main thread is also registered for thread local updates so that code that does not care // whether it runs on the main thread or on workers can still use TLS. @@ -592,7 +594,7 @@ void InstanceImpl::initialize(const Options& options, *admin_, Runtime::LoaderSingleton::get(), stats_store_, thread_local_, dns_resolver_, *ssl_context_manager_, *dispatcher_, *local_info_, *secret_manager_, messageValidationContext(), *api_, http_context_, grpc_context_, router_context_, - access_log_manager_, *singleton_manager_, options_); + access_log_manager_, *singleton_manager_, options_, quic_stat_names_); // Now the configuration gets parsed. The configuration may start setting // thread local data per above. See MainImpl::initialize() for why ConfigImpl diff --git a/source/server/server.h b/source/server/server.h index 945567740bb7e..36a017416317c 100644 --- a/source/server/server.h +++ b/source/server/server.h @@ -33,6 +33,7 @@ #include "source/common/init/manager_impl.h" #include "source/common/memory/heap_shrinker.h" #include "source/common/protobuf/message_validator_impl.h" +#include "source/common/quic/quic_stat_names.h" #include "source/common/router/context_impl.h" #include "source/common/runtime/runtime_impl.h" #include "source/common/secret/secret_manager_impl.h" @@ -288,6 +289,8 @@ class InstanceImpl final : Logger::Loggable, } bool enableReusePortDefault() override; + Quic::QuicStatNames& quicStatNames() { return quic_stat_names_; } + // ServerLifecycleNotifier ServerLifecycleNotifier::HandlePtr registerCallback(Stage stage, StageCallback callback) override; ServerLifecycleNotifier::HandlePtr @@ -382,6 +385,7 @@ class InstanceImpl final : Logger::Loggable, // whenever we have support for histogram merge across hot restarts. Stats::TimespanPtr initialization_timer_; ListenerHooks& hooks_; + Quic::QuicStatNames quic_stat_names_; ServerFactoryContextImpl server_contexts_; absl::optional enable_reuse_port_default_; diff --git a/test/common/http/conn_manager_impl_test.cc b/test/common/http/conn_manager_impl_test.cc index 69894daf187aa..c1fe56f0fbede 100644 --- a/test/common/http/conn_manager_impl_test.cc +++ b/test/common/http/conn_manager_impl_test.cc @@ -303,7 +303,7 @@ TEST_F(HttpConnectionManagerImplTest, PopulateStreamInfo) { EXPECT_EQ(requestIDExtension().get(), decoder_->streamInfo().getRequestIDProvider()); EXPECT_EQ(ssl_connection_, decoder_->streamInfo().downstreamSslConnection()); EXPECT_EQ(filter_callbacks_.connection_.id_, - decoder_->streamInfo().downstreamAddressProvider().connectionID()); + decoder_->streamInfo().downstreamAddressProvider().connectionID().value()); EXPECT_EQ(server_name_, decoder_->streamInfo().downstreamAddressProvider().requestedServerName()); // Clean up. diff --git a/test/common/http/conn_pool_grid_test.cc b/test/common/http/conn_pool_grid_test.cc index 945af22b86ab7..ec76c120984ec 100644 --- a/test/common/http/conn_pool_grid_test.cc +++ b/test/common/http/conn_pool_grid_test.cc @@ -101,10 +101,12 @@ class ConnectivityGridTestBase : public Event::TestUsingSimulatedTime, public te ConnectivityGridTestBase(bool use_alternate_protocols) : options_({Http::Protocol::Http11, Http::Protocol::Http2, Http::Protocol::Http3}), alternate_protocols_(maybeCreateAlternateProtocolsCacheImpl(use_alternate_protocols)), + quic_stat_names_(store_.symbolTable()), grid_(dispatcher_, random_, Upstream::makeTestHost(cluster_, "hostname", "tcp://127.0.0.1:9000", simTime()), Upstream::ResourcePriority::Default, socket_options_, transport_socket_options_, - state_, simTime(), alternate_protocols_, std::chrono::milliseconds(300), options_), + state_, simTime(), alternate_protocols_, std::chrono::milliseconds(300), options_, + quic_stat_names_, store_), host_(grid_.host()) { grid_.info_ = &info_; grid_.encoder_ = &encoder_; @@ -134,6 +136,8 @@ class ConnectivityGridTestBase : public Event::TestUsingSimulatedTime, public te std::shared_ptr cluster_{new NiceMock()}; NiceMock random_; AlternateProtocolsCacheSharedPtr alternate_protocols_; + Stats::IsolatedStoreImpl store_; + Quic::QuicStatNames quic_stat_names_; ConnectivityGridForTest grid_; Upstream::HostDescriptionConstSharedPtr host_; @@ -620,10 +624,11 @@ TEST_F(ConnectivityGridTest, RealGrid) { .WillRepeatedly( Return(Upstream::TransportSocketMatcher::MatchData(*factory, matcher.stats_, "test"))); - ConnectivityGrid grid( - dispatcher_, random_, Upstream::makeTestHost(cluster_, "tcp://127.0.0.1:9000", simTime()), - Upstream::ResourcePriority::Default, socket_options_, transport_socket_options_, state_, - simTime(), alternate_protocols_, std::chrono::milliseconds(300), options_); + ConnectivityGrid grid(dispatcher_, random_, + Upstream::makeTestHost(cluster_, "tcp://127.0.0.1:9000", simTime()), + Upstream::ResourcePriority::Default, socket_options_, + transport_socket_options_, state_, simTime(), alternate_protocols_, + std::chrono::milliseconds(300), options_, quic_stat_names_, store_); // Create the HTTP/3 pool. auto optional_it1 = ConnectivityGridForTest::forceCreateNextPool(grid); diff --git a/test/common/http/http3/conn_pool_test.cc b/test/common/http/http3/conn_pool_test.cc index fdb472e8c7665..ba4c3124cb38c 100644 --- a/test/common/http/http3/conn_pool_test.cc +++ b/test/common/http/http3/conn_pool_test.cc @@ -45,8 +45,9 @@ class Http3ConnPoolImplTest : public Event::TestUsingSimulatedTime, public testi new Event::MockSchedulableCallback(&dispatcher_); Network::ConnectionSocket::OptionsSharedPtr options; Network::TransportSocketOptionsConstSharedPtr transport_options; - pool_ = allocateConnPool(dispatcher_, random_, host_, Upstream::ResourcePriority::Default, - options, transport_options, state_, simTime()); + pool_ = + allocateConnPool(dispatcher_, random_, host_, Upstream::ResourcePriority::Default, options, + transport_options, state_, simTime(), quic_stat_names_, store_); } Upstream::MockHost& mockHost() { return static_cast(*host_); } @@ -62,6 +63,8 @@ class Http3ConnPoolImplTest : public Event::TestUsingSimulatedTime, public testi Quic::QuicClientTransportSocketFactory factory_{ std::unique_ptr(new NiceMock), context_}; + Stats::IsolatedStoreImpl store_; + Quic::QuicStatNames quic_stat_names_{store_.symbolTable()}; ConnectionPool::InstancePtr pool_; }; diff --git a/test/common/quic/client_connection_factory_impl_test.cc b/test/common/quic/client_connection_factory_impl_test.cc index 2995db8e98583..97220f85244a9 100644 --- a/test/common/quic/client_connection_factory_impl_test.cc +++ b/test/common/quic/client_connection_factory_impl_test.cc @@ -45,6 +45,8 @@ class QuicNetworkConnectionTest : public Event::TestUsingSimulatedTime, public t Network::Address::InstanceConstSharedPtr test_address_; NiceMock context_; std::unique_ptr factory_; + Stats::IsolatedStoreImpl store_; + QuicStatNames quic_stat_names_{store_.symbolTable()}; }; TEST_F(QuicNetworkConnectionTest, BufferLimits) { @@ -53,8 +55,8 @@ TEST_F(QuicNetworkConnectionTest, BufferLimits) { quic::QuicConfig config; PersistentQuicInfoImpl info{dispatcher_, *factory_, simTime(), test_address_, config, 45}; - std::unique_ptr client_connection = - createQuicNetworkConnection(info, dispatcher_, test_address_, test_address_); + std::unique_ptr client_connection = createQuicNetworkConnection( + info, dispatcher_, test_address_, test_address_, quic_stat_names_, store_); EnvoyQuicClientSession* session = static_cast(client_connection.get()); session->Initialize(); client_connection->connect(); diff --git a/test/common/quic/envoy_quic_client_session_test.cc b/test/common/quic/envoy_quic_client_session_test.cc index 62b9c66516736..812818016fe2f 100644 --- a/test/common/quic/envoy_quic_client_session_test.cc +++ b/test/common/quic/envoy_quic_client_session_test.cc @@ -83,13 +83,14 @@ class EnvoyQuicClientSessionTest : public testing::TestWithParam { quic_version_, *dispatcher_, createConnectionSocket(peer_addr_, self_addr_, nullptr))), crypto_config_(std::make_shared( quic::test::crypto_test_utils::ProofVerifierForTesting())), - envoy_quic_session_(quic_config_, quic_version_, - std::unique_ptr(quic_connection_), - quic::QuicServerId("example.com", 443, false), crypto_config_, nullptr, - *dispatcher_, - /*send_buffer_limit*/ 1024 * 1024, crypto_stream_factory_), - stats_({ALL_HTTP3_CODEC_STATS(POOL_COUNTER_PREFIX(scope_, "http3."), - POOL_GAUGE_PREFIX(scope_, "http3."))}), + quic_stat_names_(store_.symbolTable()), + envoy_quic_session_( + quic_config_, quic_version_, + std::unique_ptr(quic_connection_), + quic::QuicServerId("example.com", 443, false), crypto_config_, nullptr, *dispatcher_, + /*send_buffer_limit*/ 1024 * 1024, crypto_stream_factory_, quic_stat_names_, store_), + stats_({ALL_HTTP3_CODEC_STATS(POOL_COUNTER_PREFIX(store_, "http3."), + POOL_GAUGE_PREFIX(store_, "http3."))}), http_connection_(envoy_quic_session_, http_connection_callbacks_, stats_, http3_options_, 64 * 1024, 100) { EXPECT_EQ(time_system_.systemTime(), envoy_quic_session_.streamInfo().startTime()); @@ -148,6 +149,8 @@ class EnvoyQuicClientSessionTest : public testing::TestWithParam { quic::QuicConfig quic_config_; std::shared_ptr crypto_config_; TestQuicCryptoClientStreamFactory crypto_stream_factory_; + Stats::IsolatedStoreImpl store_; + QuicStatNames quic_stat_names_; EnvoyQuicClientSession envoy_quic_session_; Network::MockConnectionCallbacks network_connection_callbacks_; Http::MockServerConnectionCallbacks http_connection_callbacks_; @@ -155,7 +158,6 @@ class EnvoyQuicClientSessionTest : public testing::TestWithParam { testing::StrictMock read_current_; testing::StrictMock write_total_; testing::StrictMock write_current_; - Stats::IsolatedStoreImpl scope_; Http::Http3::CodecStats stats_; envoy::config::core::v3::Http3ProtocolOptions http3_options_; QuicHttpClientConnectionImpl http_connection_; @@ -257,6 +259,11 @@ TEST_P(EnvoyQuicClientSessionTest, ConnectionClose) { EXPECT_EQ(absl::StrCat(quic::QuicErrorCodeToString(error), " with details: ", error_details), envoy_quic_session_.transportFailureReason()); EXPECT_EQ(Network::Connection::State::Closed, envoy_quic_session_.state()); + + EXPECT_EQ( + 1U, TestUtility::findCounter( + store_, "http3.upstream.rx.quic_connection_close_error_code_QUIC_INVALID_FRAME_DATA") + ->value()); } TEST_P(EnvoyQuicClientSessionTest, ConnectionCloseWithActiveStream) { @@ -289,13 +296,14 @@ class EnvoyQuicClientSessionAllQuicVersionTest createConnectionSocket(peer_addr_, self_addr_, nullptr))), crypto_config_(std::make_shared( quic::test::crypto_test_utils::ProofVerifierForTesting())), - envoy_quic_session_(quic_config_, quic::test::SupportedVersions(GetParam()), - std::unique_ptr(quic_connection_), - quic::QuicServerId("example.com", 443, false), crypto_config_, nullptr, - *dispatcher_, - /*send_buffer_limit*/ 1024 * 1024, crypto_stream_factory_), - stats_({ALL_HTTP3_CODEC_STATS(POOL_COUNTER_PREFIX(scope_, "http3."), - POOL_GAUGE_PREFIX(scope_, "http3."))}), + quic_stat_names_(store_.symbolTable()), + envoy_quic_session_( + quic_config_, quic::test::SupportedVersions(GetParam()), + std::unique_ptr(quic_connection_), + quic::QuicServerId("example.com", 443, false), crypto_config_, nullptr, *dispatcher_, + /*send_buffer_limit*/ 1024 * 1024, crypto_stream_factory_, quic_stat_names_, store_), + stats_({ALL_HTTP3_CODEC_STATS(POOL_COUNTER_PREFIX(store_, "http3."), + POOL_GAUGE_PREFIX(store_, "http3."))}), http_connection_(envoy_quic_session_, http_connection_callbacks_, stats_, http3_options_, 64 * 1024, 100) { EXPECT_EQ(time_system_.systemTime(), envoy_quic_session_.streamInfo().startTime()); @@ -339,6 +347,8 @@ class EnvoyQuicClientSessionAllQuicVersionTest quic::QuicConfig quic_config_; std::shared_ptr crypto_config_; TestQuicCryptoClientStreamFactory crypto_stream_factory_; + Stats::IsolatedStoreImpl store_; + QuicStatNames quic_stat_names_; EnvoyQuicClientSession envoy_quic_session_; Network::MockConnectionCallbacks network_connection_callbacks_; Http::MockServerConnectionCallbacks http_connection_callbacks_; @@ -346,7 +356,6 @@ class EnvoyQuicClientSessionAllQuicVersionTest testing::StrictMock read_current_; testing::StrictMock write_total_; testing::StrictMock write_current_; - Stats::IsolatedStoreImpl scope_; Http::Http3::CodecStats stats_; envoy::config::core::v3::Http3ProtocolOptions http3_options_; QuicHttpClientConnectionImpl http_connection_; @@ -391,7 +400,7 @@ TEST_P(EnvoyQuicClientSessionAllQuicVersionTest, ConnectionClosePopulatesQuicVer break; } EXPECT_EQ(1U, TestUtility::findCounter( - scope_, absl::StrCat("http3.quic_version_", quic_version_stat_name)) + store_, absl::StrCat("http3.quic_version_", quic_version_stat_name)) ->value()); } diff --git a/test/common/quic/test_utils.h b/test/common/quic/test_utils.h index c5487c81538e0..192f0d4465c65 100644 --- a/test/common/quic/test_utils.h +++ b/test/common/quic/test_utils.h @@ -26,6 +26,7 @@ #include "source/common/quic/envoy_quic_utils.h" #include "source/common/quic/envoy_quic_client_session.h" #include "test/test_common/environment.h" +#include "source/common/stats/isolated_store_impl.h" namespace Envoy { namespace Quic { @@ -168,7 +169,8 @@ class MockEnvoyQuicClientSession : public EnvoyQuicClientSession { quic::QuicServerId("example.com", 443, false), std::make_shared( quic::test::crypto_test_utils::ProofVerifierForTesting()), - nullptr, dispatcher, send_buffer_limit, crypto_stream_factory) {} + nullptr, dispatcher, send_buffer_limit, crypto_stream_factory, + quic_stat_names_, stats_store_) {} void Initialize() override { EnvoyQuicClientSession::Initialize(); @@ -203,6 +205,9 @@ class MockEnvoyQuicClientSession : public EnvoyQuicClientSession { return initialized_ ? connection() : nullptr; } quic::QuicConnection* quicConnection() override { return initialized_ ? connection() : nullptr; } + + Stats::IsolatedStoreImpl stats_store_; + QuicStatNames quic_stat_names_{stats_store_.symbolTable()}; }; Buffer::OwnedImpl diff --git a/test/common/router/config_impl_test.cc b/test/common/router/config_impl_test.cc index fba1a9ab1f98d..3a40e003bc4bc 100644 --- a/test/common/router/config_impl_test.cc +++ b/test/common/router/config_impl_test.cc @@ -2224,7 +2224,7 @@ TEST_F(RouterMatcherHashPolicyTest, HashHeadersWithMultipleValues) { EXPECT_FALSE(generateHash({})); EXPECT_TRUE(generateHash({"bar"})); - EXPECT_NE(0UL, generateHash({"bar", "foo"})); + EXPECT_NE(0UL, generateHash({"bar", "foo"}).value()); EXPECT_EQ(generateHash({"bar", "foo"}), generateHash({"bar", "foo"})); // deterministic EXPECT_EQ(generateHash({"bar", "foo"}), generateHash({"foo", "bar"})); // order independent EXPECT_NE(generateHash({"abcd", "ef"}), generateHash({"abc", "def"})); @@ -2273,7 +2273,7 @@ TEST_F(RouterMatcherHashPolicyTest, HashHeadersRegexSubstitutionWithMultipleValu EXPECT_FALSE(generateHash({})); EXPECT_TRUE(generateHash({"/bar"})); - EXPECT_NE(0UL, generateHash({"/bar", "/foo"})); + EXPECT_NE(0UL, generateHash({"/bar", "/foo"}).value()); EXPECT_EQ(generateHash({"bar", "foo"}), generateHash({"/bar", "/foo"})); // deterministic EXPECT_EQ(generateHash({"bar", "foo"}), generateHash({"/foo", "/bar"})); // order independent EXPECT_NE(generateHash({"abcd", "ef"}), generateHash({"/abc", "/def"})); diff --git a/test/config_test/config_test.cc b/test/config_test/config_test.cc index 865c6b562ee4f..5dc666dd6f476 100644 --- a/test/config_test/config_test.cc +++ b/test/config_test/config_test.cc @@ -107,7 +107,7 @@ class ConfigTest { server_.dnsResolver(), ssl_context_manager_, server_.dispatcher(), server_.localInfo(), server_.secretManager(), server_.messageValidationContext(), *api_, server_.httpContext(), server_.grpcContext(), server_.routerContext(), server_.accessLogManager(), - server_.singletonManager(), server_.options()); + server_.singletonManager(), server_.options(), server_.quic_stat_names_); ON_CALL(server_, clusterManager()).WillByDefault(Invoke([&]() -> Upstream::ClusterManager& { return *main_config.clusterManager(); @@ -160,8 +160,8 @@ class ConfigTest { std::unique_ptr cluster_manager_factory_; NiceMock component_factory_; NiceMock worker_factory_; - Server::ListenerManagerImpl listener_manager_{server_, component_factory_, worker_factory_, - false}; + Server::ListenerManagerImpl listener_manager_{server_, component_factory_, worker_factory_, false, + server_.quic_stat_names_}; Random::RandomGeneratorImpl random_; std::shared_ptr snapshot_{ std::make_shared>()}; diff --git a/test/integration/BUILD b/test/integration/BUILD index 873ee7db78b20..544fed82743df 100644 --- a/test/integration/BUILD +++ b/test/integration/BUILD @@ -804,6 +804,7 @@ envoy_cc_test_library( "//source/common/http/http3:quic_client_connection_factory_lib", "//source/common/json:json_loader_lib", "//source/common/network:utility_lib", + "//source/common/quic:quic_stat_names_lib", "//source/common/stats:allocator_lib", "//source/common/stats:isolated_store_lib", "//source/common/thread_local:thread_local_lib", diff --git a/test/integration/http_integration.cc b/test/integration/http_integration.cc index 3f0f219e005eb..0430602910755 100644 --- a/test/integration/http_integration.cc +++ b/test/integration/http_integration.cc @@ -232,7 +232,7 @@ Network::ClientConnectionPtr HttpIntegrationTest::makeClientConnectionWithOption Network::Address::InstanceConstSharedPtr local_addr = Network::Test::getCanonicalLoopbackAddress(version_); return Quic::createQuicNetworkConnection(*quic_connection_persistent_info_, *dispatcher_, - server_addr, local_addr); + server_addr, local_addr, quic_stat_names_, stats_store_); #else ASSERT(false, "running a QUIC integration test without compiling QUIC"); return nullptr; @@ -302,7 +302,7 @@ HttpIntegrationTest::HttpIntegrationTest(Http::CodecType downstream_protocol, Network::Address::IpVersion version, const std::string& config) : BaseIntegrationTest(upstream_address_fn, version, config), - downstream_protocol_(downstream_protocol) { + downstream_protocol_(downstream_protocol), quic_stat_names_(stats_store_.symbolTable()) { // Legacy integration tests expect the default listener to be named "http" for // lookupPort calls. config_helper_.renameListener("http"); diff --git a/test/integration/http_integration.h b/test/integration/http_integration.h index 2d795cddba0a7..34a6ed6c82ee7 100644 --- a/test/integration/http_integration.h +++ b/test/integration/http_integration.h @@ -268,7 +268,7 @@ class HttpIntegrationTest : public BaseIntegrationTest { Http::CodecType downstream_protocol_{Http::CodecType::HTTP1}; std::string access_log_name_; testing::NiceMock random_; - + Quic::QuicStatNames quic_stat_names_; std::string san_to_match_{"spiffe://lyft.com/backend-team"}; }; diff --git a/test/integration/quic_http_integration_test.cc b/test/integration/quic_http_integration_test.cc index 3a38fea1fadba..a32fda3ddbee4 100644 --- a/test/integration/quic_http_integration_test.cc +++ b/test/integration/quic_http_integration_test.cc @@ -111,7 +111,7 @@ class QuicHttpIntegrationTest : public HttpIntegrationTest, public QuicMultiVers // Use smaller window than the default one to have test coverage of client codec buffer // exceeding high watermark. /*send_buffer_limit=*/2 * Http2::Utility::OptionsLimits::MIN_INITIAL_STREAM_WINDOW_SIZE, - persistent_info.crypto_stream_factory_); + persistent_info.crypto_stream_factory_, quic_stat_names_, stats_store_); return session; } diff --git a/test/integration/sds_dynamic_integration_test.cc b/test/integration/sds_dynamic_integration_test.cc index e29fc1e9cf4b9..8e7b7ad656f27 100644 --- a/test/integration/sds_dynamic_integration_test.cc +++ b/test/integration/sds_dynamic_integration_test.cc @@ -303,7 +303,8 @@ version_info: "0" local_address = std::make_shared("::1"); } return Quic::createQuicNetworkConnection(*quic_connection_persistent_info_, *dispatcher_, - Network::Utility::resolveUrl(url), local_address); + Network::Utility::resolveUrl(url), local_address, + quic_stat_names_, stats_store_); #else NOT_REACHED_GCOVR_EXCL_LINE; #endif diff --git a/test/integration/utility.cc b/test/integration/utility.cc index abf19d24a6439..c6746cae7869d 100644 --- a/test/integration/utility.cc +++ b/test/integration/utility.cc @@ -19,6 +19,7 @@ #include "source/common/http/http3/quic_client_connection_factory.h" #include "source/common/network/address_impl.h" #include "source/common/network/utility.h" +#include "source/common/quic/quic_stat_names.h" #include "source/common/upstream/upstream_impl.h" #ifdef ENVOY_ENABLE_QUIC @@ -182,6 +183,7 @@ IntegrationUtil::makeSingleRequest(const Network::Address::InstanceConstSharedPt const std::string& body, Http::CodecType type, const std::string& host, const std::string& content_type) { NiceMock mock_stats_store; + Quic::QuicStatNames quic_stat_names(mock_stats_store.symbolTable()); NiceMock random; Event::GlobalTimeSystem time_system; NiceMock random_generator; @@ -189,6 +191,7 @@ IntegrationUtil::makeSingleRequest(const Network::Address::InstanceConstSharedPt Filesystem::fileSystemForTest(), random_generator); Event::DispatcherPtr dispatcher(api.allocateDispatcher("test_thread")); TestConnectionCallbacks connection_callbacks(*dispatcher); + std::shared_ptr cluster{new NiceMock()}; Upstream::HostDescriptionConstSharedPtr host_description{Upstream::makeTestHostDescription( cluster, fmt::format("{}://127.0.0.1:80", (type == Http::CodecType::HTTP3 ? "udp" : "tcp")), @@ -221,8 +224,8 @@ IntegrationUtil::makeSingleRequest(const Network::Address::InstanceConstSharedPt // Docker only works with loopback v6 address. local_address = std::make_shared("::1"); } - Network::ClientConnectionPtr connection = - Quic::createQuicNetworkConnection(*persistent_info, *dispatcher, addr, local_address); + Network::ClientConnectionPtr connection = Quic::createQuicNetworkConnection( + *persistent_info, *dispatcher, addr, local_address, quic_stat_names, mock_stats_store); connection->addConnectionCallbacks(connection_callbacks); Http::CodecClientProd client(type, std::move(connection), host_description, *dispatcher, random); // Quic connection needs to finish handshake. diff --git a/test/mocks/server/BUILD b/test/mocks/server/BUILD index 679f3e6d1b2d2..c26d734bad79f 100644 --- a/test/mocks/server/BUILD +++ b/test/mocks/server/BUILD @@ -182,6 +182,7 @@ envoy_cc_mock( "//envoy/server:instance_interface", "//source/common/grpc:context_lib", "//source/common/http:context_lib", + "//source/common/quic:quic_stat_names_lib", "//source/common/router:context_lib", "//source/common/secret:secret_manager_impl_lib", "//source/common/singleton:manager_impl_lib", diff --git a/test/mocks/server/instance.cc b/test/mocks/server/instance.cc index 92be91025b9ed..f19f81dc4afcd 100644 --- a/test/mocks/server/instance.cc +++ b/test/mocks/server/instance.cc @@ -16,7 +16,7 @@ MockInstance::MockInstance() cluster_manager_(timeSource()), ssl_context_manager_(timeSource()), singleton_manager_(new Singleton::ManagerImpl(Thread::threadFactoryForTest())), grpc_context_(stats_store_.symbolTable()), http_context_(stats_store_.symbolTable()), - router_context_(stats_store_.symbolTable()), + router_context_(stats_store_.symbolTable()), quic_stat_names_(stats_store_.symbolTable()), stats_config_(std::make_shared>()), server_factory_context_( std::make_shared>()), diff --git a/test/mocks/server/instance.h b/test/mocks/server/instance.h index fe3f22fcc2305..455e82eebfec5 100644 --- a/test/mocks/server/instance.h +++ b/test/mocks/server/instance.h @@ -4,6 +4,7 @@ #include "source/common/grpc/context_impl.h" #include "source/common/http/context_impl.h" +#include "source/common/quic/quic_stat_names.h" #include "source/common/router/context_impl.h" #include "source/common/stats/symbol_table_impl.h" #include "source/extensions/transport_sockets/tls/context_manager_impl.h" @@ -122,6 +123,7 @@ class MockInstance : public Instance { Http::ContextImpl http_context_; envoy::config::bootstrap::v3::Bootstrap bootstrap_; Router::ContextImpl router_context_; + Quic::QuicStatNames quic_stat_names_; testing::NiceMock validation_context_; std::shared_ptr> stats_config_; std::shared_ptr> diff --git a/test/server/api_listener_test.cc b/test/server/api_listener_test.cc index f1c269a8f8c17..ee51447e4e404 100644 --- a/test/server/api_listener_test.cc +++ b/test/server/api_listener_test.cc @@ -22,8 +22,8 @@ namespace Server { class ApiListenerTest : public testing::Test { protected: ApiListenerTest() - : listener_manager_(std::make_unique(server_, listener_factory_, - worker_factory_, false)) {} + : listener_manager_(std::make_unique( + server_, listener_factory_, worker_factory_, false, server_.quic_stat_names_)) {} NiceMock server_; NiceMock listener_factory_; diff --git a/test/server/config_validation/cluster_manager_test.cc b/test/server/config_validation/cluster_manager_test.cc index 4a5ec1f4fd0d9..d0762c4425df7 100644 --- a/test/server/config_validation/cluster_manager_test.cc +++ b/test/server/config_validation/cluster_manager_test.cc @@ -45,13 +45,14 @@ TEST(ValidationClusterManagerTest, MockedMethods) { Http::ContextImpl http_context(stats_store.symbolTable()); Grpc::ContextImpl grpc_context(stats_store.symbolTable()); Router::ContextImpl router_context(stats_store.symbolTable()); + Quic::QuicStatNames quic_stat_names(stats_store.symbolTable()); AccessLog::MockAccessLogManager log_manager; Singleton::ManagerImpl singleton_manager{Thread::threadFactoryForTest()}; ValidationClusterManagerFactory factory( admin, runtime, stats_store, tls, dns_resolver, ssl_context_manager, dispatcher, local_info, secret_manager, validation_context, *api, http_context, grpc_context, router_context, - log_manager, singleton_manager, options); + log_manager, singleton_manager, options, quic_stat_names); const envoy::config::bootstrap::v3::Bootstrap bootstrap; ClusterManagerPtr cluster_manager = factory.clusterManagerFromProto(bootstrap); diff --git a/test/server/configuration_impl_test.cc b/test/server/configuration_impl_test.cc index 4e7de3b88dc1f..f2f02f385bc00 100644 --- a/test/server/configuration_impl_test.cc +++ b/test/server/configuration_impl_test.cc @@ -65,7 +65,8 @@ class ConfigurationImplTest : public testing::Test { server_.dnsResolver(), server_.sslContextManager(), server_.dispatcher(), server_.localInfo(), server_.secretManager(), server_.messageValidationContext(), *api_, server_.httpContext(), server_.grpcContext(), server_.routerContext(), - server_.accessLogManager(), server_.singletonManager(), server_.options()) {} + server_.accessLogManager(), server_.singletonManager(), server_.options(), + server_.quic_stat_names_) {} void addStatsdFakeClusterConfig(envoy::config::metrics::v3::StatsSink& sink) { envoy::config::metrics::v3::StatsdSink statsd_sink; diff --git a/test/server/listener_manager_impl_test.h b/test/server/listener_manager_impl_test.h index 856436d9c2423..077c221b4fc0b 100644 --- a/test/server/listener_manager_impl_test.h +++ b/test/server/listener_manager_impl_test.h @@ -73,8 +73,9 @@ class ListenerManagerImplTest : public testing::Test { .WillByDefault(ReturnRef(validation_visitor)); ON_CALL(server_.validation_context_, dynamicValidationVisitor()) .WillByDefault(ReturnRef(validation_visitor)); - manager_ = std::make_unique(server_, listener_factory_, worker_factory_, - enable_dispatcher_stats_); + manager_ = + std::make_unique(server_, listener_factory_, worker_factory_, + enable_dispatcher_stats_, server_.quic_stat_names_); // Use real filter loading by default. ON_CALL(listener_factory_, createNetworkFilterFactoryList(_, _))