Skip to content

Commit 4429bf2

Browse files
committed
initial commit
1 parent a1860eb commit 4429bf2

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
@@ -304,6 +304,39 @@ limit.
304304
`opentelemetry_sdk::trace::{InMemorySpanExporter, InMemorySpanExporterBuilder};`
305305
`opentelemetry_sdk::metrics::{InMemoryMetricExporter, InMemoryMetricExporterBuilder};`
306306

307+
- *Breaking*: The `BatchSpanProcessor` no longer supports configuration of `max_export_timeout`
308+
or the `OTEL_BLRP_EXPORT_TIMEOUT` environment variable. Timeout handling is now the
309+
responsibility of the exporter.
310+
For example, in the OTLP Span exporter, the export timeout can be configured using:
311+
- The environment variables `OTEL_EXPORTER_OTLP_TIMEOUT` or `OTEL_EXPORTER_OTLP_TRACES_TIMEOUT`.
312+
- The opentelemetry_otlp API, via `.with_tonic().with_timeout()` or `.with_http().with_timeout()`.
313+
Before:
314+
```rust
315+
let processor = BatchSpanProcessor::builder(exporter)
316+
.with_batch_config(
317+
BatchConfigBuilder::default()
318+
.with_max_queue_size(2048)
319+
.with_max_export_batch_size(512)
320+
.with_scheduled_delay(Duration::from_secs(5))
321+
.with_max_export_timeout(Duration::from_secs(30)) // Previously configurable
322+
.build(),
323+
)
324+
.build();
325+
```
326+
327+
After:
328+
```rust
329+
let processor = BatchSpanProcessor::builder(exporter)
330+
.with_batch_config(
331+
BatchConfigBuilder::default()
332+
.with_max_queue_size(2048)
333+
.with_max_export_batch_size(512)
334+
.with_scheduled_delay(Duration::from_secs(5)) // No `max_export_timeout`
335+
.build(),
336+
)
337+
.build();
338+
```
339+
307340
## 0.27.1
308341

309342
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)