Skip to content

Commit a1dbd3d

Browse files
authored
Merge branch 'main' into chore/otlp-retry-postreview-cleanup
2 parents b0475dc + 796ac1a commit a1dbd3d

File tree

15 files changed

+227
-76
lines changed

15 files changed

+227
-76
lines changed

.github/workflows/ci.yml

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
with:
6666
toolchain: stable
6767
components: rustfmt, clippy
68-
- uses: taiki-e/install-action@47be02f2de8a32619316956f6117e150bdc6763f # v2.62.44
68+
- uses: taiki-e/install-action@6f9c7cc51aa54b13cbcbd12f8bbf69d8ba405b4b # v2.62.47
6969
with:
7070
tool: cargo-hack
7171
- uses: arduino/setup-protoc@c65c819552d16ad3c9b72d9dfd5ba5237b9c906b # v3.0.0
@@ -93,7 +93,7 @@ jobs:
9393
# https://github.com/awslabs/cargo-check-external-types/releases
9494
toolchain: nightly-2025-05-04
9595
components: rustfmt
96-
- uses: taiki-e/install-action@47be02f2de8a32619316956f6117e150bdc6763f # v2.62.44
96+
- uses: taiki-e/install-action@6f9c7cc51aa54b13cbcbd12f8bbf69d8ba405b4b # v2.62.47
9797
with:
9898
9999
- name: external-type-check
@@ -117,7 +117,7 @@ jobs:
117117
- uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9
118118
with:
119119
toolchain: stable
120-
- uses: taiki-e/install-action@47be02f2de8a32619316956f6117e150bdc6763f # v2.62.44
120+
- uses: taiki-e/install-action@6f9c7cc51aa54b13cbcbd12f8bbf69d8ba405b4b # v2.62.47
121121
with:
122122
tool: cargo-msrv
123123
- uses: arduino/setup-protoc@c65c819552d16ad3c9b72d9dfd5ba5237b9c906b # v3.0.0
@@ -150,7 +150,7 @@ jobs:
150150
uses: EmbarkStudios/cargo-deny-action@f2ba7abc2abebaf185c833c3961145a3c275caad # v2.0.13
151151
with:
152152
command: check bans
153-
153+
154154
- name: Check sources
155155
uses: EmbarkStudios/cargo-deny-action@f2ba7abc2abebaf185c833c3961145a3c275caad # v2.0.13
156156
with:
@@ -199,7 +199,7 @@ jobs:
199199
with:
200200
repo-token: ${{ secrets.GITHUB_TOKEN }}
201201
- name: Install cargo-llvm-cov
202-
uses: taiki-e/install-action@47be02f2de8a32619316956f6117e150bdc6763f # v2.62.44
202+
uses: taiki-e/install-action@6f9c7cc51aa54b13cbcbd12f8bbf69d8ba405b4b # v2.62.47
203203
with:
204204
tool: cargo-llvm-cov
205205
- name: cargo generate-lockfile
@@ -232,7 +232,7 @@ jobs:
232232
cargo build
233233
fi
234234
done
235-
cargo-machete:
235+
cargo-shear:
236236
continue-on-error: true
237237
runs-on: ubuntu-latest
238238
steps:
@@ -246,9 +246,12 @@ jobs:
246246
submodules: true
247247
- uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9
248248
with:
249-
toolchain: stable
250-
- uses: taiki-e/install-action@47be02f2de8a32619316956f6117e150bdc6763f # v2.62.44
249+
toolchain: nightly
250+
- uses: arduino/setup-protoc@c65c819552d16ad3c9b72d9dfd5ba5237b9c906b # v3.0.0
251+
with:
252+
repo-token: ${{ secrets.GITHUB_TOKEN }}
253+
- uses: taiki-e/install-action@6f9c7cc51aa54b13cbcbd12f8bbf69d8ba405b4b # v2.62.47
251254
with:
252-
tool: cargo-machete
253-
- name: cargo machete
254-
run: cargo machete
255+
tool: cargo-shear
256+
- name: cargo shear
257+
run: cargo shear --expand

