Skip to content

Commit 86632ca

Browse files
committed
refactor: use split_last for multi-processor path, fix changelog
Use split_last() instead of index tracking for the multi-processor on_end loop. Removes unnecessary break statement and makes the clone-for-rest, move-for-last intent explicit. Fix changelog entry to describe what actually changed without overstating the scope clone savings.
1 parent 661c0e3 commit 86632ca

2 files changed

Lines changed: 5 additions & 9 deletions

File tree

opentelemetry-sdk/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## vNext
44

5-
- Store `InstrumentationScope` in `Arc` internally in `SdkTracer`, making tracer cloning cheaper and avoiding redundant scope clones in the multi-processor span export path.
5+
- Store `InstrumentationScope` in `Arc` internally in `SdkTracer`, making tracer clones cheaper (Arc refcount increment instead of deep copy). The multi-processor span export path now builds export data once instead of per processor.
66
- Add 32-bit platform support by using `portable-atomic` for `AtomicI64` and `AtomicU64` in the metrics module. This enables compilation on 32-bit ARM targets (e.g., `armv5te-unknown-linux-gnueabi`, `armv7-unknown-linux-gnueabihf`).
77
- `Aggregation` enum and `StreamBuilder::with_aggregation()` are now stable and no longer require the `spec_unstable_metrics_views` feature flag.
88
- Fix `service.name` Resource attribute fallback to follow OpenTelemetry

opentelemetry-sdk/src/trace/span.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -231,15 +231,11 @@ impl Span {
231231
processors => {
232232
let export_data =
233233
build_export_data(data, self.span_context.clone(), &self.tracer);
234-
let last_idx = processors.len() - 1;
235-
for (i, processor) in processors.iter().enumerate() {
236-
if i < last_idx {
237-
processor.on_end(export_data.clone());
238-
} else {
239-
processor.on_end(export_data);
240-
break;
241-
}
234+
let (last, rest) = processors.split_last().unwrap();
235+
for processor in rest {
236+
processor.on_end(export_data.clone());
242237
}
238+
last.on_end(export_data);
243239
}
244240
}
245241
}

0 commit comments

Comments
 (0)