Skip to content

Commit 7ca4a85

Browse files
lalitbcijothomas
andauthored
Remove export timeout configuration for BatchSpanProcessor (#2596)
Co-authored-by: Cijo Thomas <cijo.thomas@gmail.com>
1 parent 6c88d31 commit 7ca4a85

File tree

2 files changed

+38
-14
lines changed

2 files changed

+38
-14
lines changed

opentelemetry-sdk/CHANGELOG.md

+33
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,39 @@ let processor = BatchLogProcessor::builder(exporter)
337337
.build();
338338
```
339339

340+
- *Breaking*: The `BatchSpanProcessor` no longer supports configuration of `max_export_timeout`
341+
or the `OTEL_BLRP_EXPORT_TIMEOUT` environment variable. Timeout handling is now the
342+
responsibility of the exporter.
343+
For example, in the OTLP Span exporter, the export timeout can be configured using:
344+
- The environment variables `OTEL_EXPORTER_OTLP_TIMEOUT` or `OTEL_EXPORTER_OTLP_TRACES_TIMEOUT`.
345+
- The opentelemetry_otlp API, via `.with_tonic().with_timeout()` or `.with_http().with_timeout()`.
346+
Before:
347+
```rust
348+
let processor = BatchSpanProcessor::builder(exporter)
349+
.with_batch_config(
350+
BatchConfigBuilder::default()
351+
.with_max_queue_size(2048)
352+
.with_max_export_batch_size(512)
353+
.with_scheduled_delay(Duration::from_secs(5))
354+
.with_max_export_timeout(Duration::from_secs(30)) // Previously configurable
355+
.build(),
356+
)
357+
.build();
358+
```
359+
360+
After:
361+
```rust
362+
let processor = BatchSpanProcessor::builder(exporter)
363+
.with_batch_config(
364+
BatchConfigBuilder::default()
365+
.with_max_queue_size(2048)
366+
.with_max_export_batch_size(512)
367+
.with_scheduled_delay(Duration::from_secs(5)) // No `max_export_timeout`
368+
.build(),
369+
)
370+
.build();
371+
```
372+
340373
## 0.27.1
341374

342375
Released 2024-Nov-27

opentelemetry-sdk/src/trace/span_processor.rs

+5-14
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,6 @@ use crate::trace::ExportResult;
217217
/// .with_max_queue_size(1024) // Buffer up to 1024 spans.
218218
/// .with_max_export_batch_size(256) // Export in batches of up to 256 spans.
219219
/// .with_scheduled_delay(Duration::from_secs(5)) // Export every 5 seconds.
220-
/// .with_max_export_timeout(Duration::from_secs(10)) // Timeout after 10 seconds.
221220
/// .build(),
222221
/// )
223222
/// .build();
@@ -443,20 +442,14 @@ impl BatchSpanProcessor {
443442
}
444443

445444
let count_of_spans = spans.len(); // Count of spans that will be exported
446-
let result = Self::export_with_timeout_sync(
447-
config.max_export_timeout,
448-
exporter,
449-
spans,
450-
last_export_time,
451-
); // This method clears the spans vec after exporting
445+
let result = Self::export_batch_sync(exporter, spans, last_export_time); // This method clears the spans vec after exporting
452446

453447
current_batch_size.fetch_sub(count_of_spans, Ordering::Relaxed);
454448
result
455449
}
456450

457451
#[allow(clippy::vec_box)]
458-
fn export_with_timeout_sync<E>(
459-
_: Duration, // TODO, enforcing timeout in exporter.
452+
fn export_batch_sync<E>(
460453
exporter: &mut E,
461454
batch: &mut Vec<SpanData>,
462455
last_export_time: &mut Instant,
@@ -740,6 +733,7 @@ impl BatchConfigBuilder {
740733
/// Set max_export_timeout for [`BatchConfigBuilder`].
741734
/// It's the maximum duration to export a batch of data.
742735
/// The The default value is 30000 milliseconds.
736+
#[cfg(feature = "experimental_trace_batch_span_processor_with_async_runtime")]
743737
pub fn with_max_export_timeout(mut self, max_export_timeout: Duration) -> Self {
744738
self.max_export_timeout = max_export_timeout;
745739
self
@@ -960,10 +954,11 @@ mod tests {
960954
let batch = BatchConfigBuilder::default()
961955
.with_max_export_batch_size(10)
962956
.with_scheduled_delay(Duration::from_millis(10))
963-
.with_max_export_timeout(Duration::from_millis(10))
964957
.with_max_queue_size(10);
965958
#[cfg(feature = "experimental_trace_batch_span_processor_with_async_runtime")]
966959
let batch = batch.with_max_concurrent_exports(10);
960+
#[cfg(feature = "experimental_trace_batch_span_processor_with_async_runtime")]
961+
let batch = batch.with_max_export_timeout(Duration::from_millis(10));
967962
let batch = batch.build();
968963
assert_eq!(batch.max_export_batch_size, 10);
969964
assert_eq!(batch.scheduled_delay, Duration::from_millis(10));
@@ -1037,7 +1032,6 @@ mod tests {
10371032
.with_max_queue_size(10)
10381033
.with_max_export_batch_size(10)
10391034
.with_scheduled_delay(Duration::from_secs(5))
1040-
.with_max_export_timeout(Duration::from_secs(2))
10411035
.build();
10421036
let processor = BatchSpanProcessor::new(exporter, config);
10431037

@@ -1060,7 +1054,6 @@ mod tests {
10601054
.with_max_queue_size(10)
10611055
.with_max_export_batch_size(10)
10621056
.with_scheduled_delay(Duration::from_secs(5))
1063-
.with_max_export_timeout(Duration::from_secs(2))
10641057
.build();
10651058
let processor = BatchSpanProcessor::new(exporter, config);
10661059

@@ -1090,7 +1083,6 @@ mod tests {
10901083
.with_max_queue_size(10)
10911084
.with_max_export_batch_size(10)
10921085
.with_scheduled_delay(Duration::from_secs(5))
1093-
.with_max_export_timeout(Duration::from_secs(2))
10941086
.build();
10951087
let processor = BatchSpanProcessor::new(exporter, config);
10961088

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

0 commit comments

Comments
 (0)