Skip to content

Commit 5e29598

Browse files
authored
chore: fix format lint (#3039)
1 parent af2f144 commit 5e29598

File tree

55 files changed

+186
-257
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+186
-257
lines changed

opentelemetry-appender-log/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ mod any_value {
687687
) -> Result<(), Self::Error> {
688688
let key = match key.serialize(ValueSerializer)? {
689689
Some(AnyValue::String(key)) => Key::from(String::from(key)),
690-
key => Key::from(format!("{:?}", key)),
690+
key => Key::from(format!("{key:?}")),
691691
};
692692

693693
self.key = Some(key);

opentelemetry-appender-tracing/benches/log-attributes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ fn create_benchmark(c: &mut Criterion, num_attributes: usize) {
6060
let subscriber = Registry::default().with(ot_layer);
6161

6262
tracing::subscriber::with_default(subscriber, || {
63-
c.bench_function(&format!("otel_{}_attributes", num_attributes), |b| {
63+
c.bench_function(&format!("otel_{num_attributes}_attributes"), |b| {
6464
b.iter(|| {
6565
// Dynamically generate the error! macro call based on the number of attributes
6666
match num_attributes {

opentelemetry-appender-tracing/src/layer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ impl<LR: LogRecord> tracing::field::Visit for EventVisitor<'_, LR> {
7373
return;
7474
}
7575
if field.name() == "message" {
76-
self.log_record.set_body(format!("{:?}", value).into());
76+
self.log_record.set_body(format!("{value:?}").into());
7777
} else {
7878
self.log_record
7979
.add_attribute(Key::new(field.name()), AnyValue::from(format!("{value:?}")));

opentelemetry-jaeger-propagator/src/propagator.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ mod tests {
325325
true,
326326
TraceState::default(),
327327
),
328-
format!("{}:{}:0:1", LONG_TRACE_ID_STR, SPAN_ID_STR),
328+
format!("{LONG_TRACE_ID_STR}:{SPAN_ID_STR}:0:1"),
329329
),
330330
(
331331
SpanContext::new(
@@ -335,7 +335,7 @@ mod tests {
335335
true,
336336
TraceState::default(),
337337
),
338-
format!("{}:{}:0:0", LONG_TRACE_ID_STR, SPAN_ID_STR),
338+
format!("{LONG_TRACE_ID_STR}:{SPAN_ID_STR}:0:0"),
339339
),
340340
(
341341
SpanContext::new(
@@ -345,7 +345,7 @@ mod tests {
345345
true,
346346
TraceState::default(),
347347
),
348-
format!("{}:{}:0:3", LONG_TRACE_ID_STR, SPAN_ID_STR),
348+
format!("{LONG_TRACE_ID_STR}:{SPAN_ID_STR}:0:3"),
349349
),
350350
]
351351
}
@@ -356,7 +356,7 @@ mod tests {
356356
let propagator = Propagator::with_custom_header(construct_header);
357357
for (trace_id, span_id, flag, expected) in get_extract_data() {
358358
let mut map: HashMap<String, String> = HashMap::new();
359-
map.set(context_key, format!("{}:{}:0:{}", trace_id, span_id, flag));
359+
map.set(context_key, format!("{trace_id}:{span_id}:0:{flag}"));
360360
let context = propagator.extract(&map);
361361
assert_eq!(context.span().span_context(), &expected);
362362
}
@@ -392,7 +392,7 @@ mod tests {
392392

393393
// Propagators implement debug
394394
assert_eq!(
395-
format!("{:?}", default_propagator),
395+
format!("{default_propagator:?}"),
396396
format!(
397397
"Propagator {{ baggage_prefix: \"{}\", header_name: \"{}\", fields: [\"{}\"] }}",
398398
JAEGER_BAGGAGE_PREFIX, JAEGER_HEADER, JAEGER_HEADER
@@ -641,10 +641,7 @@ mod tests {
641641
}
642642
for (trace_id, span_id, flag, expected) in get_extract_data() {
643643
let mut map: HashMap<String, String> = HashMap::new();
644-
map.set(
645-
JAEGER_HEADER,
646-
format!("{}:{}:0:{}", trace_id, span_id, flag),
647-
);
644+
map.set(JAEGER_HEADER, format!("{trace_id}:{span_id}:0:{flag}"));
648645
let context = propagator.extract(&map);
649646
assert_eq!(context.span().span_context(), &expected);
650647
}
@@ -655,7 +652,7 @@ mod tests {
655652
let mut map: HashMap<String, String> = HashMap::new();
656653
map.set(
657654
JAEGER_HEADER,
658-
format!("{}:{}:0:1:aa", LONG_TRACE_ID_STR, SPAN_ID_STR),
655+
format!("{LONG_TRACE_ID_STR}:{SPAN_ID_STR}:0:1:aa"),
659656
);
660657
let propagator = Propagator::new();
661658
let context = propagator.extract(&map);
@@ -667,7 +664,7 @@ mod tests {
667664
let mut map: HashMap<String, String> = HashMap::new();
668665
map.set(
669666
JAEGER_HEADER,
670-
format!("{}:{}:0:aa", LONG_TRACE_ID_STR, SPAN_ID_STR),
667+
format!("{LONG_TRACE_ID_STR}:{SPAN_ID_STR}:0:aa"),
671668
);
672669
let propagator = Propagator::new();
673670
let context = propagator.extract(&map);
@@ -679,7 +676,7 @@ mod tests {
679676
let mut map: HashMap<String, String> = HashMap::new();
680677
map.set(
681678
JAEGER_HEADER,
682-
format!("{}%3A{}%3A0%3A1", LONG_TRACE_ID_STR, SPAN_ID_STR),
679+
format!("{LONG_TRACE_ID_STR}%3A{SPAN_ID_STR}%3A0%3A1"),
683680
);
684681
let propagator = Propagator::new();
685682
let context = propagator.extract(&map);

opentelemetry-otlp/examples/basic-otlp-http/src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,15 +169,15 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
169169
// Collect all shutdown errors
170170
let mut shutdown_errors = Vec::new();
171171
if let Err(e) = tracer_provider.shutdown() {
172-
shutdown_errors.push(format!("tracer provider: {}", e));
172+
shutdown_errors.push(format!("tracer provider: {e}"));
173173
}
174174

175175
if let Err(e) = meter_provider.shutdown() {
176-
shutdown_errors.push(format!("meter provider: {}", e));
176+
shutdown_errors.push(format!("meter provider: {e}"));
177177
}
178178

179179
if let Err(e) = logger_provider.shutdown() {
180-
shutdown_errors.push(format!("logger provider: {}", e));
180+
shutdown_errors.push(format!("logger provider: {e}"));
181181
}
182182

183183
// Return an error if any shutdown failed

opentelemetry-otlp/examples/basic-otlp/src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,15 +162,15 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
162162
// Collect all shutdown errors
163163
let mut shutdown_errors = Vec::new();
164164
if let Err(e) = tracer_provider.shutdown() {
165-
shutdown_errors.push(format!("tracer provider: {}", e));
165+
shutdown_errors.push(format!("tracer provider: {e}"));
166166
}
167167

168168
if let Err(e) = meter_provider.shutdown() {
169-
shutdown_errors.push(format!("meter provider: {}", e));
169+
shutdown_errors.push(format!("meter provider: {e}"));
170170
}
171171

172172
if let Err(e) = logger_provider.shutdown() {
173-
shutdown_errors.push(format!("logger provider: {}", e));
173+
shutdown_errors.push(format!("logger provider: {e}"));
174174
}
175175

176176
// Return an error if any shutdown failed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ impl LogExporter for OtlpHttpClient {
1010
let client = self
1111
.client
1212
.lock()
13-
.map_err(|e| OTelSdkError::InternalFailure(format!("Mutex lock failed: {}", e)))?
13+
.map_err(|e| OTelSdkError::InternalFailure(format!("Mutex lock failed: {e}")))?
1414
.clone()
1515
.ok_or(OTelSdkError::AlreadyShutdown)?;
1616

@@ -53,7 +53,7 @@ impl LogExporter for OtlpHttpClient {
5353

5454
fn shutdown_with_timeout(&self, _timeout: time::Duration) -> OTelSdkResult {
5555
let mut client_guard = self.client.lock().map_err(|e| {
56-
OTelSdkError::InternalFailure(format!("Failed to acquire client lock: {}", e))
56+
OTelSdkError::InternalFailure(format!("Failed to acquire client lock: {e}"))
5757
})?;
5858

5959
if client_guard.take().is_none() {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ impl MetricsClient for OtlpHttpClient {
6262
fn shutdown(&self) -> OTelSdkResult {
6363
self.client
6464
.lock()
65-
.map_err(|e| OTelSdkError::InternalFailure(format!("Failed to acquire lock: {}", e)))?
65+
.map_err(|e| OTelSdkError::InternalFailure(format!("Failed to acquire lock: {e}")))?
6666
.take();
6767

6868
Ok(())

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

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -615,17 +615,14 @@ mod tests {
615615
assert_eq!(
616616
headers.len(),
617617
expected_headers.len(),
618-
"Failed on input: {}",
619-
input_str
618+
"Failed on input: {input_str}"
620619
);
621620

622621
for (expected_key, expected_value) in expected_headers {
623622
assert_eq!(
624623
headers.get(&HeaderName::from_static(expected_key)),
625624
Some(&HeaderValue::from_static(expected_value)),
626-
"Failed on key: {} with input: {}",
627-
expected_key,
628-
input_str
625+
"Failed on key: {expected_key} with input: {input_str}"
629626
);
630627
}
631628
}
@@ -665,17 +662,14 @@ mod tests {
665662
assert_eq!(
666663
headers.len(),
667664
expected_headers.len(),
668-
"Failed on input: {}",
669-
input_str
665+
"Failed on input: {input_str}"
670666
);
671667

672668
for (expected_key, expected_value) in expected_headers {
673669
assert_eq!(
674670
headers.get(&HeaderName::from_static(expected_key)),
675671
Some(&HeaderValue::from_static(expected_value)),
676-
"Failed on key: {} with input: {}",
677-
expected_key,
678-
input_str
672+
"Failed on key: {expected_key} with input: {input_str}"
679673
);
680674
}
681675
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ impl SpanExporter for OtlpHttpClient {
1313
let client = match self
1414
.client
1515
.lock()
16-
.map_err(|e| OTelSdkError::InternalFailure(format!("Mutex lock failed: {}", e)))
16+
.map_err(|e| OTelSdkError::InternalFailure(format!("Mutex lock failed: {e}")))
1717
.and_then(|g| match &*g {
1818
Some(client) => Ok(Arc::clone(client)),
1919
_ => Err(OTelSdkError::AlreadyShutdown),
@@ -65,7 +65,7 @@ impl SpanExporter for OtlpHttpClient {
6565

6666
fn shutdown(&mut self) -> OTelSdkResult {
6767
let mut client_guard = self.client.lock().map_err(|e| {
68-
OTelSdkError::InternalFailure(format!("Failed to acquire client lock: {}", e))
68+
OTelSdkError::InternalFailure(format!("Failed to acquire client lock: {e}"))
6969
})?;
7070

7171
if client_guard.take().is_none() {

opentelemetry-otlp/src/exporter/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,7 @@ mod tests {
396396
exporter_result,
397397
Err(crate::exporter::ExporterBuildError::InvalidUri(_, _))
398398
),
399-
"Expected InvalidUri error, but got {:?}",
400-
exporter_result
399+
"Expected InvalidUri error, but got {exporter_result:?}"
401400
);
402401
}
403402

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl LogExporter for TonicLogsClient {
6363
let (m, e, _) = inner
6464
.interceptor
6565
.call(Request::new(()))
66-
.map_err(|e| OTelSdkError::InternalFailure(format!("error: {:?}", e)))?
66+
.map_err(|e| OTelSdkError::InternalFailure(format!("error: {e:?}")))?
6767
.into_parts();
6868
(inner.client.clone(), m, e)
6969
}
@@ -88,7 +88,7 @@ impl LogExporter for TonicLogsClient {
8888
Ok(())
8989
}
9090
Err(e) => {
91-
let error = format!("export error: {:?}", e);
91+
let error = format!("export error: {e:?}");
9292
otel_debug!(name: "TonicLogsClient.ExportFailed", error = &error);
9393
Err(OTelSdkError::InternalFailure(error))
9494
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl MetricsClient for TonicMetricsClient {
101101
fn shutdown(&self) -> OTelSdkResult {
102102
self.inner
103103
.lock()
104-
.map_err(|e| OTelSdkError::InternalFailure(format!("Failed to acquire lock: {}", e)))?
104+
.map_err(|e| OTelSdkError::InternalFailure(format!("Failed to acquire lock: {e}")))?
105105
.take();
106106

107107
Ok(())

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl SpanExporter for TonicTracesClient {
6767
.lock()
6868
.await // tokio::sync::Mutex doesn't return a poisoned error, so we can safely use the interceptor here
6969
.call(Request::new(()))
70-
.map_err(|e| OTelSdkError::InternalFailure(format!("error: {:?}", e)))?
70+
.map_err(|e| OTelSdkError::InternalFailure(format!("error: {e:?}")))?
7171
.into_parts();
7272
(inner.client.clone(), m, e)
7373
}

opentelemetry-otlp/tests/integration_test/src/metric_helpers.rs

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,7 @@ pub fn assert_metrics_results_contains(expected_content: &str) -> Result<()> {
101101
reader.read_to_string(&mut contents)?;
102102
assert!(
103103
contents.contains(expected_content),
104-
"Expected content {} not found in actual content {}",
105-
expected_content,
106-
contents
104+
"Expected content {expected_content} not found in actual content {contents}"
107105
);
108106
Ok(())
109107
}
@@ -162,12 +160,7 @@ pub fn fetch_latest_metrics_for_scope(scope_name: &str) -> Result<Value> {
162160
None
163161
})
164162
})
165-
.with_context(|| {
166-
format!(
167-
"No valid JSON line containing scope `{}` found.",
168-
scope_name
169-
)
170-
})?;
163+
.with_context(|| format!("No valid JSON line containing scope `{scope_name}` found."))?;
171164

172165
Ok(json_line)
173166
}
@@ -178,18 +171,16 @@ pub fn fetch_latest_metrics_for_scope(scope_name: &str) -> Result<Value> {
178171
///
179172
pub fn validate_metrics_against_results(scope_name: &str) -> Result<()> {
180173
// Define the results file path
181-
let results_file_path = format!("./expected/metrics/{}.json", scope_name);
174+
let results_file_path = format!("./expected/metrics/{scope_name}.json");
182175

183176
// Fetch the actual metrics for the given scope
184177
let actual_metrics = fetch_latest_metrics_for_scope(scope_name)
185-
.context(format!("Failed to fetch metrics for scope: {}", scope_name))?;
178+
.context(format!("Failed to fetch metrics for scope: {scope_name}"))?;
186179

187180
// Read the expected metrics from the results file
188181
let expected_metrics = {
189-
let file = File::open(&results_file_path).context(format!(
190-
"Failed to open results file: {}",
191-
results_file_path
192-
))?;
182+
let file = File::open(&results_file_path)
183+
.context(format!("Failed to open results file: {results_file_path}"))?;
193184
read_metrics_from_json(file)
194185
}?;
195186

opentelemetry-otlp/tests/integration_test/src/trace_asserter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ impl SpanForest {
119119
}
120120

121121
if !spans.is_empty() {
122-
panic!("found spans with invalid parent: {:?}", spans);
122+
panic!("found spans with invalid parent: {spans:?}");
123123
}
124124

125125
forest

opentelemetry-otlp/tests/integration_test/tests/metrics_roundtrip.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ mod metrictests_roundtrip {
3838
let metrics: MetricsData = serde_json::from_str(metrics_in)?;
3939
let metrics_out = serde_json::to_string(&metrics)?;
4040

41-
println!("{:}", metrics_out);
41+
println!("{metrics_out:}");
4242

4343
let metrics_in_json: Value = serde_json::from_str(metrics_in)?;
4444
let metrics_out_json: Value = serde_json::from_str(&metrics_out)?;

opentelemetry-otlp/tests/smoke.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ async fn smoke_tracer() {
8989
opentelemetry_otlp::SpanExporter::builder()
9090
.with_tonic()
9191
.with_compression(opentelemetry_otlp::Compression::Gzip)
92-
.with_endpoint(format!("http://{}", addr))
92+
.with_endpoint(format!("http://{addr}"))
9393
.with_metadata(metadata)
9494
.build()
9595
.expect("gzip-tonic SpanExporter failed to build"),

opentelemetry-prometheus/src/utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ pub(crate) fn get_unit_suffixes(unit: &str) -> Option<Cow<'static, str>> {
2626
get_prom_per_unit(second),
2727
) {
2828
(true, _, Some(second_part)) | (false, None, Some(second_part)) => {
29-
Some(Cow::Owned(format!("per_{}", second_part)))
29+
Some(Cow::Owned(format!("per_{second_part}")))
3030
}
3131
(false, Some(first_part), Some(second_part)) => {
32-
Some(Cow::Owned(format!("{}_per_{}", first_part, second_part)))
32+
Some(Cow::Owned(format!("{first_part}_per_{second_part}")))
3333
}
3434
_ => None,
3535
};

opentelemetry-sdk/benches/batch_span_processor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ fn criterion_benchmark(c: &mut Criterion) {
4242

4343
for task_num in [1, 2, 4, 8, 16, 32].iter() {
4444
group.bench_with_input(
45-
BenchmarkId::from_parameter(format!("with {} concurrent task", task_num)),
45+
BenchmarkId::from_parameter(format!("with {task_num} concurrent task")),
4646
task_num,
4747
|b, &task_num| {
4848
b.iter(|| {

0 commit comments

Comments
 (0)