Skip to content

Commit 3df1b9d

Browse files
authored
chore(linting): fix linting (#41)
1 parent 8495657 commit 3df1b9d

File tree

13 files changed

+44
-53
lines changed

13 files changed

+44
-53
lines changed

datadog-opentelemetry-mappings/src/transform/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,9 +349,9 @@ fn dd_value_to_string(value: &AttributeAnyValue<BytesString>) -> BytesString {
349349
fn write_scalar(value: &AttributeArrayValue<BytesString>, w: &mut String) {
350350
let _ = match value {
351351
AttributeArrayValue::String(s) => write!(w, "{}", s.as_str()),
352-
AttributeArrayValue::Integer(i) => write!(w, "{}", i),
353-
AttributeArrayValue::Double(d) => write!(w, "{}", d),
354-
AttributeArrayValue::Boolean(b) => write!(w, "{}", b),
352+
AttributeArrayValue::Integer(i) => write!(w, "{i}"),
353+
AttributeArrayValue::Double(d) => write!(w, "{d}"),
354+
AttributeArrayValue::Boolean(b) => write!(w, "{b}"),
355355
};
356356
}
357357
fn write_vec(value: &[AttributeArrayValue<BytesString>], w: &mut String) {

datadog-opentelemetry-mappings/src/transform/otel_util.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ pub fn get_otel_operation_name_v2(span: &impl OtelSpan) -> Cow<'static, str> {
6565
SpanKind::Client | SpanKind::Server | SpanKind::Consumer | SpanKind::Producer
6666
)
6767
{
68-
return Cow::Owned(format!("{}.{}", messaging_system, messaging_operation).to_lowercase());
68+
return Cow::Owned(format!("{messaging_system}.{messaging_operation}").to_lowercase());
6969
}
7070

7171
// RPC & AWS
@@ -91,7 +91,7 @@ pub fn get_otel_operation_name_v2(span: &impl OtelSpan) -> Cow<'static, str> {
9191
let faas_invoked_name = span.get_attr_str(FAAS_INVOKED_NAME);
9292
if is_client && !faas_invoked_provider.is_empty() && !faas_invoked_name.is_empty() {
9393
return Cow::Owned(
94-
format!("{}.{}.invoke", faas_invoked_provider, faas_invoked_name).to_lowercase(),
94+
format!("{faas_invoked_provider}.{faas_invoked_name}.invoke").to_lowercase(),
9595
);
9696
}
9797

@@ -147,7 +147,7 @@ pub fn get_otel_resource_v2(span: &impl OtelSpan) -> Cow<'static, str> {
147147
if matches!(span.span_kind(), SpanKind::Server) {
148148
let route = get_res_span_attributes(span, &[HTTP_ROUTE]);
149149
if !route.is_empty() {
150-
return Cow::Owned(format!("{} {}", m, route));
150+
return Cow::Owned(format!("{m} {route}"));
151151
}
152152
}
153153
return m;
@@ -159,7 +159,7 @@ pub fn get_otel_resource_v2(span: &impl OtelSpan) -> Cow<'static, str> {
159159
let messaging_destination =
160160
get_res_span_attributes(span, &[MESSAGING_DESTINATION, MESSAGING_DESTINATION_NAME]);
161161
if !messaging_destination.is_empty() {
162-
res_name = Cow::Owned(format!("{} {}", res_name, messaging_destination));
162+
res_name = Cow::Owned(format!("{res_name} {messaging_destination}"));
163163
}
164164
return res_name;
165165
}
@@ -169,7 +169,7 @@ pub fn get_otel_resource_v2(span: &impl OtelSpan) -> Cow<'static, str> {
169169
let mut res_name = rpc_method;
170170
let rpc_service = get_res_span_attributes(span, &[RPC_SERVICE]);
171171
if !rpc_service.is_empty() {
172-
res_name = Cow::Owned(format!("{} {}", res_name, rpc_service));
172+
res_name = Cow::Owned(format!("{res_name} {rpc_service}"));
173173
}
174174
return res_name;
175175
}
@@ -179,7 +179,7 @@ pub fn get_otel_resource_v2(span: &impl OtelSpan) -> Cow<'static, str> {
179179
let mut res_name = graphql_operation_type;
180180
let graphql_operation_name = get_res_span_attributes(span, &[GRAPHQL_OPERATION_NAME]);
181181
if !graphql_operation_name.is_empty() {
182-
res_name = Cow::Owned(format!("{} {}", res_name, graphql_operation_name));
182+
res_name = Cow::Owned(format!("{res_name} {graphql_operation_name}"));
183183
}
184184
return res_name;
185185
}
@@ -399,7 +399,7 @@ pub fn get_dd_key_for_otlp_attribute(k: &str) -> BorrowedString {
399399
return BorrowedString::Static(mapped_key);
400400
}
401401
if let Some(suffix) = k.strip_prefix("http.request.header.") {
402-
return BorrowedString::Owned(format!("http.request.headers.{}", suffix));
402+
return BorrowedString::Owned(format!("http.request.headers.{suffix}"));
403403
}
404404
if is_datadog_convention_key(k) {
405405
return BorrowedString::Static("");

datadog-opentelemetry-mappings/src/transform/transform_tests.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -719,35 +719,35 @@ fn hashmap_diff<V: PartialEq + Debug>(
719719
match (a.peek(), b.peek()) {
720720
(Some(a_v), Some(b_v)) => match a_v.0.as_str().cmp(b_v.0.as_str()) {
721721
std::cmp::Ordering::Less => {
722-
writeln!(&mut message, "a :+{:?}", a_v).unwrap();
722+
writeln!(&mut message, "a :+{a_v:?}").unwrap();
723723
a.next();
724724
}
725725
std::cmp::Ordering::Equal => {
726726
if a_v.1 != b_v.1 {
727-
writeln!(&mut message, "a!b: {:?} != {:?}", a_v, b_v).unwrap();
727+
writeln!(&mut message, "a!b: {a_v:?} != {b_v:?}").unwrap();
728728
} else {
729-
writeln!(&mut message, "a b: {:?}", b_v).unwrap();
729+
writeln!(&mut message, "a b: {b_v:?}").unwrap();
730730
}
731731
a.next();
732732
b.next();
733733
}
734734
std::cmp::Ordering::Greater => {
735-
writeln!(&mut message, " b:+{:?}", b_v).unwrap();
735+
writeln!(&mut message, " b:+{b_v:?}").unwrap();
736736
b.next();
737737
}
738738
},
739739
(None, None) => break,
740740
(Some(a_v), None) => {
741-
writeln!(&mut message, "a :+{:?}", a_v).unwrap();
741+
writeln!(&mut message, "a :+{a_v:?}").unwrap();
742742
a.next();
743743
}
744744
(None, Some(b_v)) => {
745-
writeln!(&mut message, " b:+{:?}", b_v).unwrap();
745+
writeln!(&mut message, " b:+{b_v:?}").unwrap();
746746
b.next();
747747
}
748748
}
749749
}
750750
if output != expected {
751-
eprintln!("Hashmaps are not equal :\n{}", message);
751+
eprintln!("Hashmaps are not equal :\n{message}");
752752
}
753753
}

