@@ -29,16 +29,6 @@ bool reEnableTimer(Http::Code response_code) {
2929 }
3030}
3131
32- std::chrono::milliseconds getTimeout (envoy::config::core::v3::HttpUri& http_uri) {
33- auto timeout =
34- std::chrono::milliseconds (DurationUtil::durationToMilliseconds (http_uri.timeout ()));
35- // we want to ensure that we don't have more than one pending request
36- if (timeout > (TIMER_INTERVAL / 2 )) {
37- timeout = (TIMER_INTERVAL / 2 );
38- }
39- return timeout;
40- }
41-
4232} // namespace
4333
4434SamplerConfigProviderImpl::SamplerConfigProviderImpl (
@@ -47,7 +37,7 @@ SamplerConfigProviderImpl::SamplerConfigProviderImpl(
4737 : cluster_manager_(context.serverFactoryContext().clusterManager()),
4838 http_uri_ (config.http_uri()),
4939 authorization_header_value_(absl::StrCat(" Api-Token " , config.token())),
50- sampler_config_(config.root_spans_per_minute()), timeout_(getTimeout(http_uri_)) {
40+ sampler_config_(config.root_spans_per_minute()) {
5141
5242 timer_ = context.serverFactoryContext ().mainThreadDispatcher ().createTimer ([this ]() -> void {
5343 const auto thread_local_cluster = cluster_manager_.getThreadLocalCluster (http_uri_.cluster ());
@@ -60,7 +50,9 @@ SamplerConfigProviderImpl::SamplerConfigProviderImpl(
6050 message->headers ().setReference (Http::CustomHeaders::get ().Authorization ,
6151 authorization_header_value_);
6252 active_request_ = thread_local_cluster->httpAsyncClient ().send (
63- std::move (message), *this , Http::AsyncClient::RequestOptions ().setTimeout (timeout_));
53+ std::move (message), *this ,
54+ Http::AsyncClient::RequestOptions ().setTimeout (std::chrono::milliseconds (
55+ DurationUtil::durationToMilliseconds (http_uri_.timeout ()))));
6456 }
6557 });
6658
@@ -92,6 +84,8 @@ void SamplerConfigProviderImpl::onSuccess(const Http::AsyncClient::Request& /*re
9284
9385 if (json_valid || reEnableTimer (static_cast <Http::Code>(response_code))) {
9486 timer_->enableTimer (std::chrono::seconds (TIMER_INTERVAL));
87+ } else {
88+ ENVOY_LOG (error, " Stopped to query sampling configuration from Dynatrace." );
9589 }
9690}
9791
0 commit comments