Skip to content

Commit 3d7e6b9

Browse files
authored
Merge branch 'main' into cijothomas/otlptonic-improvelog
2 parents b08f658 + c7e47de commit 3d7e6b9

File tree

11 files changed

+24
-52
lines changed

11 files changed

+24
-52
lines changed

opentelemetry-http/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
- Implementation of `Extractor::get_all` for `HeaderExtractor`
66
- Support `HttpClient` implementation for `HyperClient<C>` with custom connectors beyond `HttpConnector`, enabling Unix Domain Socket connections and other custom transports
7+
- Add `reqwest` and `reqwest-blocking` features to enable async and blocking
8+
reqwest HTTP clients
79

810
## 0.30.0
911

opentelemetry-http/Cargo.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ autobenches = false
1313
[features]
1414
default = ["internal-logs"]
1515
hyper = ["dep:http-body-util", "dep:hyper", "dep:hyper-util", "dep:tokio"]
16-
reqwest-rustls = ["reqwest", "reqwest/rustls-tls-native-roots"]
17-
reqwest-rustls-webpki-roots = ["reqwest", "reqwest/rustls-tls-webpki-roots"]
16+
reqwest = ["dep:reqwest"]
17+
reqwest-blocking = ["dep:reqwest", "reqwest/blocking"]
18+
reqwest-rustls = ["dep:reqwest", "reqwest/rustls-tls-native-roots"]
19+
reqwest-rustls-webpki-roots = ["dep:reqwest", "reqwest/rustls-tls-webpki-roots"]
1820
internal-logs = ["opentelemetry/internal-logs"]
1921

2022
[dependencies]
@@ -25,7 +27,7 @@ http-body-util = { workspace = true, optional = true }
2527
hyper = { workspace = true, optional = true }
2628
hyper-util = { workspace = true, features = ["client-legacy", "http1", "http2"], optional = true }
2729
opentelemetry = { workspace = true, features = ["trace"] }
28-
reqwest = { workspace = true, features = ["blocking"], optional = true }
30+
reqwest = { workspace = true, optional = true }
2931
tokio = { workspace = true, features = ["time"], optional = true }
3032

3133
[lints]

opentelemetry-http/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ mod reqwest {
108108
}
109109

