Skip to content

Commit 3057685

Browse files
committed
make shutdown_with_timeout required on LogProcessor
1 parent 353bbb0 commit 3057685

File tree

9 files changed

+35
-10
lines changed

9 files changed

+35
-10
lines changed

examples/tracing-http-propagator/src/server.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ impl LogProcessor for EnrichWithBaggageLogProcessor {
121121
fn force_flush(&self) -> OTelSdkResult {
122122
Ok(())
123123
}
124+
125+
fn shutdown_with_timeout(&self, _timeout: Duration) -> OTelSdkResult {
126+
Ok(())
127+
}
124128
}
125129

126130
/// A custom span processor that enriches spans with baggage attributes. Baggage

opentelemetry-appender-tracing/src/layer.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -931,6 +931,10 @@ mod tests {
931931
fn force_flush(&self) -> OTelSdkResult {
932932
Ok(())
933933
}
934+
935+
fn shutdown_with_timeout(&self, _timeout: std::time::Duration) -> OTelSdkResult {
936+
Ok(())
937+
}
934938
}
935939

936940
#[cfg(feature = "spec_unstable_logs_enabled")]

opentelemetry-proto/src/transform/logs.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,10 @@ mod tests {
241241
fn force_flush(&self) -> OTelSdkResult {
242242
Ok(())
243243
}
244+
245+
fn shutdown_with_timeout(&self, _timeout: std::time::Duration) -> OTelSdkResult {
246+
Ok(())
247+
}
244248
}
245249

246250
fn create_test_log_data(

opentelemetry-sdk/CHANGELOG.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
between logs and traces continues to work when the "trace" feature is
1515
explicitly enabled.
1616

17+
- *Breaking* default implementation of `LogProcessor::shutdown_with_timeout()` method is removed. Implementors must now provide this to guarantee shutdown is performed properly.
18+
1719
## 0.30.0
1820

1921
Released 2025-May-23
@@ -35,7 +37,7 @@ also modified to suppress telemetry before invoking exporters.
3537

3638
- **Feature**: Implemented and enabled cardinality capping for Metrics by
3739
default. [#2901](https://github.com/open-telemetry/opentelemetry-rust/pull/2901)
38-
- The default cardinality limit is 2000 and can be customized using Views.
40+
- The default cardinality limit is 2000 and can be customized using Views.
3941
- This feature was previously removed in version 0.28 due to the lack of
4042
configurability but has now been reintroduced with the ability to configure
4143
the limit.
@@ -176,7 +178,7 @@ Released 2025-Mar-21
176178
```
177179

178180
After:
179-
181+
180182
```rust
181183
async fn export(&self, batch: Vec<SpanData>) -> OTelSdkResult
182184
```

opentelemetry-sdk/src/logs/log_processor.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@ pub trait LogProcessor: Send + Sync + Debug {
5757
/// Shuts down the processor.
5858
/// After shutdown returns the log processor should stop processing any logs.
5959
/// It's up to the implementation on when to drop the LogProcessor.
60-
fn shutdown_with_timeout(&self, _timeout: Duration) -> OTelSdkResult {
61-
Ok(())
62-
}
60+
fn shutdown_with_timeout(&self, _timeout: Duration) -> OTelSdkResult;
6361
/// Shuts down the processor with default timeout.
6462
fn shutdown(&self) -> OTelSdkResult {
6563
self.shutdown_with_timeout(Duration::from_secs(5))
@@ -140,6 +138,10 @@ pub(crate) mod tests {
140138
fn force_flush(&self) -> OTelSdkResult {
141139
Ok(())
142140
}
141+
142+
fn shutdown_with_timeout(&self, _timeout: std::time::Duration) -> OTelSdkResult {
143+
Ok(())
144+
}
143145
}
144146

145147
#[derive(Debug)]
@@ -166,6 +168,10 @@ pub(crate) mod tests {
166168
fn force_flush(&self) -> OTelSdkResult {
167169
Ok(())
168170
}
171+
172+
fn shutdown_with_timeout(&self, _timeout: std::time::Duration) -> OTelSdkResult {
173+
Ok(())
174+
}
169175
}
170176

171177
#[test]

opentelemetry-sdk/src/logs/log_processor_with_async_runtime.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl<R: RuntimeChannel> LogProcessor for BatchLogProcessor<R> {
8787
.and_then(std::convert::identity)
8888
}
8989

90-
fn shutdown(&self) -> OTelSdkResult {
90+
fn shutdown_with_timeout(&self, _timeout: Duration) -> OTelSdkResult {
9191
let dropped_logs = self.dropped_logs_count.load(Ordering::Relaxed);
9292
let max_queue_size = self.max_queue_size;
9393
if dropped_logs > 0 {

opentelemetry-sdk/src/logs/logger_provider.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,10 @@ mod tests {
402402
*res = resource.clone();
403403
self.exporter.set_resource(resource);
404404
}
405+
406+
fn shutdown_with_timeout(&self, _timeout: Duration) -> OTelSdkResult {
407+
Ok(())
408+
}
405409
}
406410
impl TestProcessorForResource {
407411
fn new(exporter: TestExporterForResource) -> Self {

opentelemetry-sdk/src/logs/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ mod tests {
171171
Ok(())
172172
}
173173

174-
fn shutdown(&self) -> crate::error::OTelSdkResult {
174+
fn shutdown_with_timeout(&self, _timeout: std::time::Duration) -> OTelSdkResult {
175175
Ok(())
176176
}
177177
}
@@ -277,7 +277,7 @@ mod tests {
277277
Ok(())
278278
}
279279

280-
fn shutdown(&self) -> OTelSdkResult {
280+
fn shutdown_with_timeout(&self, _timeout: std::time::Duration) -> OTelSdkResult {
281281
Ok(())
282282
}
283283
}

opentelemetry-sdk/src/logs/simple_log_processor.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ use opentelemetry::{otel_debug, otel_error, otel_warn, Context, InstrumentationS
2828
use std::fmt::Debug;
2929
use std::sync::atomic::AtomicBool;
3030
use std::sync::Mutex;
31+
use std::time::Duration;
3132

3233
/// A [`LogProcessor`] designed for testing and debugging purpose, that immediately
3334
/// exports log records as they are emitted. Log records are exported synchronously
@@ -116,11 +117,11 @@ impl<T: LogExporter> LogProcessor for SimpleLogProcessor<T> {
116117
Ok(())
117118
}
118119

119-
fn shutdown(&self) -> OTelSdkResult {
120+
fn shutdown_with_timeout(&self, timeout: Duration) -> OTelSdkResult {
120121
self.is_shutdown
121122
.store(true, std::sync::atomic::Ordering::Relaxed);
122123
if let Ok(exporter) = self.exporter.lock() {
123-
exporter.shutdown()
124+
exporter.shutdown_with_timeout(timeout)
124125
} else {
125126
Err(OTelSdkError::InternalFailure(
126127
"SimpleLogProcessor mutex poison at shutdown".into(),

0 commit comments

Comments
 (0)