Skip to content

Commit

Permalink
[SDK] PeriodicExportingMetricReader: future is never set, blocks unti…
Browse files Browse the repository at this point in the history
…l timeout (open-telemetry#3030)
  • Loading branch information
owent authored Aug 21, 2024
1 parent b890969 commit 242d52a
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions sdk/src/metrics/export/periodic_exporting_metric_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,22 @@ bool PeriodicExportingMetricReader::CollectAndExportOnce()
std::promise<void> sender;
auto receiver = sender.get_future();

task_thread.reset(new std::thread([this, &cancel_export_for_timeout] {
this->Collect([this, &cancel_export_for_timeout](ResourceMetrics &metric_data) {
if (cancel_export_for_timeout.load(std::memory_order_acquire))
{
OTEL_INTERNAL_LOG_ERROR(
"[Periodic Exporting Metric Reader] Collect took longer configured time: "
<< this->export_timeout_millis_.count() << " ms, and timed out");
return false;
}
this->exporter_->Export(metric_data);
return true;
});
}));
task_thread.reset(
new std::thread([this, &cancel_export_for_timeout, sender = std::move(sender)] {
this->Collect([this, &cancel_export_for_timeout](ResourceMetrics &metric_data) {
if (cancel_export_for_timeout.load(std::memory_order_acquire))
{
OTEL_INTERNAL_LOG_ERROR(
"[Periodic Exporting Metric Reader] Collect took longer configured time: "
<< this->export_timeout_millis_.count() << " ms, and timed out");
return false;
}
this->exporter_->Export(metric_data);
return true;
});

const_cast<std::promise<void> &>(sender).set_value();
}));

std::future_status status;
do
Expand Down

0 comments on commit 242d52a

Please sign in to comment.