Skip to content

Commit 06ce6dd

Browse files
committed
chore(sampling): appease the clippy gods
1 parent 10cb627 commit 06ce6dd

2 files changed

Lines changed: 21 additions & 19 deletions

File tree

libdd-sampling/src/sampling_rule.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,19 @@ impl From<&str> for RuleProvenance {
241241
}
242242
}
243243

244+
/// Helper struct for representing i64 values as ValueLike
245+
struct ValueI64(i64);
246+
247+
impl ValueLike for ValueI64 {
248+
fn extract_float(&self) -> Option<f64> {
249+
Some(self.0 as f64)
250+
}
251+
252+
fn extract_string(&self) -> Option<std::borrow::Cow<'_, str>> {
253+
Some(std::borrow::Cow::Owned(self.0.to_string()))
254+
}
255+
}
256+
244257
#[cfg(test)]
245258
mod tests {
246259
use super::*;
@@ -595,16 +608,3 @@ mod tests {
595608
assert!(RuleProvenance::Dynamic < RuleProvenance::Default);
596609
}
597610
}
598-
599-
/// Helper struct for representing i64 values as ValueLike
600-
struct ValueI64(i64);
601-
602-
impl ValueLike for ValueI64 {
603-
fn extract_float(&self) -> Option<f64> {
604-
Some(self.0 as f64)
605-
}
606-
607-
fn extract_string(&self) -> Option<std::borrow::Cow<'_, str>> {
608-
Some(std::borrow::Cow::Owned(self.0.to_string()))
609-
}
610-
}

libdd-sampling/src/v04_span.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,9 @@ mod tests {
286286

287287
#[test]
288288
fn test_span_attribute_value_metric() {
289-
let val = SpanAttributeValue::Metric(3.14);
290-
assert_eq!(val.extract_float(), Some(3.14));
291-
assert_eq!(val.extract_string(), Some(Cow::Owned("3.14".to_string())));
289+
let val = SpanAttributeValue::Metric(1.5);
290+
assert_eq!(val.extract_float(), Some(1.5));
291+
assert_eq!(val.extract_string(), Some(Cow::Owned("1.5".to_string())));
292292
}
293293

294294
#[test]
@@ -521,9 +521,11 @@ mod tests {
521521
#[test]
522522
fn test_integration_tags_apply_to_span() {
523523
let sampler = DatadogSampler::new(vec![], 100);
524-
let mut span = Span::<SliceData<'static>>::default();
525-
span.name = "op";
526-
span.service = "svc";
524+
let span = Span::<SliceData<'static>> {
525+
name: "op",
526+
service: "svc",
527+
..Default::default()
528+
};
527529

528530
let data = V04SamplingData {
529531
is_parent_sampled: None,

0 commit comments

Comments
 (0)