Cargo.toml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ log = "0.4.21"
3333
once_cell = "1.13"
3434
pin-project-lite = "0.2"
3535
prost = "0.14"
36-
prost-build = "0.14"
37-
prost-types = "0.14"
3836
rand = { version = "0.9", default-features = false }
3937
reqwest = { version = "0.12", default-features = false }
4038
serde = { version = "1.0", default-features = false }
@@ -100,3 +98,10 @@ tail_expr_drop_order = "allow"
10098

10199
[workspace.lints.clippy]
102100
all = { level = "warn", priority = 1 }
101+
102+
[workspace.metadata.cargo-shear]
103+
ignored = [
104+
# workspace crates
105+
"opentelemetry-appender-log",
106+
"opentelemetry-jaeger-propagator",
107+
]

examples/tracing-grpc/Cargo.toml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,3 @@ tonic-prost = { workspace = true }
2828

2929
[build-dependencies]
3030
tonic-prost-build = { workspace = true }
31-
32-
[package.metadata.cargo-machete]
33-
ignored = [
34-
"prost", # needed for `tonic-prost-build`
35-
"tonic-prost" # needed for `tonic-prost-build`
36-
]

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::Protocol;
33
use opentelemetry::{otel_debug, otel_warn};
44
use opentelemetry_sdk::error::{OTelSdkError, OTelSdkResult};
55
use opentelemetry_sdk::logs::{LogBatch, LogExporter};
6+
#[cfg(feature = "http-proto")]
67
use prost::Message;
78
use std::time;
89

@@ -51,13 +52,18 @@ fn handle_partial_success(response_body: &[u8], protocol: Protocol) {
5152
return;
5253
}
5354
},
54-
_ => match Message::decode(response_body) {
55+
#[cfg(feature = "http-proto")]
56+
Protocol::HttpBinary => match Message::decode(response_body) {
5557
Ok(r) => r,
5658
Err(e) => {
5759
otel_debug!(name: "HttpLogsClient.ResponseParseError", error = e.to_string());
5860
return;
5961
}
6062
},
63+
#[cfg(feature = "grpc-tonic")]
64+
Protocol::Grpc => {
65+
unreachable!("HTTP client should not receive Grpc protocol")
66+
}
6167
};
6268

6369
if let Some(partial_success) = response.partial_success {

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::Protocol;
33
use opentelemetry::{otel_debug, otel_warn};
44
use opentelemetry_sdk::error::{OTelSdkError, OTelSdkResult};
55
use opentelemetry_sdk::metrics::data::ResourceMetrics;
6+
#[cfg(feature = "http-proto")]
67
use prost::Message;
78

89
use super::OtlpHttpClient;
@@ -47,13 +48,18 @@ fn handle_partial_success(response_body: &[u8], protocol: Protocol) {
4748
return;
4849
}
4950
},
50-
_ => match Message::decode(response_body) {
51+
#[cfg(feature = "http-proto")]
52+
Protocol::HttpBinary => match Message::decode(response_body) {
5153
Ok(r) => r,
5254
Err(e) => {
5355
otel_debug!(name: "HttpMetricsClient.ResponseParseError", error = e.to_string());
5456
return;
5557
}
5658
},
59+
#[cfg(feature = "grpc-tonic")]
60+
Protocol::Grpc => {
61+
unreachable!("HTTP client should not receive Grpc protocol")
62+
}
5763
};
5864

