Skip to content

Commit 89c0849

Browse files
authored
Merge branch 'main' into cijothomas/doc-tokio-current
2 parents 92a4fb5 + 7ca4a85 commit 89c0849

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();
@@ -474,20 +473,14 @@ impl BatchSpanProcessor {
474473
}
475474

476475
let count_of_spans = spans.len(); // Count of spans that will be exported
477-
let result = Self::export_with_timeout_sync(
478-
config.max_export_timeout,
479-
exporter,
480-
spans,
481-
last_export_time,
482-
); // This method clears the spans vec after exporting
476+
let result = Self::export_batch_sync(exporter, spans, last_export_time); // This method clears the spans vec after exporting
483477

484478
current_batch_size.fetch_sub(count_of_spans, Ordering::Relaxed);
485479
result
486480
}
487481

488482
#[allow(clippy::vec_box)]
489-
fn export_with_timeout_sync<E>(
490-
_: Duration, // TODO, enforcing timeout in exporter.
483+
fn export_batch_sync<E>(
491484
exporter: &mut E,
492485
batch: &mut Vec<SpanData>,
493486
last_export_time: &mut Instant,
@@ -771,6 +764,7 @@ impl BatchConfigBuilder {
771764
/// Set max_export_timeout for [`BatchConfigBuilder`].
772765
/// It's the maximum duration to export a batch of data.
773766
/// The The default value is 30000 milliseconds.
767+
#[cfg(feature = "experimental_trace_batch_span_processor_with_async_runtime")]
774768
pub fn with_max_export_timeout(mut self, max_export_timeout: Duration) -> Self {
775769
self.max_export_timeout = max_export_timeout;
776770
self
@@ -991,10 +985,11 @@ mod tests {
991985
let batch = BatchConfigBuilder::default()
992986
.with_max_export_batch_size(10)
993987
.with_scheduled_delay(Duration::from_millis(10))
994-
.with_max_export_timeout(Duration::from_millis(10))
995988
.with_max_queue_size(10);
996989
#[cfg(feature = "experimental_trace_batch_span_processor_with_async_runtime")]
997990
let batch = batch.with_max_concurrent_exports(10);
991+
#[cfg(feature = "experimental_trace_batch_span_processor_with_async_runtime")]
992+
let batch = batch.with_max_export_timeout(Duration::from_millis(10));
998993
let batch = batch.build();
999994
assert_eq!(batch.max_export_batch_size, 10);
1000995
assert_eq!(batch.scheduled_delay, Duration::from_millis(10));
@@ -1068,7 +1063,6 @@ mod tests {
10681063
.with_max_queue_size(10)
10691064
.with_max_export_batch_size(10)
10701065
.with_scheduled_delay(Duration::from_secs(5))
1071-
.with_max_export_timeout(Duration::from_secs(2))
10721066
.build();
10731067
let processor = BatchSpanProcessor::new(exporter, config);
10741068

@@ -1091,7 +1085,6 @@ mod tests {
10911085
.with_max_queue_size(10)
10921086
.with_max_export_batch_size(10)
10931087
.with_scheduled_delay(Duration::from_secs(5))
1094-
.with_max_export_timeout(Duration::from_secs(2))
10951088
.build();
10961089
let processor = BatchSpanProcessor::new(exporter, config);
10971090

@@ -1121,7 +1114,6 @@ mod tests {
11211114
.with_max_queue_size(10)
11221115
.with_max_export_batch_size(10)
11231116
.with_scheduled_delay(Duration::from_secs(5))
1124-
.with_max_export_timeout(Duration::from_secs(2))
11251117
.build();
11261118
let processor = BatchSpanProcessor::new(exporter, config);
11271119

@@ -1157,7 +1149,6 @@ mod tests {
11571149
let config = BatchConfigBuilder::default()
11581150
.with_max_queue_size(2) // Small queue size to test span dropping
11591151
.with_scheduled_delay(Duration::from_secs(5))
1160-
.with_max_export_timeout(Duration::from_secs(2))
11611152
.build();
11621153
let processor = BatchSpanProcessor::new(exporter, config);
11631154

0 commit comments

Comments
 (0)