Skip to content

Commit a526a70

Browse files
authored
Merge branch 'main' into patch
2 parents 338a0fd + 5c60f12 commit a526a70

File tree

13 files changed

+26
-28
lines changed

13 files changed

+26
-28
lines changed

opentelemetry-otlp/src/exporter/http/logs.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use http::{header::CONTENT_TYPE, Method};
33
use opentelemetry::otel_debug;
44
use opentelemetry_sdk::error::{OTelSdkError, OTelSdkResult};
55
use opentelemetry_sdk::logs::{LogBatch, LogExporter};
6+
use std::time;
67

78
impl LogExporter for OtlpHttpClient {
89
async fn export(&self, batch: LogBatch<'_>) -> OTelSdkResult {
@@ -46,7 +47,7 @@ impl LogExporter for OtlpHttpClient {
4647
Ok(())
4748
}
4849

49-
fn shutdown(&self) -> OTelSdkResult {
50+
fn shutdown_with_timeout(&self, _timeout: time::Duration) -> OTelSdkResult {
5051
let mut client_guard = self.client.lock().map_err(|e| {
5152
OTelSdkError::InternalFailure(format!("Failed to acquire client lock: {}", e))
5253
})?;

opentelemetry-otlp/src/exporter/tonic/logs.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use opentelemetry_proto::tonic::collector::logs::v1::{
55
};
66
use opentelemetry_sdk::error::{OTelSdkError, OTelSdkResult};
77
use opentelemetry_sdk::logs::{LogBatch, LogExporter};
8+
use std::time;
89
use tokio::sync::Mutex;
910
use tonic::{codegen::CompressionEncoding, service::Interceptor, transport::Channel, Request};
1011

@@ -84,7 +85,7 @@ impl LogExporter for TonicLogsClient {
8485
Ok(())
8586
}
8687

87-
fn shutdown(&self) -> OTelSdkResult {
88+
fn shutdown_with_timeout(&self, _timeout: time::Duration) -> OTelSdkResult {
8889
// TODO: Implement actual shutdown
8990
// Due to the use of tokio::sync::Mutex to guard
9091
// the inner client, we need to await the call to lock the mutex

opentelemetry-otlp/src/logs.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
55
#[cfg(feature = "grpc-tonic")]
66
use opentelemetry::otel_debug;
7-
use std::fmt::Debug;
8-
97
use opentelemetry_sdk::{error::OTelSdkResult, logs::LogBatch};
8+
use std::fmt::Debug;
9+
use std::time;
1010

1111
use crate::{ExporterBuildError, HasExportConfig, NoExporterBuilderSet};
1212

@@ -157,7 +157,7 @@ impl opentelemetry_sdk::logs::LogExporter for LogExporter {
157157
}
158158
}
159159

160-
fn shutdown(&self) -> OTelSdkResult {
160+
fn shutdown_with_timeout(&self, _timeout: time::Duration) -> OTelSdkResult {
161161
match &self.client {
162162
#[cfg(feature = "grpc-tonic")]
163163
SupportedTransportClient::Tonic(client) => client.shutdown(),

opentelemetry-sdk/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ also modified to suppress telemetry before invoking exporters.
2525
- Fixed the overflow attribute to correctly use the boolean value `true`
2626
instead of the string `"true"`.
2727
[#2878](https://github.com/open-telemetry/opentelemetry-rust/issues/2878)
28+
- The `shutdown_with_timeout` method is added to LogExporter trait.
2829
- *Breaking* `MetricError`, `MetricResult` no longer public (except when
2930
`spec_unstable_metrics_views` feature flag is enabled). `OTelSdkResult` should
3031
be used instead, wherever applicable. [#2906](https://github.com/open-telemetry/opentelemetry-rust/pull/2906)

opentelemetry-sdk/benches/log_enabled.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ impl LogExporter for NoopExporter {
2929
Ok(())
3030
}
3131

32-
fn shutdown(&self) -> OTelSdkResult {
33-
Ok(())
34-
}
35-
3632
#[inline]
3733
fn event_enabled(
3834
&self,

opentelemetry-sdk/src/logs/export.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use crate::Resource;
66
use opentelemetry::logs::Severity;
77
use opentelemetry::InstrumentationScope;
88
use std::fmt::Debug;
9+
use std::time;
910

1011
/// A batch of log records to be exported by a `LogExporter`.
1112
///
@@ -134,11 +135,14 @@ pub trait LogExporter: Send + Sync + Debug {
134135
&self,
135136
batch: LogBatch<'_>,
136137
) -> impl std::future::Future<Output = OTelSdkResult> + Send;
137-
138138
/// Shuts down the exporter.
139-
fn shutdown(&self) -> OTelSdkResult {
139+
fn shutdown_with_timeout(&self, _timeout: time::Duration) -> OTelSdkResult {
140140
Ok(())
141141
}
142+
/// Shuts down the exporter with a default timeout.
143+
fn shutdown(&self) -> OTelSdkResult {
144+
self.shutdown_with_timeout(time::Duration::from_secs(5))
145+
}
142146
#[cfg(feature = "spec_unstable_logs_enabled")]
143147
/// Check if logs are enabled.
144148
fn event_enabled(&self, _level: Severity, _target: &str, _name: Option<&str>) -> bool {

opentelemetry-sdk/src/logs/in_memory_exporter.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use opentelemetry::InstrumentationScope;
77
use std::borrow::Cow;
88
use std::sync::atomic::AtomicBool;
99
use std::sync::{Arc, Mutex};
10+
use std::time;
1011

1112
/// An in-memory logs exporter that stores logs data in memory..
1213
///
@@ -205,7 +206,7 @@ impl LogExporter for InMemoryLogExporter {
205206
Ok(())
206207
}
207208

208-
fn shutdown(&self) -> OTelSdkResult {
209+
fn shutdown_with_timeout(&self, _timeout: time::Duration) -> OTelSdkResult {
209210
self.shutdown_called
210211
.store(true, std::sync::atomic::Ordering::Relaxed);
211212
if self.should_reset_on_shutdown {

opentelemetry-sdk/src/logs/log_processor.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,6 @@ pub(crate) mod tests {
9292
Ok(())
9393
}
9494

95-
fn shutdown(&self) -> OTelSdkResult {
96-
Ok(())
97-
}
98-
9995
fn set_resource(&mut self, resource: &Resource) {
10096
self.resource
10197
.lock()

opentelemetry-sdk/src/logs/log_processor_with_async_runtime.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -321,10 +321,6 @@ mod tests {
321321
Ok(())
322322
}
323323

324-
fn shutdown(&self) -> OTelSdkResult {
325-
Ok(())
326-
}
327-
328324
fn set_resource(&mut self, resource: &Resource) {
329325
self.resource
330326
.lock()

opentelemetry-sdk/src/logs/logger_provider.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ mod tests {
291291
use std::fmt::{Debug, Formatter};
292292
use std::sync::atomic::AtomicU64;
293293
use std::sync::Mutex;
294-
use std::thread;
294+
use std::{thread, time};
295295

296296
struct ShutdownTestLogProcessor {
297297
is_shutdown: Arc<Mutex<bool>>,
@@ -364,7 +364,7 @@ mod tests {
364364
*res = resource.clone();
365365
}
366366

367-
fn shutdown(&self) -> OTelSdkResult {
367+
fn shutdown_with_timeout(&self, _timeout: time::Duration) -> OTelSdkResult {
368368
Ok(())
369369
}
370370
}

opentelemetry-sdk/src/logs/simple_log_processor.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ mod tests {
164164
use opentelemetry::KeyValue;
165165
use std::sync::atomic::{AtomicUsize, Ordering};
166166
use std::sync::{Arc, Mutex};
167+
use std::time;
167168
use std::time::Duration;
168169

169170
#[derive(Debug, Clone)]
@@ -195,6 +196,9 @@ mod tests {
195196
}
196197
Ok(())
197198
}
199+
fn shutdown_with_timeout(&self, _timeout: time::Duration) -> OTelSdkResult {
200+
Ok(())
201+
}
198202
}
199203

200204
#[test]
@@ -460,10 +464,6 @@ mod tests {
460464
}
461465

462466
impl LogExporter for ReentrantLogExporter {
463-
fn shutdown(&self) -> OTelSdkResult {
464-
Ok(())
465-
}
466-
467467
async fn export(&self, _batch: LogBatch<'_>) -> OTelSdkResult {
468468
let logger = self.logger.lock().unwrap();
469469
if let Some(logger) = logger.as_ref() {

opentelemetry-stdout/src/logs/exporter.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use opentelemetry_sdk::logs::LogBatch;
55
use opentelemetry_sdk::Resource;
66
use std::sync::atomic;
77
use std::sync::atomic::Ordering;
8+
use std::time;
89

910
/// An OpenTelemetry exporter that writes Logs to stdout on export.
1011
pub struct LogExporter {
@@ -57,7 +58,7 @@ impl opentelemetry_sdk::logs::LogExporter for LogExporter {
5758
}
5859
}
5960

60-
fn shutdown(&self) -> OTelSdkResult {
61+
fn shutdown_with_timeout(&self, _timeout: time::Duration) -> OTelSdkResult {
6162
self.is_shutdown.store(true, atomic::Ordering::SeqCst);
6263
Ok(())
6364
}

stress/src/logs.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use opentelemetry_sdk::logs::concurrent_log_processor::SimpleConcurrentLogProces
2424
use opentelemetry_sdk::logs::SdkLoggerProvider;
2525
use opentelemetry_sdk::logs::{LogBatch, LogExporter};
2626
use opentelemetry_sdk::Resource;
27+
use std::time;
2728
use tracing::error;
2829
use tracing_subscriber::prelude::*;
2930

@@ -52,7 +53,7 @@ impl LogExporter for NoopExporter {
5253
Ok(())
5354
}
5455

55-
fn shutdown(&self) -> OTelSdkResult {
56+
fn shutdown_with_timeout(&self, _timeout: time::Duration) -> OTelSdkResult {
5657
Ok(())
5758
}
5859

0 commit comments

Comments
 (0)