Skip to content

Commit 78767c7

Browse files
authored
Merge branch 'main' into copilot/fix-2444
2 parents 6bc03bc + e0dd566 commit 78767c7

File tree

34 files changed

+841
-273
lines changed

34 files changed

+841
-273
lines changed

opentelemetry-appender-tracing/src/layer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -674,8 +674,8 @@ mod tests {
674674
assert_eq!(trace_ctx1.span_id, inner_span_id);
675675

676676
// Set context from remote.
677-
let remote_trace_id = TraceId::from_u128(233);
678-
let remote_span_id = SpanId::from_u64(2333);
677+
let remote_trace_id = TraceId::from(233);
678+
let remote_span_id = SpanId::from(2333);
679679
let remote_span_context = SpanContext::new(
680680
remote_trace_id,
681681
remote_span_id,

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-jaeger-propagator/src/propagator.rs

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,8 @@ mod tests {
239239
SPAN_ID_STR,
240240
1,
241241
SpanContext::new(
242-
TraceId::from_u128(TRACE_ID),
243-
SpanId::from_u64(SPAN_ID),
242+
TraceId::from(TRACE_ID),
243+
SpanId::from(SPAN_ID),
244244
TraceFlags::SAMPLED,
245245
true,
246246
TraceState::default(),
@@ -251,8 +251,8 @@ mod tests {
251251
SPAN_ID_STR,
252252
1,
253253
SpanContext::new(
254-
TraceId::from_u128(TRACE_ID),
255-
SpanId::from_u64(SPAN_ID),
254+
TraceId::from(TRACE_ID),
255+
SpanId::from(SPAN_ID),
256256
TraceFlags::SAMPLED,
257257
true,
258258
TraceState::default(),
@@ -263,8 +263,8 @@ mod tests {
263263
SHORT_SPAN_ID_STR,
264264
1,
265265
SpanContext::new(
266-
TraceId::from_u128(TRACE_ID),
267-
SpanId::from_u64(SPAN_ID),
266+
TraceId::from(TRACE_ID),
267+
SpanId::from(SPAN_ID),
268268
TraceFlags::SAMPLED,
269269
true,
270270
TraceState::default(),
@@ -275,8 +275,8 @@ mod tests {
275275
SPAN_ID_STR,
276276
3,
277277
SpanContext::new(
278-
TraceId::from_u128(TRACE_ID),
279-
SpanId::from_u64(SPAN_ID),
278+
TraceId::from(TRACE_ID),
279+
SpanId::from(SPAN_ID),
280280
TRACE_FLAG_DEBUG | TraceFlags::SAMPLED,
281281
true,
282282
TraceState::default(),
@@ -287,8 +287,8 @@ mod tests {
287287
SPAN_ID_STR,
288288
0,
289289
SpanContext::new(
290-
TraceId::from_u128(TRACE_ID),
291-
SpanId::from_u64(SPAN_ID),
290+
TraceId::from(TRACE_ID),
291+
SpanId::from(SPAN_ID),
292292
TraceFlags::default(),
293293
true,
294294
TraceState::default(),
@@ -319,8 +319,8 @@ mod tests {
319319
vec![
320320
(
321321
SpanContext::new(
322-
TraceId::from_u128(TRACE_ID),
323-
SpanId::from_u64(SPAN_ID),
322+
TraceId::from(TRACE_ID),
323+
SpanId::from(SPAN_ID),
324324
TraceFlags::SAMPLED,
325325
true,
326326
TraceState::default(),
@@ -329,8 +329,8 @@ mod tests {
329329
),
330330
(
331331
SpanContext::new(
332-
TraceId::from_u128(TRACE_ID),
333-
SpanId::from_u64(SPAN_ID),
332+
TraceId::from(TRACE_ID),
333+
SpanId::from(SPAN_ID),
334334
TraceFlags::default(),
335335
true,
336336
TraceState::default(),
@@ -339,8 +339,8 @@ mod tests {
339339
),
340340
(
341341
SpanContext::new(
342-
TraceId::from_u128(TRACE_ID),
343-
SpanId::from_u64(SPAN_ID),
342+
TraceId::from(TRACE_ID),
343+
SpanId::from(SPAN_ID),
344344
TRACE_FLAG_DEBUG | TraceFlags::SAMPLED,
345345
true,
346346
TraceState::default(),
@@ -550,10 +550,7 @@ mod tests {
550550
#[test]
551551
fn test_extract_span_id() {
552552
let propgator = Propagator::new();
553-
assert_eq!(
554-
propgator.extract_span_id("12345"),
555-
Ok(SpanId::from_u64(74565))
556-
);
553+
assert_eq!(propgator.extract_span_id("12345"), Ok(SpanId::from(74565)));
557554

558555
// Fail to extract span id with an invalid hex-string
559556
assert_eq!(propgator.extract_span_id("invalid"), Err(()));
@@ -683,8 +680,8 @@ mod tests {
683680
assert_eq!(
684681
context.span().span_context(),
685682
&SpanContext::new(
686-
TraceId::from_u128(TRACE_ID),
687-
SpanId::from_u64(SPAN_ID),
683+
TraceId::from(TRACE_ID),
684+
SpanId::from(SPAN_ID),
688685
TraceFlags::SAMPLED,
689686
true,
690687
TraceState::default(),

opentelemetry-otlp/CHANGELOG.md

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

33
## vNext
44

5+
- Add HTTP compression support with `gzip-http` and `zstd-http` feature flags
6+
57
## 0.30.0
68

79
Released 2025-May-23

opentelemetry-otlp/Cargo.toml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,18 @@ serde = { workspace = true, features = ["derive"], optional = true }
4343
thiserror = { workspace = true }
4444
serde_json = { workspace = true, optional = true }
4545

46+
# compression dependencies
47+
flate2 = { version = "1.1.2", optional = true }
48+
zstd = { version = "0.13", optional = true }
49+
4650
[dev-dependencies]
4751
tokio-stream = { workspace = true, features = ["net"] }
4852
opentelemetry_sdk = { workspace = true, features = ["trace", "testing"] }
4953
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
5054
futures-util = { workspace = true }
5155
temp-env = { workspace = true }
5256
tonic = { workspace = true, features = ["router", "server"] }
57+
async-trait = { workspace = true }
5358

5459
[features]
5560
# telemetry pillars and functions
@@ -67,14 +72,18 @@ default = ["http-proto", "reqwest-blocking-client", "trace", "metrics", "logs",
6772
grpc-tonic = ["tonic", "prost", "http", "tokio", "opentelemetry-proto/gen-tonic"]
6873
gzip-tonic = ["tonic/gzip"]
6974
zstd-tonic = ["tonic/zstd"]
75+
76+
# http compression
77+
gzip-http = ["flate2"]
78+
zstd-http = ["zstd"]
7079
tls = ["tonic/tls-ring"]
7180
tls-roots = ["tls", "tonic/tls-native-roots"]
7281
tls-webpki-roots = ["tls", "tonic/tls-webpki-roots"]
7382

7483
# http binary
7584
http-proto = ["prost", "opentelemetry-http", "opentelemetry-proto/gen-tonic-messages", "http", "trace", "metrics"]
7685
http-json = ["serde_json", "prost", "opentelemetry-http", "opentelemetry-proto/gen-tonic-messages", "opentelemetry-proto/with-serde", "http", "trace", "metrics"]
77-
reqwest-blocking-client = ["reqwest/blocking", "opentelemetry-http/reqwest"]
86+
reqwest-blocking-client = ["reqwest/blocking", "opentelemetry-http/reqwest-blocking"]
7887
reqwest-client = ["reqwest", "opentelemetry-http/reqwest"]
7988
reqwest-rustls = ["reqwest", "opentelemetry-http/reqwest-rustls"]
8089
reqwest-rustls-webpki-roots = ["reqwest", "opentelemetry-http/reqwest-rustls-webpki-roots"]

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use super::OtlpHttpClient;
2+
use http::header::CONTENT_ENCODING;
23
use http::{header::CONTENT_TYPE, Method};
34
use opentelemetry::otel_debug;
45
use opentelemetry_sdk::error::{OTelSdkError, OTelSdkResult};
@@ -14,14 +15,20 @@ impl LogExporter for OtlpHttpClient {
1415
.clone()
1516
.ok_or(OTelSdkError::AlreadyShutdown)?;
1617

17-
let (body, content_type) = self
18+
let (body, content_type, content_encoding) = self
1819
.build_logs_export_body(batch)
1920
.map_err(OTelSdkError::InternalFailure)?;
2021

21-
let mut request = http::Request::builder()
22+
let mut request_builder = http::Request::builder()
2223
.method(Method::POST)
2324
.uri(&self.collector_endpoint)
24-
.header(CONTENT_TYPE, content_type)
25+
.header(CONTENT_TYPE, content_type);
26+
27+
if let Some(encoding) = content_encoding {
28+
request_builder = request_builder.header(CONTENT_ENCODING, encoding);
29+
}
30+
31+
let mut request = request_builder
2532
.body(body.into())
2633
.map_err(|e| OTelSdkError::InternalFailure(e.to_string()))?;
2734

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

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,21 @@ impl MetricsClient for OtlpHttpClient {
1919
_ => Err(OTelSdkError::AlreadyShutdown),
2020
})?;
2121

22-
let (body, content_type) = self.build_metrics_export_body(metrics).ok_or_else(|| {
23-
OTelSdkError::InternalFailure("Failed to serialize metrics".to_string())
24-
})?;
25-
let mut request = http::Request::builder()
22+
let (body, content_type, content_encoding) =
23+
self.build_metrics_export_body(metrics).ok_or_else(|| {
24+
OTelSdkError::InternalFailure("Failed to serialize metrics".to_string())
25+
})?;
26+
27+
let mut request_builder = http::Request::builder()
2628
.method(Method::POST)
2729
.uri(&self.collector_endpoint)
28-
.header(CONTENT_TYPE, content_type)
30+
.header(CONTENT_TYPE, content_type);
31+
32+
if let Some(encoding) = content_encoding {
33+
request_builder = request_builder.header("Content-Encoding", encoding);
34+
}
35+
36+
let mut request = request_builder
2937
.body(body.into())
3038
.map_err(|e| OTelSdkError::InternalFailure(format!("{e:?}")))?;
3139

0 commit comments

Comments
 (0)