Skip to content

Commit 535d99b

Browse files
committed
review feedback: add log msg, remove timeout adjustment
Signed-off-by: thomas.ebner <[email protected]>
1 parent 4c246a6 commit 535d99b

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

source/extensions/tracers/opentelemetry/samplers/dynatrace/sampler_config_provider.cc

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -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

4434
SamplerConfigProviderImpl::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

source/extensions/tracers/opentelemetry/samplers/dynatrace/sampler_config_provider.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ class SamplerConfigProviderImpl : public SamplerConfigProvider,
6868
const std::string authorization_header_value_;
6969
Http::AsyncClient::Request* active_request_{};
7070
SamplerConfig sampler_config_;
71-
const std::chrono::milliseconds timeout_;
7271
};
7372

7473
using SamplerConfigProviderPtr = std::unique_ptr<SamplerConfigProvider>;

0 commit comments

Comments
 (0)