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 (#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: b890969 Ratio
BM_ProcYieldSpinLockThrashing/2/process_time/real_time 0.3996635305470434 ms/iter 0.19012539592010297 ms/iter 2.10
BM_NaiveSpinLockThrashing/1/process_time/real_time 0.48722428818271585 ms/iter 0.10208416822888666 ms/iter 4.77
BM_NaiveSpinLockThrashing/2/process_time/real_time 0.6541637487189714 ms/iter 0.2699008201087653 ms/iter 2.42
BM_NaiveSpinLockThrashing/4/process_time/real_time 1.7489062415228949 ms/iter 0.7164192696412405 ms/iter 2.44

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

Please sign in to comment.