Skip to content

Commit 48578a9

Browse files
authored
Merge branch 'main' into 2726-clonebreaking
2 parents 6a28b31 + 9dc727e commit 48578a9

File tree

18 files changed

+147
-37
lines changed

18 files changed

+147
-37
lines changed

.cspell.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@
2626
// workspace dictionary.
2727
"words": [
2828
"actix",
29+
"Antonsson",
2930
"anyvalue",
3031
"appender",
3132
"appenders",
3233
"autobenches",
3334
"Bhasin",
35+
"Björn",
3436
"BLRP",
3537
"Cijo",
3638
"clippy",

.github/workflows/ci.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,27 @@ jobs:
137137
egress-policy: audit
138138

139139
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
140-
- uses: EmbarkStudios/cargo-deny-action@34899fc7ba81ca6268d5947a7a16b4649013fea1 # v2.0.11
140+
141+
- name: Check advisories
142+
uses: EmbarkStudios/cargo-deny-action@34899fc7ba81ca6268d5947a7a16b4649013fea1 # v2.0.11
141143
with:
142144
command: check advisories
145+
146+
- name: Check licenses
147+
uses: EmbarkStudios/cargo-deny-action@34899fc7ba81ca6268d5947a7a16b4649013fea1 # v2.0.11
148+
with:
149+
command: check licenses
150+
151+
- name: Check bans
152+
uses: EmbarkStudios/cargo-deny-action@34899fc7ba81ca6268d5947a7a16b4649013fea1 # v2.0.11
153+
with:
154+
command: check bans
155+
156+
- name: Check sources
157+
uses: EmbarkStudios/cargo-deny-action@34899fc7ba81ca6268d5947a7a16b4649013fea1 # v2.0.11
158+
with:
159+
command: check sources
160+
143161
docs:
144162
continue-on-error: true
145163
runs-on: ubuntu-latest

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ you're more than welcome to participate!
189189
### Approvers
190190

191191
* [Anton Grübel](https://github.com/gruebel), Baz
192+
* [Björn Antonsson](https://github.com/bantonsson), Datadog
192193
* [Shaun Cox](https://github.com/shaun-cox), Microsoft
193194
* [Scott Gerring](https://github.com/scottgerring), Datadog
194195

deny.toml

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,30 @@ allow = [
77
"Apache-2.0",
88
"ISC",
99
"BSD-3-Clause",
10-
"OpenSSL"
10+
]
11+
12+
exceptions = [
13+
{ allow = ["MPL-2.0"], crate = "webpki-roots" }, # This crate is a dependency of `reqwest`.
14+
{ allow = ["Unicode-3.0"], crate = "icu_collections" }, # This crate gets used transitively by `reqwest`.
15+
{ allow = ["Unicode-3.0"], crate = "icu_locid" }, # This crate gets used transitively by `reqwest`.
16+
{ allow = ["Unicode-3.0"], crate = "icu_locid_transform" }, # This crate gets used transitively by `reqwest`.
17+
{ allow = ["Unicode-3.0"], crate = "icu_locid_transform_data" }, # This crate gets used transitively by `reqwest`.
18+
{ allow = ["Unicode-3.0"], crate = "icu_normalizer" }, # This crate gets used transitively by `reqwest`.
19+
{ allow = ["Unicode-3.0"], crate = "icu_normalizer_data" }, # This crate gets used transitively by `reqwest`.
20+
{ allow = ["Unicode-3.0"], crate = "icu_properties" }, # This crate gets used transitively by `reqwest`.
21+
{ allow = ["Unicode-3.0"], crate = "icu_properties_data" }, # This crate gets used transitively by `reqwest`.
22+
{ allow = ["Unicode-3.0"], crate = "icu_provider" }, # This crate gets used transitively by `reqwest`.
23+
{ allow = ["Unicode-3.0"], crate = "icu_provider_macros" }, # This crate gets used transitively by `reqwest`.
24+
{ allow = ["Unicode-3.0"], crate = "litemap" }, # This crate gets used transitively by `reqwest`.
25+
{ allow = ["Unicode-3.0"], crate = "tinystr" }, # This crate gets used transitively by `reqwest`.
26+
{ allow = ["Unicode-3.0"], crate = "writeable" }, # This crate gets used transitively by `reqwest`.
27+
{ allow = ["Unicode-3.0"], crate = "unicode-ident" }, # This crate gets used transitively by `reqwest` and other crates.
28+
{ allow = ["Unicode-3.0"], crate = "yoke" }, # This crate gets used transitively by `reqwest`.
29+
{ allow = ["Unicode-3.0"], crate = "yoke-derive" }, # This crate gets used transitively by `reqwest`.
30+
{ allow = ["Unicode-3.0"], crate = "zerovec" }, # This crate gets used transitively by `reqwest`.
31+
{ allow = ["Unicode-3.0"], crate = "zerovec-derive" }, # This crate gets used transitively by `reqwest`.
32+
{ allow = ["Unicode-3.0"], crate = "zerofrom" }, # This crate gets used transitively by `reqwest`.
33+
{ allow = ["Unicode-3.0"], crate = "zerofrom-derive" }, # This crate gets used transitively by `reqwest`.
1134
]
1235

1336
[licenses.private]
@@ -21,6 +44,31 @@ license-files = [
2144
{ path = "LICENSE", hash = 0xbd0eed23 }
2245
]
2346

47+
# This section is considered when running `cargo deny check advisories`
48+
# More documentation for the advisories section can be found here:
49+
# https://embarkstudios.github.io/cargo-deny/checks/advisories/cfg.html
2450
[advisories]
2551
unmaintained = "none"
26-
yanked = "allow"
52+
yanked = "deny"
53+
54+
# This section is considered when running `cargo deny check bans`.
55+
# More documentation about the 'bans' section can be found here:
56+
# https://embarkstudios.github.io/cargo-deny/checks/bans/cfg.html
57+
[bans]
58+
# Lint level for when multiple versions of the same crate are detected
59+
multiple-versions = "warn"
60+
# Lint level for when a crate version requirement is `*`
61+
wildcards = "warn"
62+
# The graph highlighting used when creating dotgraphs for crates
63+
# with multiple versions
64+
# * lowest-version - The path to the lowest versioned duplicate is highlighted
65+
# * simplest-path - The path to the version with the fewest edges is highlighted
66+
# * all - Both lowest-version and simplest-path are used
67+
highlight = "all"
68+
69+
# This section is considered when running `cargo deny check sources`.
70+
# More documentation about the 'sources' section can be found here:
71+
# https://embarkstudios.github.io/cargo-deny/checks/sources/cfg.html
72+
[sources]
73+
unknown-registry = "deny"
74+
unknown-git = "deny"

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/lib.rs

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,13 @@
3939
//! .build()?;
4040
//!
4141
//! // Create a tracer provider with the exporter
42-
//! let _ = opentelemetry_sdk::trace::SdkTracerProvider::builder()
42+
//! let tracer_provider = opentelemetry_sdk::trace::SdkTracerProvider::builder()
4343
//! .with_simple_exporter(otlp_exporter)
4444
//! .build();
4545
//!
46+
//! // Set it as the global provider
47+
//! global::set_tracer_provider(tracer_provider);
48+
//!
4649
//! // Get a tracer and create spans
4750
//! let tracer = global::tracer("my_tracer");
4851
//! tracer.in_span("doing_work", |_cx| {
@@ -62,31 +65,71 @@
6265
//! $ docker run -p 4317:4317 otel/opentelemetry-collector:latest
6366
//! ```
6467
//!
65-
//! Configure your application to export traces via gRPC:
68+
//! Configure your application to export traces via gRPC (the tonic client requires a Tokio runtime):
69+
//!
70+
//! - With `[tokio::main]`
6671
//!
6772
//! ```no_run
6873
//! # #[cfg(all(feature = "trace", feature = "grpc-tonic"))]
6974
//! # {
70-
//! use opentelemetry::global;
71-
//! use opentelemetry::trace::Tracer;
75+
//! use opentelemetry::{global, trace::Tracer};
7276
//!
73-
//! fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
77+
//! #[tokio::main]
78+
//! async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
7479
//! // Initialize OTLP exporter using gRPC (Tonic)
7580
//! let otlp_exporter = opentelemetry_otlp::SpanExporter::builder()
7681
//! .with_tonic()
7782
//! .build()?;
7883
//!
7984
//! // Create a tracer provider with the exporter
80-
//! let _ = opentelemetry_sdk::trace::SdkTracerProvider::builder()
85+
//! let tracer_provider = opentelemetry_sdk::trace::SdkTracerProvider::builder()
8186
//! .with_simple_exporter(otlp_exporter)
8287
//! .build();
8388
//!
89+
//! // Set it as the global provider
90+
//! global::set_tracer_provider(tracer_provider);
91+
//!
92+
//! // Get a tracer and create spans
93+
//! let tracer = global::tracer("my_tracer");
94+
//! tracer.in_span("doing_work", |_cx| {
95+
//! // Your application logic here...
96+
//! });
97+
//!
98+
//! Ok(())
99+
//! # }
100+
//! }
101+
//! ```
102+
//!
103+
//! - Without `[tokio::main]`
104+
//!
105+
//! ```no_run
106+
//! # #[cfg(all(feature = "trace", feature = "grpc-tonic"))]
107+
//! # {
108+
//! use opentelemetry::{global, trace::Tracer};
109+
//!
110+
//! fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
111+
//! // Initialize OTLP exporter using gRPC (Tonic)
112+
//! let rt = tokio::runtime::Runtime::new()?;
113+
//! let tracer_provider = rt.block_on(async {
114+
//! let exporter = opentelemetry_otlp::SpanExporter::builder()
115+
//! .with_tonic()
116+
//! .build()
117+
//! .expect("Failed to create span exporter");
118+
//! opentelemetry_sdk::trace::SdkTracerProvider::builder()
119+
//! .with_simple_exporter(exporter)
120+
//! .build()
121+
//! });
122+
//!
123+
//! // Set it as the global provider
124+
//! global::set_tracer_provider(tracer_provider);
125+
//!
84126
//! // Get a tracer and create spans
85127
//! let tracer = global::tracer("my_tracer");
86128
//! tracer.in_span("doing_work", |_cx| {
87129
//! // Your application logic here...
88130
//! });
89131
//!
132+
//! // Ensure the runtime (`rt`) remains active until the program ends
90133
//! Ok(())
91134
//! # }
92135
//! }

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() {

0 commit comments

Comments
 (0)