Skip to content

Commit

Permalink
rds: add config reload time stat for rds (#17033)
Browse files Browse the repository at this point in the history
Signed-off-by: Rama Chavali <rama.rao@salesforce.com>
  • Loading branch information
ramaraochavali authored Jun 22, 2021
1 parent 5a0d165 commit 305ea53
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/root/configuration/overview/mgmt_server.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ The following statistics are generated for all subscriptions.
:widths: 1, 1, 2

config_reload, Counter, Total API fetches that resulted in a config reload due to a different config
config_reload_time_ms, Gauge, Timestamp of the last config reload as milliseconds since the epoch
init_fetch_timeout, Counter, Total :ref:`initial fetch timeouts <envoy_v3_api_field_config.core.v3.ConfigSource.initial_fetch_timeout>`
update_attempt, Counter, Total API fetches attempted
update_success, Counter, Total API fetches completed successfully
Expand Down
1 change: 1 addition & 0 deletions docs/root/version_history/current.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ New Features
* bootstrap: added :ref:`dns_resolution_config <envoy_v3_api_field_config.bootstrap.v3.Bootstrap.dns_resolution_config>` to aggregate all of the DNS resolver configuration in a single message. By setting one such configuration option ``no_default_search_domain`` as true the DNS resolver will not use the default search domains. And by setting the configuration ``resolvers`` we can specify the external DNS servers to be used for external DNS query.
* cluster: added :ref:`dns_resolution_config <envoy_v3_api_field_config.cluster.v3.Cluster.dns_resolution_config>` to aggregate all of the DNS resolver configuration in a single message. By setting one such configuration option ``no_default_search_domain`` as true the DNS resolver will not use the default search domains.
* composite filter: can now be used with filters that also add an access logger, such as the WASM filter.
* config: added stat :ref:`config_reload_time_ms <subscription_statistics>`.
* connection_limit: added new :ref:`Network connection limit filter <config_network_filters_connection_limit>`.
* crash support: restore crash context when continuing to processing requests or responses as a result of an asynchronous callback that invokes a filter directly. This is unlike the call stacks that go through the various network layers, to eventually reach the filter. For a concrete example see: ``Envoy::Extensions::HttpFilters::Cache::CacheFilter::getHeaders`` which posts a callback on the dispatcher that will invoke the filter directly.
* dns cache: added :ref:`preresolve_hostnames <envoy_v3_api_field_extensions.common.dynamic_forward_proxy.v3.DnsCacheConfig.preresolve_hostnames>` option to the DNS cache config. This option allows hostnames to be preresolved into the cache upon cache creation. This might provide performance improvement, in the form of cache hits, for hostnames that are going to be resolved during steady state and are known at config load time.
Expand Down
4 changes: 3 additions & 1 deletion source/common/router/rds_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ RdsRouteConfigSubscription::RdsRouteConfigSubscription(
fmt::format("RdsRouteConfigSubscription local-init-target {}", route_config_name_),
[this]() { subscription_->start({route_config_name_}); }),
local_init_manager_(fmt::format("RDS local-init-manager {}", route_config_name_)),
stat_prefix_(stat_prefix), stats_({ALL_RDS_STATS(POOL_COUNTER(*scope_))}),
stat_prefix_(stat_prefix),
stats_({ALL_RDS_STATS(POOL_COUNTER(*scope_), POOL_GAUGE(*scope_))}),
route_config_provider_manager_(route_config_provider_manager),
manager_identifier_(manager_identifier), optional_http_filters_(optional_http_filters) {
const auto resource_name = getResourceName();
Expand Down Expand Up @@ -131,6 +132,7 @@ void RdsRouteConfigSubscription::onConfigUpdate(
std::unique_ptr<Cleanup> resume_rds;
if (config_update_info_->onRdsUpdate(route_config, version_info)) {
stats_.config_reload_.inc();
stats_.config_reload_time_ms_.set(DateUtil::nowToMilliseconds(factory_context_.timeSource()));
if (config_update_info_->protobufConfiguration().has_vhds() &&
config_update_info_->vhdsConfigurationChanged()) {
ENVOY_LOG(
Expand Down
7 changes: 4 additions & 3 deletions source/common/router/rds_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,16 @@ class StaticRouteConfigProviderImpl : public RouteConfigProvider {
/**
* All RDS stats. @see stats_macros.h
*/
#define ALL_RDS_STATS(COUNTER) \
#define ALL_RDS_STATS(COUNTER, GAUGE) \
COUNTER(config_reload) \
COUNTER(update_empty)
COUNTER(update_empty) \
GAUGE(config_reload_time_ms, NeverImport)

/**
* Struct definition for all RDS stats. @see stats_macros.h
*/
struct RdsStats {
ALL_RDS_STATS(GENERATE_COUNTER_STRUCT)
ALL_RDS_STATS(GENERATE_COUNTER_STRUCT, GENERATE_GAUGE_STRUCT)
};

class RdsRouteConfigProviderImpl;
Expand Down
1 change: 1 addition & 0 deletions source/common/router/scoped_rds.cc
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ void ScopedRdsConfigSubscription::onConfigUpdate(
}
stats_.all_scopes_.set(scoped_route_map_.size());
stats_.config_reload_.inc();
stats_.config_reload_time_ms_.set(DateUtil::nowToMilliseconds(factory_context_.timeSource()));
}

void ScopedRdsConfigSubscription::onRdsConfigUpdate(const std::string& scope_name,
Expand Down
1 change: 1 addition & 0 deletions source/common/router/scoped_rds.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class InlineScopedRoutesConfigProvider : public Envoy::Config::ImmutableConfigPr
COUNTER(config_reload) \
COUNTER(update_empty) \
GAUGE(all_scopes, Accumulate) \
GAUGE(config_reload_time_ms, NeverImport) \
GAUGE(on_demand_scopes, Accumulate) \
GAUGE(active_scopes, Accumulate)

Expand Down
1 change: 1 addition & 0 deletions test/common/router/rds_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ TEST_F(RdsImplTest, Basic) {
// Old config use count should be 1 now.
EXPECT_EQ(1, config.use_count());
EXPECT_EQ(2UL, scope_.counter("foo.rds.foo_route_config.config_reload").value());
EXPECT_TRUE(scope_.findGaugeByString("foo.rds.foo_route_config.config_reload_time_ms"));
}

// validate there will be exception throw when unknown factory found for per virtualhost typed
Expand Down
3 changes: 3 additions & 0 deletions test/common/router/scoped_rds_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,9 @@ route_configuration_name: foo_routes
EXPECT_EQ(2UL,
server_factory_context_.scope_.counter("foo.scoped_rds.foo_scoped_routes.config_reload")
.value());
EXPECT_TRUE(server_factory_context_.scope_.findGaugeByString(
"foo.scoped_rds.foo_scoped_routes.config_reload_time_ms"));

// now scope key "x-bar-key" points to nowhere.
EXPECT_THAT(getScopedRdsProvider()->config<ScopedConfigImpl>()->getRouteConfig(
TestRequestHeaderMapImpl{{"Addr", "x-foo-key;x-bar-key"}}),
Expand Down

0 comments on commit 305ea53

Please sign in to comment.