5965
if let Some(partial_success) = response.partial_success {

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

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use super::{
2-
default_headers, default_protocol, parse_header_string, resolve_timeout, ExporterBuildError,
2+
default_headers, parse_header_string, resolve_timeout, ExporterBuildError,
33
OTEL_EXPORTER_OTLP_HTTP_ENDPOINT_DEFAULT,
44
};
55
use crate::{ExportConfig, Protocol, OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_HEADERS};
@@ -15,6 +15,7 @@ use opentelemetry_proto::transform::trace::tonic::group_spans_by_resource_and_sc
1515
use opentelemetry_sdk::logs::LogBatch;
1616
#[cfg(feature = "trace")]
1717
use opentelemetry_sdk::trace::SpanData;
18+
#[cfg(feature = "http-proto")]
1819
use prost::Message;
1920
use std::collections::HashMap;
2021
use std::env;
@@ -154,7 +155,7 @@ impl Default for HttpExporterBuilder {
154155
fn default() -> Self {
155156
HttpExporterBuilder {
156157
exporter_config: ExportConfig {
157-
protocol: default_protocol(),
158+
protocol: Protocol::default(),
158159
..ExportConfig::default()
159160
},
160161
http_config: HttpConfig {
@@ -595,7 +596,12 @@ impl OtlpHttpClient {
595596
Ok(json) => (json.into_bytes(), "application/json"),
596597
Err(e) => return Err(e.to_string()),
597598
},
598-
_ => (req.encode_to_vec(), "application/x-protobuf"),
599+
#[cfg(feature = "http-proto")]
600+
Protocol::HttpBinary => (req.encode_to_vec(), "application/x-protobuf"),
601+
#[cfg(feature = "grpc-tonic")]
602+
Protocol::Grpc => {
603+
unreachable!("HTTP client should not receive Grpc protocol")
604+
}
599605
};
600606

601607
let (processed_body, content_encoding) = self.process_body(body)?;
@@ -617,7 +623,12 @@ impl OtlpHttpClient {
617623
Ok(json) => (json.into_bytes(), "application/json"),
618624
Err(e) => return Err(e.to_string()),
619625
},
620-
_ => (req.encode_to_vec(), "application/x-protobuf"),
626+
#[cfg(feature = "http-proto")]
627+
Protocol::HttpBinary => (req.encode_to_vec(), "application/x-protobuf"),
628+
#[cfg(feature = "grpc-tonic")]
629+
Protocol::Grpc => {
630+
unreachable!("HTTP client should not receive Grpc protocol")
631+
}
621632
};
622633

623634
let (processed_body, content_encoding) = self.process_body(body)?;
@@ -642,7 +653,12 @@ impl OtlpHttpClient {
642653
return None;
643654
}
644655
},
645-
_ => (req.encode_to_vec(), "application/x-protobuf"),
656+
#[cfg(feature = "http-proto")]
657+
Protocol::HttpBinary => (req.encode_to_vec(), "application/x-protobuf"),
658+
#[cfg(feature = "grpc-tonic")]
659+
Protocol::Grpc => {
660+
unreachable!("HTTP client should not receive Grpc protocol")
661+
}
646662
};
647663

648664
match self.process_body(body) {

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use opentelemetry_sdk::{
55
error::{OTelSdkError, OTelSdkResult},
66
trace::{SpanData, SpanExporter},
77
};
8+
#[cfg(feature = "http-proto")]
89
use prost::Message;
910

1011
impl SpanExporter for OtlpHttpClient {
@@ -52,13 +53,18 @@ fn handle_partial_success(response_body: &[u8], protocol: Protocol) {
5253
return;
5354
}
5455
},
55-
_ => match Message::decode(response_body) {
56+
#[cfg(feature = "http-proto")]
57+
Protocol::HttpBinary => match Message::decode(response_body) {
5658
Ok(r) => r,
5759
Err(e) => {
5860
otel_debug!(name: "HttpTraceClient.ResponseParseError", error = e.to_string());
5961
return;
6062
}
6163
},
64+
#[cfg(feature = "grpc-tonic")]
65+
Protocol::Grpc => {
66+
unreachable!("HTTP client should not receive Grpc protocol")
67+
}
6268
};
6369

6470
if let Some(partial_success) = response.partial_success {

0 commit comments

Comments
 (0)