Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove export timeout configuration for BatchSpanProcessor #2596

Merged
Merged
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
33 changes: 33 additions & 0 deletions opentelemetry-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,39 @@ let processor = BatchLogProcessor::builder(exporter)
.build();
```

- *Breaking*: The `BatchSpanProcessor` no longer supports configuration of `max_export_timeout`
or the `OTEL_BLRP_EXPORT_TIMEOUT` environment variable. Timeout handling is now the
responsibility of the exporter.
For example, in the OTLP Span exporter, the export timeout can be configured using:
- The environment variables `OTEL_EXPORTER_OTLP_TIMEOUT` or `OTEL_EXPORTER_OTLP_TRACES_TIMEOUT`.
- The opentelemetry_otlp API, via `.with_tonic().with_timeout()` or `.with_http().with_timeout()`.
Before:
```rust
let processor = BatchSpanProcessor::builder(exporter)
.with_batch_config(
BatchConfigBuilder::default()
.with_max_queue_size(2048)
.with_max_export_batch_size(512)
.with_scheduled_delay(Duration::from_secs(5))
.with_max_export_timeout(Duration::from_secs(30)) // Previously configurable
.build(),
)
.build();
```

After:
```rust
let processor = BatchSpanProcessor::builder(exporter)
.with_batch_config(
BatchConfigBuilder::default()
.with_max_queue_size(2048)
.with_max_export_batch_size(512)
.with_scheduled_delay(Duration::from_secs(5)) // No `max_export_timeout`
.build(),
)
.build();
```

## 0.27.1

Released 2024-Nov-27
Expand Down
19 changes: 5 additions & 14 deletions opentelemetry-sdk/src/trace/span_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ use crate::trace::ExportResult;
/// .with_max_queue_size(1024) // Buffer up to 1024 spans.
/// .with_max_export_batch_size(256) // Export in batches of up to 256 spans.
/// .with_scheduled_delay(Duration::from_secs(5)) // Export every 5 seconds.
/// .with_max_export_timeout(Duration::from_secs(10)) // Timeout after 10 seconds.
/// .build(),
/// )
/// .build();
Expand Down Expand Up @@ -443,20 +442,14 @@ impl BatchSpanProcessor {
}

let count_of_spans = spans.len(); // Count of spans that will be exported
let result = Self::export_with_timeout_sync(
config.max_export_timeout,
exporter,
spans,
last_export_time,
); // This method clears the spans vec after exporting
let result = Self::export_batch_sync(exporter, spans, last_export_time); // This method clears the spans vec after exporting

current_batch_size.fetch_sub(count_of_spans, Ordering::Relaxed);
result
}

#[allow(clippy::vec_box)]
fn export_with_timeout_sync<E>(
_: Duration, // TODO, enforcing timeout in exporter.
fn export_batch_sync<E>(
exporter: &mut E,
batch: &mut Vec<SpanData>,
last_export_time: &mut Instant,
Expand Down Expand Up @@ -740,6 +733,7 @@ impl BatchConfigBuilder {
/// Set max_export_timeout for [`BatchConfigBuilder`].
/// It's the maximum duration to export a batch of data.
/// The The default value is 30000 milliseconds.
#[cfg(feature = "experimental_trace_batch_span_processor_with_async_runtime")]
pub fn with_max_export_timeout(mut self, max_export_timeout: Duration) -> Self {
self.max_export_timeout = max_export_timeout;
self
Expand Down Expand Up @@ -960,10 +954,11 @@ mod tests {
let batch = BatchConfigBuilder::default()
.with_max_export_batch_size(10)
.with_scheduled_delay(Duration::from_millis(10))
.with_max_export_timeout(Duration::from_millis(10))
.with_max_queue_size(10);
#[cfg(feature = "experimental_trace_batch_span_processor_with_async_runtime")]
let batch = batch.with_max_concurrent_exports(10);
#[cfg(feature = "experimental_trace_batch_span_processor_with_async_runtime")]
let batch = batch.with_max_export_timeout(Duration::from_millis(10));
let batch = batch.build();
assert_eq!(batch.max_export_batch_size, 10);
assert_eq!(batch.scheduled_delay, Duration::from_millis(10));
Expand Down Expand Up @@ -1037,7 +1032,6 @@ mod tests {
.with_max_queue_size(10)
.with_max_export_batch_size(10)
.with_scheduled_delay(Duration::from_secs(5))
.with_max_export_timeout(Duration::from_secs(2))
.build();
let processor = BatchSpanProcessor::new(exporter, config);

Expand All @@ -1060,7 +1054,6 @@ mod tests {
.with_max_queue_size(10)
.with_max_export_batch_size(10)
.with_scheduled_delay(Duration::from_secs(5))
.with_max_export_timeout(Duration::from_secs(2))
.build();
let processor = BatchSpanProcessor::new(exporter, config);

Expand Down Expand Up @@ -1090,7 +1083,6 @@ mod tests {
.with_max_queue_size(10)
.with_max_export_batch_size(10)
.with_scheduled_delay(Duration::from_secs(5))
.with_max_export_timeout(Duration::from_secs(2))
.build();
let processor = BatchSpanProcessor::new(exporter, config);

Expand Down Expand Up @@ -1126,7 +1118,6 @@ mod tests {
let config = BatchConfigBuilder::default()
.with_max_queue_size(2) // Small queue size to test span dropping
.with_scheduled_delay(Duration::from_secs(5))
.with_max_export_timeout(Duration::from_secs(2))
.build();
let processor = BatchSpanProcessor::new(exporter, config);

Expand Down