Skip to content

Commit a34d8fe

Browse files
authored
chore: fix new clippy lints (#221)
## Motivation There are new lints that will need to be fixed for CI to pass.
1 parent 9301a93 commit a34d8fe

File tree

5 files changed

+23
-27
lines changed

5 files changed

+23
-27
lines changed

examples/opentelemetry-error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ impl Display for SpanData {
165165
}
166166
writeln!(f, "- Links:")?;
167167
for link in self.0.links.iter() {
168-
writeln!(f, " - {:?}", link)?;
168+
writeln!(f, " - {link:?}")?;
169169
}
170170
Ok(())
171171
}

src/layer.rs

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -225,18 +225,17 @@ impl field::Visit for SpanEventVisitor<'_, '_> {
225225
self.span_builder_updates
226226
.get_or_insert_with(SpanBuilderUpdates::default)
227227
.status
228-
.replace(otel::Status::error(format!("{:?}", value)));
228+
.replace(otel::Status::error(format!("{value:?}")));
229229
}
230230
if self.sem_conv_config.error_events_to_exceptions {
231231
self.event_builder.name = EVENT_EXCEPTION_NAME.into();
232-
self.event_builder.attributes.push(KeyValue::new(
233-
FIELD_EXCEPTION_MESSAGE,
234-
format!("{:?}", value),
235-
));
232+
self.event_builder
233+
.attributes
234+
.push(KeyValue::new(FIELD_EXCEPTION_MESSAGE, format!("{value:?}")));
236235
} else {
237236
self.event_builder
238237
.attributes
239-
.push(KeyValue::new("error", format!("{:?}", value)));
238+
.push(KeyValue::new("error", format!("{value:?}")));
240239
}
241240
}
242241
// Skip fields that are actually log metadata that have already been handled
@@ -256,7 +255,7 @@ impl field::Visit for SpanEventVisitor<'_, '_> {
256255
/// [`Span`]: opentelemetry::trace::Span
257256
fn record_debug(&mut self, field: &field::Field, value: &dyn fmt::Debug) {
258257
match field.name() {
259-
"message" => self.event_builder.name = format!("{:?}", value).into(),
258+
"message" => self.event_builder.name = format!("{value:?}").into(),
260259
// While tracing supports the error primitive, the instrumentation macro does not
261260
// use the primitive and instead uses the debug or display primitive.
262261
// In both cases, an event with an empty name and with an error attribute is created.
@@ -265,18 +264,17 @@ impl field::Visit for SpanEventVisitor<'_, '_> {
265264
self.span_builder_updates
266265
.get_or_insert_with(SpanBuilderUpdates::default)
267266
.status
268-
.replace(otel::Status::error(format!("{:?}", value)));
267+
.replace(otel::Status::error(format!("{value:?}")));
269268
}
270269
if self.sem_conv_config.error_events_to_exceptions {
271270
self.event_builder.name = EVENT_EXCEPTION_NAME.into();
272-
self.event_builder.attributes.push(KeyValue::new(
273-
FIELD_EXCEPTION_MESSAGE,
274-
format!("{:?}", value),
275-
));
271+
self.event_builder
272+
.attributes
273+
.push(KeyValue::new(FIELD_EXCEPTION_MESSAGE, format!("{value:?}")));
276274
} else {
277275
self.event_builder
278276
.attributes
279-
.push(KeyValue::new("error", format!("{:?}", value)));
277+
.push(KeyValue::new("error", format!("{value:?}")));
280278
}
281279
}
282280
// Skip fields that are actually log metadata that have already been handled
@@ -285,7 +283,7 @@ impl field::Visit for SpanEventVisitor<'_, '_> {
285283
name => {
286284
self.event_builder
287285
.attributes
288-
.push(KeyValue::new(name, format!("{:?}", value)));
286+
.push(KeyValue::new(name, format!("{value:?}")));
289287
}
290288
}
291289
}
@@ -454,19 +452,19 @@ impl field::Visit for SpanAttributeVisitor<'_> {
454452
/// [`Span`]: opentelemetry::trace::Span
455453
fn record_debug(&mut self, field: &field::Field, value: &dyn fmt::Debug) {
456454
match field.name() {
457-
SPAN_NAME_FIELD => self.span_builder_updates.name = Some(format!("{:?}", value).into()),
455+
SPAN_NAME_FIELD => self.span_builder_updates.name = Some(format!("{value:?}").into()),
458456
SPAN_KIND_FIELD => {
459-
self.span_builder_updates.span_kind = str_to_span_kind(&format!("{:?}", value))
457+
self.span_builder_updates.span_kind = str_to_span_kind(&format!("{value:?}"))
460458
}
461459
SPAN_STATUS_CODE_FIELD => {
462-
self.span_builder_updates.status = Some(str_to_status(&format!("{:?}", value)))
460+
self.span_builder_updates.status = Some(str_to_status(&format!("{value:?}")))
463461
}
464462
SPAN_STATUS_DESCRIPTION_FIELD => {
465-
self.span_builder_updates.status = Some(otel::Status::error(format!("{:?}", value)))
463+
self.span_builder_updates.status = Some(otel::Status::error(format!("{value:?}")))
466464
}
467465
_ => self.record(KeyValue::new(
468466
Key::new(field.name()),
469-
Value::String(format!("{:?}", value).into()),
467+
Value::String(format!("{value:?}").into()),
470468
)),
471469
}
472470
}
@@ -1212,7 +1210,7 @@ impl Timings {
12121210
}
12131211

12141212
fn thread_id_integer(id: thread::ThreadId) -> u64 {
1215-
let thread_id = format!("{:?}", id);
1213+
let thread_id = format!("{id:?}");
12161214
thread_id
12171215
.trim_start_matches("ThreadId(")
12181216
.trim_end_matches(')')

src/metrics.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,8 @@ impl Visit for MetricVisitor<'_> {
188188
} else {
189189
eprintln!(
190190
"[tracing-opentelemetry]: Received Counter metric, but \
191-
provided u64: {} is greater than i64::MAX. Ignoring \
192-
this metric.",
193-
value
191+
provided u64: {value} is greater than i64::MAX. Ignoring \
192+
this metric."
194193
);
195194
}
196195
} else if let Some(metric_name) = field.name().strip_prefix(METRIC_PREFIX_HISTOGRAM) {

src/tracer.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,7 @@ mod tests {
212212
assert_eq!(
213213
sampled.span().span_context().is_sampled(),
214214
is_sampled,
215-
"{}",
216-
name
215+
"{name}"
217216
)
218217
}
219218
}

tests/metrics_publishing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ where
674674
}
675675
}
676676
unexpected => {
677-
panic!("InstrumentKind {:?} not currently supported!", unexpected)
677+
panic!("InstrumentKind {unexpected:?} not currently supported!")
678678
}
679679
}
680680
});

0 commit comments

Comments
 (0)