Skip to content

Commit

Permalink
Minor refactoring- Rename the variants of LogBatchData enum (#2490)
Browse files Browse the repository at this point in the history
  • Loading branch information
utpilla authored Jan 1, 2025
1 parent 17855be commit 42b4f2f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions opentelemetry-sdk/src/export/logs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ pub struct LogBatch<'a> {
/// - Or it can be a shared reference to a slice of tuples, where each tuple consists of a reference to a `LogRecord` and a reference to an `InstrumentationScope`.
#[derive(Debug)]
enum LogBatchData<'a> {
BorrowedVec(&'a [Box<(LogRecord, InstrumentationScope)>]), // Used by BatchProcessor which clones the LogRecords for its own use.
BorrowedSlice(&'a [(&'a LogRecord, &'a InstrumentationScope)]),
SliceOfOwnedData(&'a [Box<(LogRecord, InstrumentationScope)>]), // Used by BatchProcessor which clones the LogRecords for its own use.
SliceOfBorrowedData(&'a [(&'a LogRecord, &'a InstrumentationScope)]),
}

impl<'a> LogBatch<'a> {
Expand All @@ -48,15 +48,15 @@ impl<'a> LogBatch<'a> {
/// made private in the future.
pub fn new(data: &'a [(&'a LogRecord, &'a InstrumentationScope)]) -> LogBatch<'a> {
LogBatch {
data: LogBatchData::BorrowedSlice(data),
data: LogBatchData::SliceOfBorrowedData(data),
}
}

pub(crate) fn new_with_owned_data(
data: &'a [Box<(LogRecord, InstrumentationScope)>],
) -> LogBatch<'a> {
LogBatch {
data: LogBatchData::BorrowedVec(data),
data: LogBatchData::SliceOfOwnedData(data),
}
}
}
Expand Down Expand Up @@ -89,7 +89,7 @@ impl<'a> Iterator for LogBatchDataIter<'a> {

fn next(&mut self) -> Option<Self::Item> {
match self.data {
LogBatchData::BorrowedVec(data) => {
LogBatchData::SliceOfOwnedData(data) => {
if self.index < data.len() {
let record = &*data[self.index];
self.index += 1;
Expand All @@ -98,7 +98,7 @@ impl<'a> Iterator for LogBatchDataIter<'a> {
None
}
}
LogBatchData::BorrowedSlice(data) => {
LogBatchData::SliceOfBorrowedData(data) => {
if self.index < data.len() {
let record = &data[self.index];
self.index += 1;
Expand Down

0 comments on commit 42b4f2f

Please sign in to comment.