Skip to content

Commit aa74b9c

Browse files
committed
run pre-commit script
1 parent da76734 commit aa74b9c

File tree

3 files changed

+23
-10
lines changed

3 files changed

+23
-10
lines changed

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

+9-6
Original file line numberDiff line numberDiff line change
@@ -70,26 +70,29 @@ impl SpanExporter for OtlpHttpClient {
7070

7171
#[cfg(any(feature = "http-proto", feature = "http-json"))]
7272
fn build_body(spans: Vec<SpanData>) -> TraceResult<(Vec<u8>, &'static str)> {
73+
use crate::exporter::default_protocol;
74+
#[cfg(feature = "http-json")]
75+
use crate::Protocol;
7376
use opentelemetry_proto::tonic::collector::trace::v1::ExportTraceServiceRequest;
77+
#[cfg(feature = "http-proto")]
7478
use prost::Message;
7579

76-
use crate::{exporter::default_protocol, Protocol};
77-
7880
let req = ExportTraceServiceRequest {
7981
resource_spans: spans.into_iter().map(Into::into).collect(),
8082
};
8183
let buf;
8284
let ctype;
8385
match default_protocol() {
86+
#[cfg(feature = "http-json")]
8487
Protocol::HttpJson => {
8588
let json_struct = serde_json::to_string_pretty(&req).unwrap();
8689
buf = json_struct.into();
87-
ctype = "application/json";
88-
},
90+
ctype = "application/json";
91+
}
8992
_ => {
9093
buf = req.encode_to_vec();
91-
ctype = "application/x-protobuf";
92-
},
94+
ctype = "application/x-protobuf";
95+
}
9396
};
9497
Ok((buf, ctype))
9598
}

opentelemetry-otlp/src/exporter/mod.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,20 @@ pub const OTEL_EXPORTER_OTLP_PROTOCOL: &str = "OTEL_EXPORTER_OTLP_PROTOCOL";
2828
/// Compression algorithm to use, defaults to none.
2929
pub const OTEL_EXPORTER_OTLP_COMPRESSION: &str = "OTEL_EXPORTER_OTLP_COMPRESSION";
3030

31-
#[cfg(all(feature = "trace", not(feature = "http-proto"), not(feature = "grpc-tonic")))]
31+
#[cfg(all(
32+
feature = "trace",
33+
not(feature = "http-proto"),
34+
not(feature = "grpc-tonic")
35+
))]
3236
/// Default protocol, using http-json.
3337
pub const OTEL_EXPORTER_OTLP_PROTOCOL_DEFAULT: &str = OTEL_EXPORTER_OTLP_PROTOCOL_HTTP_JSON;
3438
#[cfg(feature = "http-proto")]
3539
/// Default protocol, using http-proto.
3640
pub const OTEL_EXPORTER_OTLP_PROTOCOL_DEFAULT: &str = OTEL_EXPORTER_OTLP_PROTOCOL_HTTP_PROTOBUF;
37-
#[cfg(all(feature = "grpc-tonic", not(all(feature = "http-proto", feature = "http-json"))))]
41+
#[cfg(all(
42+
feature = "grpc-tonic",
43+
not(all(feature = "http-proto", feature = "http-json"))
44+
))]
3845
/// Default protocol, using grpc as http-proto or http-json feature is not enabled.
3946
pub const OTEL_EXPORTER_OTLP_PROTOCOL_DEFAULT: &str = OTEL_EXPORTER_OTLP_PROTOCOL_GRPC;
4047
#[cfg(not(any(any(feature = "grpc-tonic", feature = "http-proto", feature = "http-json"))))]

opentelemetry-otlp/src/lib.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -352,10 +352,13 @@ pub enum Error {
352352
InvalidHeaderName(#[from] http::header::InvalidHeaderName),
353353

354354
/// Prost encode failed
355-
#[cfg(any(feature = "http-proto", all(feature = "http-json", not(feature = "trace"))))]
355+
#[cfg(any(
356+
feature = "http-proto",
357+
all(feature = "http-json", not(feature = "trace"))
358+
))]
356359
#[error("prost encoding error {0}")]
357360
EncodeError(#[from] prost::EncodeError),
358-
361+
359362
/// The lock in exporters has been poisoned.
360363
#[cfg(feature = "metrics")]
361364
#[error("the lock of the {0} has been poisoned")]

0 commit comments

Comments
 (0)