datadog-opentelemetry/src/sampler.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,11 @@ mod tests {
186186
let span_context = SpanContext::new(
187187
trace_id,
188188
span_id,
189-
is_sampled
190-
.then_some(TraceFlags::SAMPLED)
191-
.unwrap_or_default(),
189+
if is_sampled {
190+
TraceFlags::SAMPLED
191+
} else {
192+
Default::default()
193+
},
192194
true,
193195
trace_state.clone(),
194196
);

datadog-opentelemetry/src/span_exporter.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,7 @@ impl DatadogExporter {
167167
))
168168
}
169169
Err(e) => Err(OTelSdkError::InternalFailure(format!(
170-
"DatadogExporter: failed to add trace chunk: {:?}",
171-
e
170+
"DatadogExporter: failed to add trace chunk: {e:?}",
172171
))),
173172
Ok(()) => Ok(()),
174173
}
@@ -183,8 +182,7 @@ impl DatadogExporter {
183182
))
184183
}
185184
Err(e) => Err(OTelSdkError::InternalFailure(format!(
186-
"DatadogExporter: failed to set resource: {:?}",
187-
e
185+
"DatadogExporter: failed to set resource: {e:?}",
188186
))),
189187
Ok(()) => Ok(()),
190188
}
@@ -199,8 +197,7 @@ impl DatadogExporter {
199197
))
200198
}
201199
Err(e) => Err(OTelSdkError::InternalFailure(format!(
202-
"DatadogExporter: failed to trigger flush: {:?}",
203-
e
200+
"DatadogExporter: failed to trigger flush: {e:?}",
204201
))),
205202
Ok(()) => Ok(()),
206203
}
@@ -221,8 +218,7 @@ impl DatadogExporter {
221218
}
222219
Err(e) => {
223220
return Err(OTelSdkError::InternalFailure(format!(
224-
"DatadogExporter: trace exporter shutdown failed {:?}",
225-
e,
221+
"DatadogExporter: trace exporter shutdown failed {e:?}",
226222
)));
227223
}
228224
};
@@ -249,7 +245,7 @@ impl DatadogExporter {
249245
OTelSdkError::InternalFailure("Trace exporter thread panicked".to_string())
250246
})?
251247
.map_err(|e| {
252-
OTelSdkError::InternalFailure(format!("Trace exporter exited with error: {}", e))
248+
OTelSdkError::InternalFailure(format!("Trace exporter exited with error: {e}"))
253249
})
254250
}
255251
}

