Skip to content

Commit

Permalink
Merge pull request #49 from open-telemetry/main
Browse files Browse the repository at this point in the history
 [SDK] Added reserve for spans array in BatchSpanProcessor. (open-telemetry#2724)
  • Loading branch information
malkia authored Jun 28, 2024
2 parents 9ba176e + f0e0ef0 commit 052a22c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sdk/src/logs/batch_log_record_processor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ void BatchLogRecordProcessor::Export()
break;
}

// Reserve space for the number of records
records_arr.reserve(num_records_to_export);
buffer_.Consume(num_records_to_export,
[&](CircularBufferRange<AtomicUniquePtr<Recordable>> range) noexcept {
range.ForEach([&](AtomicUniquePtr<Recordable> &ptr) {
Expand Down
4 changes: 4 additions & 0 deletions sdk/src/trace/batch_span_processor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@ void BatchSpanProcessor::Export()
NotifyCompletion(notify_force_flush, exporter_, synchronization_data_);
break;
}

// Reserve space for the number of records
spans_arr.reserve(num_records_to_export);

buffer_.Consume(num_records_to_export,
[&](CircularBufferRange<AtomicUniquePtr<Recordable>> range) noexcept {
range.ForEach([&](AtomicUniquePtr<Recordable> &ptr) {
Expand Down

0 comments on commit 052a22c

Please sign in to comment.