Skip to content

Commit

Permalink
perf(export): do not use splice if fit in one batch
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuron authored and Ievgen Makukh committed Mar 20, 2024
1 parent c5b52e2 commit a4f45c7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ For experimental package changes, see the [experimental CHANGELOG](experimental/

### :rocket: (Enhancement)

perf(sdk-trace-base): do not allocate arrays if resource has no pending async attributes

### :bug: (Bug Fix)

* fix(sdk-metrics): increase the depth of the output to the console such that objects in the metric are printed fully to the console [#4522](https://github.com/open-telemetry/opentelemetry-js/pull/4522) @JacksonWeber
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,13 @@ export abstract class BatchSpanProcessorBase<T extends BufferConfig>
// Reset the finished spans buffer here because the next invocations of the _flush method
// could pass the same finished spans to the exporter if the buffer is cleared
// outside the execution of this callback.
const spans = this._finishedSpans.splice(0, this._maxExportBatchSize);
let spans: ReadableSpan[];
if (this._finishedSpans.length <= this._maxExportBatchSize) {
spans = this._finishedSpans;
this._finishedSpans = [];
} else {
spans = this._finishedSpans.splice(0, this._maxExportBatchSize);
}

const doExport = () =>
this._exporter.export(spans, result => {
Expand Down

0 comments on commit a4f45c7

Please sign in to comment.