This repository was archived by the owner on Jul 31, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +13
-8
lines changed
opencensus/trace/internal Expand file tree Collapse file tree 2 files changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,11 @@ void SpanExporterImpl::StartExportThread() {
5757 thread_started_ = true ;
5858}
5959
60+ bool SpanExporterImpl::IsBufferFull () const {
61+ span_mu_.AssertHeld ();
62+ return spans_.size () >= buffer_size_;
63+ }
64+
6065void SpanExporterImpl::RunWorkerLoop () {
6166 std::vector<opencensus::trace::exporter::SpanData> span_data_;
6267 std::vector<std::shared_ptr<opencensus::trace::SpanImpl>> spans_copy_;
@@ -67,14 +72,9 @@ void SpanExporterImpl::RunWorkerLoop() {
6772 {
6873 absl::MutexLock l (&span_mu_);
6974 // Wait until batch is full or interval time has been exceeded.
70- span_mu_.AwaitWithDeadline (absl::Condition (
71- +[](SpanExporterImpl* ptr) {
72- ptr->span_mu_ .AssertHeld ();
73- return ptr->spans_ .size () >=
74- ptr->buffer_size_ ;
75- },
76- this ),
77- next_forced_export_time);
75+ span_mu_.AwaitWithDeadline (
76+ absl::Condition (this , &SpanExporterImpl::IsBufferFull),
77+ next_forced_export_time);
7878 next_forced_export_time = absl::Now () + interval_;
7979 if (spans_.empty ()) {
8080 continue ;
Original file line number Diff line number Diff line change @@ -66,10 +66,15 @@ class SpanExporterImpl {
6666
6767 void StartExportThread () EXCLUSIVE_LOCKS_REQUIRED(handler_mu_);
6868 void RunWorkerLoop ();
69+
6970 // Calls all registered handlers and exports the spans contained in span_data.
7071 void Export (const std::vector<SpanData>& span_data);
72+
7173 void ExportForTesting ();
7274
75+ // Returns true if the spans_ buffer has filled up.
76+ bool IsBufferFull () const ;
77+
7378 static SpanExporterImpl* span_exporter_;
7479 const uint32_t buffer_size_;
7580 const absl::Duration interval_;
You can’t perform that action at this time.
0 commit comments