datadog-opentelemetry/src/text_map_propagator.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -365,9 +365,7 @@ pub mod tests {
365365
assert_eq!(
366366
propagator.extract(&extractor).span().span_context(),
367367
&expected_context,
368-
"Error with traceparent: {}, tracestate: {}",
369-
trace_parent,
370-
trace_state
368+
"Error with traceparent: {trace_parent}, tracestate: {trace_state}",
371369
)
372370
}
373371
}
@@ -404,8 +402,7 @@ pub mod tests {
404402
assert_eq!(
405403
propagator.extract(&extractor).span().span_context(),
406404
&opentelemetry::trace::SpanContext::empty_context(),
407-
"{}",
408-
reason
405+
"{reason}",
409406
)
410407
}
411408
}

datadog-opentelemetry/tests/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,15 +218,15 @@ mod datadog_test_agent {
218218
[
219219
"s:2".to_string(),
220220
"t.dm:-3".to_string(),
221-
format!("p:{:016x}", span_id),
221+
format!("p:{span_id:016x}"),
222222
],
223223
);
224224

225225
assert_subset(
226226
injected.into_iter(),
227227
[(
228228
"traceparent".to_string(),
229-
format!("00-{:032x}-{:016x}-01", trace_id, span_id),
229+
format!("00-{trace_id:032x}-{span_id:016x}-01"),
230230
)],
231231
);
232232
}
@@ -239,7 +239,7 @@ mod datadog_test_agent {
239239
let set: HashSet<_, RandomState> = HashSet::from_iter(set);
240240
for item in subset {
241241
if !set.contains(&item) {
242-
panic!("Set {:?} does not contain subset item {:?}", set, item);
242+
panic!("Set {set:?} does not contain subset item {item:?}");
243243
}
244244
}
245245
}

dd-trace-propagation/src/datadog.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ fn inject_trace_id(trace_id: u128, carrier: &mut dyn Injector, tags: &mut HashMa
7373
if let Some(higher) = higher {
7474
tags.insert(
7575
DATADOG_HIGHER_ORDER_TRACE_ID_BITS_KEY.to_string(),
76-
format!("{:016x}", higher),
76+
format!("{higher:016x}"),
7777
);
7878
} else {
7979
tags.remove(DATADOG_HIGHER_ORDER_TRACE_ID_BITS_KEY);
@@ -589,7 +589,7 @@ mod test {
589589
assert_eq!(carrier[DATADOG_ORIGIN_KEY], "synthetics");
590590
assert_eq!(
591591
carrier[DATADOG_TAGS_KEY],
592-
format!("_dd.p.tid={:016x}", higher)
592+
format!("_dd.p.tid={higher:016x}")
593593
);
594594
}
595595

dd-trace-propagation/src/tracecontext.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ fn inject_tracestate(context: &SpanContext, carrier: &mut dyn Injector) {
8686
.and_then(|sampling| sampling.priority)
8787
.unwrap_or(priority::USER_KEEP);
8888

89-
tracestate_parts.push(format!("{TRACESTATE_SAMPLING_PRIORITY_KEY}:{}", priority));
89+
tracestate_parts.push(format!("{TRACESTATE_SAMPLING_PRIORITY_KEY}:{priority}"));
9090

9191
if let Some(origin) = context.origin.as_ref().map(|origin| {
9292
encode_tag_value(

dd-trace-sampling/src/datadog_sampler.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ impl DatadogSampler {
284284
// Get env from attributes
285285
let env = get_otel_env(span);
286286

287-
format!("service:{},env:{}", service, env)
287+
format!("service:{service},env:{env}")
288288
}
289289

290290
/// Updates the service-based sample rates from the Agent
@@ -678,7 +678,7 @@ mod tests {
678678
assert_eq!(
679679
sampler.service_key(&span),
680680
// Expect the service name from the sampler's resource
681-
format!("service:{},env:production", test_service_name)
681+
format!("service:{test_service_name},env:production")
682682
);
683683

684684
// Test with missing env
@@ -693,7 +693,7 @@ mod tests {
693693
assert_eq!(
694694
sampler.service_key(&span),
695695
// Expect the service name from the sampler's resource and an empty env
696-
format!("service:{},env:", test_service_name)
696+
format!("service:{test_service_name},env:")
697697
);
698698
}
699699

0 commit comments

Comments
 (0)