Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

## Unreleased

### SDK

#### Traces

* Add `BatchSpanProcessor.create(SpanExporter)` convenience factory to mirror
`SimpleSpanProcessor.create(SpanExporter)`
([#8561](https://github.com/open-telemetry/opentelemetry-java/issues/8561))

## Version 1.63.0 (2026-06-05)

### API
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
Comparing source compatibility of opentelemetry-sdk-trace-1.64.0-SNAPSHOT.jar against opentelemetry-sdk-trace-1.63.0.jar
No changes.
*** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.sdk.trace.export.BatchSpanProcessor (not serializable)
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
+++ NEW METHOD: PUBLIC(+) STATIC(+) io.opentelemetry.sdk.trace.export.BatchSpanProcessor create(io.opentelemetry.sdk.trace.export.SpanExporter)
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

package io.opentelemetry.sdk.trace.export;

import static java.util.Objects.requireNonNull;

import io.opentelemetry.api.metrics.MeterProvider;
import io.opentelemetry.context.Context;
import io.opentelemetry.sdk.common.CompletableResultCode;
Expand Down Expand Up @@ -54,6 +56,24 @@ public final class BatchSpanProcessor implements SpanProcessor {
private final Worker worker;
private final AtomicBoolean isShutdown = new AtomicBoolean(false);

/**
* Returns a new {@link BatchSpanProcessor} with default configuration which batches spans
* exported by the SDK then pushes them to the {@code spanExporter}.
*
* <p>This is a convenience method equivalent to {@code
* BatchSpanProcessor.builder(spanExporter).build()}. Use {@link #builder(SpanExporter)} if you
* need to customize the configuration.
*
* @param spanExporter the {@link SpanExporter} to which the Spans are pushed.
* @return a new {@link BatchSpanProcessor}.
* @throws NullPointerException if the {@code spanExporter} is {@code null}.
* @since 1.64.0
*/
public static BatchSpanProcessor create(SpanExporter spanExporter) {
requireNonNull(spanExporter, "spanExporter");
return builder(spanExporter).build();
}

/**
* Returns a new Builder for {@link BatchSpanProcessor}.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,21 @@ void builderDefaults() {
TimeUnit.MILLISECONDS.toNanos(BatchSpanProcessorBuilder.DEFAULT_EXPORT_TIMEOUT_MILLIS));
}

@Test
void createDefaults() {
BatchSpanProcessor processor =
BatchSpanProcessor.create(new WaitingSpanExporter(0, CompletableResultCode.ofSuccess()));
assertThat(processor).isNotNull();
processor.shutdown().join(10, TimeUnit.SECONDS);
}

@Test
void createNull() {
assertThatThrownBy(() -> BatchSpanProcessor.create(null))
.isInstanceOf(NullPointerException.class)
.hasMessage("spanExporter");
}

@Test
void builderInvalidConfig() {
assertThatThrownBy(
Expand Down
Loading