Skip to content

Commit 7033725

Browse files
authored
Update rustfmt (#157)
1 parent 93d6e2c commit 7033725

File tree

7 files changed

+64
-41
lines changed

7 files changed

+64
-41
lines changed

opentelemetry-jaeger/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ mod agent;
9797
#[cfg(feature = "collector_client")]
9898
mod collector;
9999
#[allow(clippy::all, unreachable_pub, dead_code)]
100+
#[rustfmt::skip]
100101
mod thrift;
101102
pub(crate) mod transport;
102103
mod uploader;

opentelemetry-zipkin/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ impl ExporterConfigBuilder {
143143
self.service_endpoint = Some(endpoint);
144144
self
145145
}
146-
146+
147147
/// Assign the collector endpoint for `ConfigBuilder`
148148
pub fn with_collector_endpoint(&mut self, endpoint: String) -> &mut Self {
149149
self.collector_endpoint = Some(endpoint);

src/api/context/propagation/composite_propagator.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,7 @@ mod tests {
8888

8989
fn test_data() -> Vec<(&'static str, &'static str)> {
9090
vec![
91-
(
92-
"b3",
93-
"00000000000000000000000000000001-0000000000000001-0",
94-
),
91+
("b3", "00000000000000000000000000000001-0000000000000001-0"),
9592
(
9693
"traceparent",
9794
"00-00000000000000000000000000000001-0000000000000001-00",

src/api/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ pub use trace::{
4848
sampler::{Sampler, SamplingDecision, SamplingResult},
4949
span::{Span, SpanKind, StatusCode},
5050
span_context::{
51-
SpanContext, SpanId, TraceId, TRACE_FLAG_DEBUG, TRACE_FLAG_DEFERRED, TRACE_FLAG_SAMPLED, TRACE_FLAG_NOT_SAMPLED
51+
SpanContext, SpanId, TraceId, TRACE_FLAG_DEBUG, TRACE_FLAG_DEFERRED,
52+
TRACE_FLAG_NOT_SAMPLED, TRACE_FLAG_SAMPLED,
5253
},
5354
span_processor::SpanProcessor,
5455
trace_context_propagator::TraceContextPropagator,

src/api/trace/b3_propagator.rs

Lines changed: 54 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
//!
1414
//! If `inject_encoding` is set to `B3Encoding::SingleHeader` then `b3` header is used to inject
1515
//! and extract. Otherwise, separate headers are used to inject and extract.
16-
use crate::{api, api::TraceContextExt};
17-
use crate::api::TRACE_FLAG_DEFERRED;
1816
use crate::api::trace::b3_propagator::B3Encoding::MultipleHeader;
17+
use crate::api::TRACE_FLAG_DEFERRED;
18+
use crate::{api, api::TraceContextExt};
1919

2020
static B3_SINGLE_HEADER: &str = "b3";
2121
/// As per spec, the multiple header should be case sensitive. But different protocol will use
@@ -82,8 +82,7 @@ impl B3Propagator {
8282
/// Extract trace id from hex encoded &str value.
8383
fn extract_trace_id(&self, trace_id: &str) -> Result<api::TraceId, ()> {
8484
// Only allow lower case hex string
85-
if trace_id.to_lowercase() != trace_id ||
86-
(trace_id.len() != 16 && trace_id.len() != 32) {
85+
if trace_id.to_lowercase() != trace_id || (trace_id.len() != 16 && trace_id.len() != 32) {
8786
Err(())
8887
} else {
8988
u128::from_str_radix(trace_id, 16)
@@ -223,8 +222,9 @@ impl api::HttpTextFormat for B3Propagator {
223222

224223
carrier.set(B3_SINGLE_HEADER, value);
225224
}
226-
if self.inject_encoding.support(&B3Encoding::MultipleHeader) ||
227-
self.inject_encoding.support(&B3Encoding::UnSpecified) {
225+
if self.inject_encoding.support(&B3Encoding::MultipleHeader)
226+
|| self.inject_encoding.support(&B3Encoding::UnSpecified)
227+
{
228228
// if inject_encoding is Unspecified, default to use MultipleHeader
229229
carrier.set(
230230
B3_TRACE_ID_HEADER,
@@ -247,8 +247,9 @@ impl api::HttpTextFormat for B3Propagator {
247247
if self.inject_encoding.support(&B3Encoding::SingleHeader) {
248248
carrier.set(B3_SINGLE_HEADER, flag.to_string())
249249
}
250-
if self.inject_encoding.support(&B3Encoding::MultipleHeader) ||
251-
self.inject_encoding.support(&B3Encoding::UnSpecified) {
250+
if self.inject_encoding.support(&B3Encoding::MultipleHeader)
251+
|| self.inject_encoding.support(&B3Encoding::UnSpecified)
252+
{
252253
carrier.set(B3_SAMPLED_HEADER, flag.to_string())
253254
}
254255
}
@@ -259,8 +260,7 @@ impl api::HttpTextFormat for B3Propagator {
259260
/// `Context` is returned.
260261
fn extract_with_context(&self, cx: &api::Context, carrier: &dyn api::Carrier) -> api::Context {
261262
let span_context = if self.inject_encoding.support(&B3Encoding::SingleHeader) {
262-
self.extract_single_header(carrier)
263-
.unwrap_or_else(|_|
263+
self.extract_single_header(carrier).unwrap_or_else(|_|
264264
// if invalid single header should fallback to multiple
265265
self.extract_multi_header(carrier)
266266
.unwrap_or_else(|_| api::SpanContext::empty_context()))
@@ -285,7 +285,6 @@ mod tests {
285285
const TRACE_ID_HEX: u128 = 0x4bf9_2f35_77b3_4da6_a3ce_929d_0e0e_4736;
286286
const SPAN_ID_HEX: u64 = 0x00f0_67aa_0ba9_02b7;
287287

288-
289288
#[rustfmt::skip]
290289
fn single_header_extract_data() -> Vec<(&'static str, api::SpanContext)> {
291290
vec![
@@ -407,7 +406,13 @@ mod tests {
407406
]
408407
}
409408

410-
fn extract_carrier_from_test_data(trace: Option<&'static str>, span: Option<&'static str>, sampled: Option<&'static str>, debug: Option<&'static str>, parent: Option<&'static str>) -> HashMap<String, String> {
409+
fn extract_carrier_from_test_data(
410+
trace: Option<&'static str>,
411+
span: Option<&'static str>,
412+
sampled: Option<&'static str>,
413+
debug: Option<&'static str>,
414+
parent: Option<&'static str>,
415+
) -> HashMap<String, String> {
411416
let mut carrier = HashMap::new();
412417
if let Some(trace_id) = trace {
413418
carrier.insert(B3_TRACE_ID_HEADER.to_string(), trace_id.to_owned());
@@ -462,7 +467,9 @@ mod tests {
462467
)
463468
}
464469

465-
for ((trace, span, sampled, debug, parent), single_header, expected_context) in single_multi_header_extract_data() {
470+
for ((trace, span, sampled, debug, parent), single_header, expected_context) in
471+
single_multi_header_extract_data()
472+
{
466473
let mut carrier = extract_carrier_from_test_data(trace, span, sampled, debug, parent);
467474
carrier.insert(B3_SINGLE_HEADER.to_string(), single_header.to_owned());
468475
assert_eq!(
@@ -481,7 +488,10 @@ mod tests {
481488

482489
for invalid_single_header in single_header_extrace_invalid_data() {
483490
let mut carrier = HashMap::new();
484-
carrier.insert(B3_SINGLE_HEADER.to_string(), invalid_single_header.to_string());
491+
carrier.insert(
492+
B3_SINGLE_HEADER.to_string(),
493+
invalid_single_header.to_string(),
494+
);
485495
assert_eq!(
486496
single_header_propagator
487497
.extract(&carrier)
@@ -511,7 +521,8 @@ mod tests {
511521
_name: String,
512522
_timestamp: std::time::SystemTime,
513523
_attributes: Vec<api::KeyValue>,
514-
) {}
524+
) {
525+
}
515526
fn span_context(&self) -> api::SpanContext {
516527
self.0.clone()
517528
}
@@ -528,7 +539,8 @@ mod tests {
528539
fn inject_b3() {
529540
let single_header_propagator = B3Propagator::with_encoding(B3Encoding::SingleHeader);
530541
let multi_header_propagator = B3Propagator::with_encoding(B3Encoding::MultipleHeader);
531-
let single_multi_header_propagator = B3Propagator::with_encoding(B3Encoding::SingleAndMultiHeader);
542+
let single_multi_header_propagator =
543+
B3Propagator::with_encoding(B3Encoding::SingleAndMultiHeader);
532544
let unspecified_header_propagator = B3Propagator::with_encoding(B3Encoding::UnSpecified);
533545

534546
for (expected_header, context) in single_header_inject_data() {
@@ -558,16 +570,28 @@ mod tests {
558570

559571
assert_eq!(carrier_multi_header, carrier_unspecific);
560572

561-
assert_eq!(carrier_multi_header.get(B3_TRACE_ID_HEADER).map(|s| s.to_owned()),
562-
trace_id.map(|s| s.to_string()));
563-
assert_eq!(carrier_multi_header.get(B3_SPAN_ID_HEADER).map(|s| s.to_owned()),
564-
span_id.map(|s| s.to_string()));
565573
assert_eq!(
566-
carrier_multi_header.get(B3_SAMPLED_HEADER).map(|s| s.to_owned()),
574+
carrier_multi_header
575+
.get(B3_TRACE_ID_HEADER)
576+
.map(|s| s.to_owned()),
577+
trace_id.map(|s| s.to_string())
578+
);
579+
assert_eq!(
580+
carrier_multi_header
581+
.get(B3_SPAN_ID_HEADER)
582+
.map(|s| s.to_owned()),
583+
span_id.map(|s| s.to_string())
584+
);
585+
assert_eq!(
586+
carrier_multi_header
587+
.get(B3_SAMPLED_HEADER)
588+
.map(|s| s.to_owned()),
567589
sampled.map(|s| s.to_string())
568590
);
569591
assert_eq!(
570-
carrier_multi_header.get(B3_DEBUG_FLAG_HEADER).map(|s| s.to_owned()),
592+
carrier_multi_header
593+
.get(B3_DEBUG_FLAG_HEADER)
594+
.map(|s| s.to_owned()),
571595
flag.map(|s| s.to_string())
572596
);
573597
assert_eq!(carrier_multi_header.get(B3_PARENT_SPAN_ID_HEADER), None);
@@ -580,10 +604,14 @@ mod tests {
580604
&mut carrier,
581605
);
582606

583-
assert_eq!(carrier.get(B3_TRACE_ID_HEADER).map(|s| s.to_owned()),
584-
trace_id.map(|s| s.to_string()));
585-
assert_eq!(carrier.get(B3_SPAN_ID_HEADER).map(|s| s.to_owned()),
586-
span_id.map(|s| s.to_string()));
607+
assert_eq!(
608+
carrier.get(B3_TRACE_ID_HEADER).map(|s| s.to_owned()),
609+
trace_id.map(|s| s.to_string())
610+
);
611+
assert_eq!(
612+
carrier.get(B3_SPAN_ID_HEADER).map(|s| s.to_owned()),
613+
span_id.map(|s| s.to_string())
614+
);
587615
assert_eq!(
588616
carrier.get(B3_SAMPLED_HEADER).map(|s| s.to_owned()),
589617
sampled.map(|s| s.to_string())

src/api/trace/span.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,7 @@ pub trait Span: fmt::Debug + 'static + Send + Sync {
5353
/// Users can custom the exception message by overriding the `fmt::Display` trait's `fmt` method
5454
/// for the error.
5555
fn record_exception(&self, err: &dyn Error) {
56-
let attributes = vec![api::KeyValue::new(
57-
"exception.message",
58-
err.to_string(),
59-
)];
56+
let attributes = vec![api::KeyValue::new("exception.message", err.to_string())];
6057

6158
self.add_event("exception".to_string(), attributes);
6259
}
@@ -65,10 +62,10 @@ pub trait Span: fmt::Debug + 'static + Send + Sync {
6562
///
6663
/// See `Span:record_exception` method for more details.
6764
fn record_exception_with_stacktrace(&self, err: &dyn Error, stacktrace: String) {
68-
let attributes = vec![api::KeyValue::new(
69-
"exception.message",
70-
err.to_string(),
71-
), api::KeyValue::new("exception.stacktrace", stacktrace)];
65+
let attributes = vec![
66+
api::KeyValue::new("exception.message", err.to_string()),
67+
api::KeyValue::new("exception.stacktrace", stacktrace),
68+
];
7269

7370
self.add_event("exception".to_string(), attributes);
7471
}

src/api/trace/span_context.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#[cfg(feature = "serialize")]
1414
use serde::{Deserialize, Serialize};
1515

16-
1716
/// A SpanContext with TRACE_FLAG_NOT_SAMPLED means the span is not sampled.
1817
pub const TRACE_FLAG_NOT_SAMPLED: u8 = 0x00;
1918
/// TRACE_FLAG_SAMPLED is a bitmask with the sampled bit set. A SpanContext

0 commit comments

Comments
 (0)