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

1 comment on commit 242d52a

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'OpenTelemetry-cpp api Benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: 242d52a Previous: 9e062b5 Ratio
BM_NaiveSpinLockThrashing/1/process_time/real_time 0.742895801423489 ms/iter 0.09962429596094491 ms/iter 7.46
BM_NaiveSpinLockThrashing/2/process_time/real_time 7.185593895290209 ms/iter 0.26067630382170776 ms/iter 27.57
BM_NaiveSpinLockThrashing/4/process_time/real_time 6.356501579284668 ms/iter 0.818328857421875 ms/iter 7.77

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.