110110
#[cfg(not(target_arch = "wasm32"))]
111+
#[cfg(feature = "reqwest-blocking")]
111112
#[async_trait]
112113
impl HttpClient for reqwest::blocking::Client {
113114
async fn send_bytes(&self, request: Request<Bytes>) -> Result<Response<Bytes>, HttpError> {

opentelemetry-otlp/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ tls-webpki-roots = ["tls", "tonic/tls-webpki-roots"]
8383
# http binary
8484
http-proto = ["prost", "opentelemetry-http", "opentelemetry-proto/gen-tonic-messages", "http", "trace", "metrics"]
8585
http-json = ["serde_json", "prost", "opentelemetry-http", "opentelemetry-proto/gen-tonic-messages", "opentelemetry-proto/with-serde", "http", "trace", "metrics"]
86-
reqwest-blocking-client = ["reqwest/blocking", "opentelemetry-http/reqwest"]
86+
reqwest-blocking-client = ["reqwest/blocking", "opentelemetry-http/reqwest-blocking"]
8787
reqwest-client = ["reqwest", "opentelemetry-http/reqwest"]
8888
reqwest-rustls = ["reqwest", "opentelemetry-http/reqwest-rustls"]
8989
reqwest-rustls-webpki-roots = ["reqwest", "opentelemetry-http/reqwest-rustls-webpki-roots"]

opentelemetry-otlp/src/exporter/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ fn default_headers() -> std::collections::HashMap<String, String> {
206206
let mut headers = std::collections::HashMap::new();
207207
headers.insert(
208208
"User-Agent".to_string(),
209-
format!("OTel OTLP Exporter Rust/{}", env!("CARGO_PKG_VERSION")),
209+
format!("OTel-OTLP-Exporter-Rust/{}", env!("CARGO_PKG_VERSION")),
210210
);
211211
headers
212212
}

opentelemetry-otlp/src/lib.rs

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
//!
4141
//! // Create a tracer provider with the exporter
4242
//! let tracer_provider = opentelemetry_sdk::trace::SdkTracerProvider::builder()
43-
//! .with_simple_exporter(otlp_exporter)
43+
//! .with_batch_exporter(otlp_exporter)
4444
//! .build();
4545
//!
4646
//! // Set it as the global provider
@@ -83,7 +83,7 @@
8383
//!
8484
//! // Create a tracer provider with the exporter
8585
//! let tracer_provider = opentelemetry_sdk::trace::SdkTracerProvider::builder()
86-
//! .with_simple_exporter(otlp_exporter)
86+
//! .with_batch_exporter(otlp_exporter)
8787
//! .build();
8888
//!
8989
//! // Set it as the global provider
@@ -116,7 +116,7 @@
116116
//! .build()
117117
//! .expect("Failed to create span exporter");
118118
//! opentelemetry_sdk::trace::SdkTracerProvider::builder()
119-
//! .with_simple_exporter(exporter)
119+
//! .with_batch_exporter(exporter)
120120
//! .build()
121121
//! });
122122
//!
@@ -203,40 +203,6 @@
203203
//! `http://localhost:9090`
204204
//! ## Show Logs, Metrics too (TODO)
205205
//!
206-
//! ## Performance
207-
//!
208-
//! For optimal performance, a batch exporting processor is recommended as the simple
209-
//! processor will export each span synchronously on dropping, and is only good
210-
//! for test/debug purposes.
211-
//!
212-
//! ```toml
213-
//! [dependencies]
214-
//! opentelemetry-otlp = { version = "*", features = ["grpc-tonic"] }
215-
//! ```
216-
//!
217-
//! ```no_run
218-
//! # #[cfg(all(feature = "trace", feature = "grpc-tonic"))]
219-
//! # {
220-
//! use opentelemetry::global;
221-
//! use opentelemetry::trace::Tracer;
222-
//!
223-
//! fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
224-
//! // First, create a OTLP exporter builder. Configure it as you need.
225-
//! let otlp_exporter = opentelemetry_otlp::SpanExporter::builder().with_tonic().build()?;
226-
//! // Then pass it into provider builder
227-
//! let _ = opentelemetry_sdk::trace::SdkTracerProvider::builder()
228-
//! .with_batch_exporter(otlp_exporter)
229-
//! .build();
230-
//! let tracer = global::tracer("my_tracer");
231-
//! tracer.in_span("doing_work", |cx| {
232-
//! // Traced app logic here...
233-
//! });
234-
//!
235-
//! Ok(())
236-
//! # }
237-
//! }
238-
//! ```
239-
//!
240206
//! [`tokio`]: https://tokio.rs
241207
//!
242208
//! # Feature Flags

opentelemetry-proto/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ testing = ["opentelemetry/testing"]
4949
# add ons
5050
internal-logs = ["opentelemetry/internal-logs"]
5151
with-schemars = ["schemars"]
52-
with-serde = ["serde", "const-hex", "base64"]
52+
with-serde = ["serde", "const-hex", "base64", "serde_json"]
5353

5454
[dependencies]
5555
tonic = { workspace = true, optional = true, features = ["codegen", "prost"] }
@@ -58,6 +58,7 @@ opentelemetry = { workspace = true }
5858
opentelemetry_sdk = { workspace = true }
5959
schemars = { workspace = true, optional = true }
6060
serde = { workspace = true, optional = true, features = ["serde_derive"] }
61+
serde_json = { workspace = true, optional = true }
6162
const-hex = { workspace = true, optional = true }
6263
base64 = { workspace = true, optional = true }
6364

opentelemetry-sdk/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pprof = { version = "0.14", features = ["flamegraph", "criterion"] }
4242
default = ["trace", "metrics", "logs", "internal-logs"]
4343
trace = ["opentelemetry/trace", "rand", "percent-encoding"]
4444
jaeger_remote_sampler = ["trace", "opentelemetry-http", "http", "serde", "serde_json", "url", "experimental_async_runtime"]
45-
logs = ["opentelemetry/logs", "serde_json"]
45+
logs = ["opentelemetry/logs"]
4646
spec_unstable_logs_enabled = ["logs", "opentelemetry/spec_unstable_logs_enabled"]
4747
metrics = ["opentelemetry/metrics"]
4848
testing = ["opentelemetry/testing", "trace", "metrics", "logs", "rt-tokio", "rt-tokio-current-thread", "tokio/macros", "tokio/rt-multi-thread"]

opentelemetry-sdk/src/logs/batch_log_processor.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ impl BatchLogProcessor {
360360
logs: &mut Vec<LogsData>,
361361
last_export_time: &mut Instant,
362362
current_batch_size: &AtomicUsize,
363-
config: &BatchConfig,
363+
max_export_size: usize,
364364
) -> OTelSdkResult
365365
where
366366
E: LogExporter + Send + Sync + 'static,
@@ -373,7 +373,7 @@ impl BatchLogProcessor {
373373
// Get upto `max_export_batch_size` amount of logs log records from the channel and push them to the logs vec
374374
while let Ok(log) = logs_receiver.try_recv() {
375375
logs.push(log);
376-
if logs.len() == config.max_export_batch_size {
376+
if logs.len() == max_export_size {
377377
break;
378378
}
379379
}
@@ -409,7 +409,7 @@ impl BatchLogProcessor {
409409
&mut logs,
410410
&mut last_export_time,
411411
&current_batch_size,
412-
&config,
412+
max_export_batch_size,
413413
);
414414
}
415415
Ok(BatchMessage::ForceFlush(sender)) => {
@@ -420,7 +420,7 @@ impl BatchLogProcessor {
420420
&mut logs,
421421
&mut last_export_time,
422422
&current_batch_size,
423-
&config,
423+
max_export_batch_size,
424424
);
425425
let _ = sender.send(result);
426426
}
@@ -432,7 +432,7 @@ impl BatchLogProcessor {
432432
&mut logs,
433433
&mut last_export_time,
434434
&current_batch_size,
435-
&config,
435+
max_export_batch_size,
436436
);
437437
let _ = exporter.shutdown();
438438
let _ = sender.send(result);
@@ -460,7 +460,7 @@ impl BatchLogProcessor {
460460
&mut logs,
461461
&mut last_export_time,
462462
&current_batch_size,
463-
&config,
463+
max_export_batch_size,
464464
);
465465
}
466466
Err(RecvTimeoutError::Disconnected) => {

opentelemetry-zipkin/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ rustdoc-args = ["--cfg", "docsrs"]
2222

2323
[features]
2424
default = ["reqwest-blocking-client", "reqwest/native-tls"]
25-
reqwest-blocking-client = ["reqwest/blocking", "opentelemetry-http/reqwest"]
25+
reqwest-blocking-client = ["reqwest/blocking", "opentelemetry-http/reqwest-blocking"]
2626
reqwest-client = ["reqwest", "opentelemetry-http/reqwest"]
2727
reqwest-rustls = ["reqwest", "reqwest/rustls-tls-native-roots"]
2828

0 commit comments

Comments
 (0)