File tree Expand file tree Collapse file tree 1 file changed +16
-13
lines changed
Expand file tree Collapse file tree 1 file changed +16
-13
lines changed Original file line number Diff line number Diff line change @@ -106,19 +106,22 @@ bool PeriodicExportingMetricReader::CollectAndExportOnce()
106106 std::promise<void > sender;
107107 auto receiver = sender.get_future ();
108108
109- task_thread.reset (new std::thread ([this , &cancel_export_for_timeout] {
110- this ->Collect ([this , &cancel_export_for_timeout](ResourceMetrics &metric_data) {
111- if (cancel_export_for_timeout.load (std::memory_order_acquire))
112- {
113- OTEL_INTERNAL_LOG_ERROR (
114- " [Periodic Exporting Metric Reader] Collect took longer configured time: "
115- << this ->export_timeout_millis_ .count () << " ms, and timed out" );
116- return false ;
117- }
118- this ->exporter_ ->Export (metric_data);
119- return true ;
120- });
121- }));
109+ task_thread.reset (
110+ new std::thread ([this , &cancel_export_for_timeout, sender = std::move (sender)] {
111+ this ->Collect ([this , &cancel_export_for_timeout](ResourceMetrics &metric_data) {
112+ if (cancel_export_for_timeout.load (std::memory_order_acquire))
113+ {
114+ OTEL_INTERNAL_LOG_ERROR (
115+ " [Periodic Exporting Metric Reader] Collect took longer configured time: "
116+ << this ->export_timeout_millis_ .count () << " ms, and timed out" );
117+ return false ;
118+ }
119+ this ->exporter_ ->Export (metric_data);
120+ return true ;
121+ });
122+
123+ const_cast <std::promise<void > &>(sender).set_value ();
124+ }));
122125
123126 std::future_status status;
124127 do
You can’t perform that action at this time.
0 commit comments