Skip to content

Commit

Permalink
Merge pull request #62 from open-telemetry/main
Browse files Browse the repository at this point in the history
[SDK] PeriodicExportingMetricReader: future is never set, blocks unti…
  • Loading branch information
malkia authored Aug 22, 2024
2 parents 3f26fac + 242d52a commit 71d90d9
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 71d90d9

Please sign in to comment.