Skip to content

Commit

Permalink
Fixed timeout calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
intuibase committed Oct 2, 2024
1 parent 5525e93 commit d90eac0
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions prod/native/libcommon/code/transport/HttpTransportAsync.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ class HttpTransportAsync : public ForkableInterface, public boost::noncopyable {
}

~HttpTransportAsync() {
shutdownStart_ = std::chrono::steady_clock::now();
forceFlush_ = true;
shutdownThread();
CurlCleanup();
Expand Down Expand Up @@ -233,8 +234,6 @@ class HttpTransportAsync : public ForkableInterface, public boost::noncopyable {
}

void send(std::unique_lock<std::mutex> &locked) {
auto sendStartTime = std::chrono::steady_clock::now();

while (!payloadsToSend_.empty()) {
auto [endpointHash, payload] = std::move(payloadsToSend_.front());
payloadsToSend_.pop();
Expand Down Expand Up @@ -287,7 +286,7 @@ class HttpTransportAsync : public ForkableInterface, public boost::noncopyable {
ELOG_WARNING(log_, "HttpTransportAsync::send exception '%s'. enpointHash: %X connectionId: %X payload size: %zu", e.what(), endpointHash, endpoint->second.getConnectionId(), payload.size());
}

if (forceFlush_ && !payloadsToSend_.empty() && config_->get().async_transport_shutdown_timeout.count() > 0 && ((std::chrono::steady_clock::now() - sendStartTime) >= config_->get().async_transport_shutdown_timeout)) {
if (forceFlush_ && !payloadsToSend_.empty() && config_->get().async_transport_shutdown_timeout.count() > 0 && ((std::chrono::steady_clock::now() - shutdownStart_) >= config_->get().async_transport_shutdown_timeout)) {
ELOG_WARNING(log_, "Dropping %zu payloads because ELASTIC_OTEL_ASYNC_TRANSPORT_SHUTDOWN_TIMEOUT (%zums) was reached", payloadsToSend_.size(), config_->get().async_transport_shutdown_timeout.count());
break;
}
Expand Down Expand Up @@ -319,8 +318,8 @@ class HttpTransportAsync : public ForkableInterface, public boost::noncopyable {
std::unique_ptr<std::thread> thread_;
std::condition_variable pauseCondition_;
bool working_ = true;
bool resumed_ = false;
std::atomic_bool forceFlush_ = false;
std::chrono::time_point<std::chrono::steady_clock> shutdownStart_;
};

} // namespace elasticapm::php::transport

0 comments on commit d90eac0

Please sign in to comment.