Skip to content

Commit 4be708f

Browse files
Rename SpanValue
1 parent f27b214 commit 4be708f

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

trace-utils/src/span/v04/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ mod span;
55

66
pub mod trace_utils;
77

8-
pub use span::{Span, SpanBytes, SpanKey, SpanKeyParseError, SpanLink, SpanLinkBytes, SpanValue};
8+
pub use span::{Span, SpanBytes, SpanKey, SpanKeyParseError, SpanLink, SpanLinkBytes, SpanText};

trace-utils/src/span/v04/span.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ impl FromStr for SpanKey {
5353

5454
/// Trait representing the requirements for a type to be used as a Span "string" type.
5555
/// Note: Borrow<str> is not required by the derived traits, but allows to access HashMap elements
56-
/// from a static str.
57-
pub trait SpanValue: Eq + Hash + Borrow<str> {}
58-
/// Implement the SpanValue trait for any type which satisfies the sub trait.
59-
impl<T: Eq + Hash + Borrow<str>> SpanValue for T {}
56+
/// from a static str and check if the string is empty.
57+
pub trait SpanText: Eq + Hash + Borrow<str> {}
58+
/// Implement the SpanText trait for any type which satisfies the sub traits.
59+
impl<T: Eq + Hash + Borrow<str>> SpanText for T {}
6060

61-
/// Checks if the `value` represents an empty string. Used to skip serializing empty strings in
61+
/// Checks if the `value` represents an empty string. Used to skip serializing empty strings
6262
/// with serde.
6363
fn is_empty_str<T: Borrow<str>>(value: &T) -> bool {
6464
value.borrow().is_empty()
@@ -70,15 +70,15 @@ fn is_empty_str<T: Borrow<str>>(value: &T) -> bool {
7070
/// or borrowed (e.g. &str). To define a generic function taking any `Span<T>` you can use the
7171
/// [`SpanValue`] trait:
7272
/// ```
73-
/// use datadog_trace_utils::span::v04::{Span, SpanValue};
74-
/// fn foo<T: SpanValue>(span: Span<T>) {
73+
/// use datadog_trace_utils::span::v04::{Span, SpanText};
74+
/// fn foo<T: SpanText>(span: Span<T>) {
7575
/// let _ = span.meta.get("foo");
7676
/// }
7777
/// ```
7878
#[derive(Clone, Debug, Default, PartialEq, Serialize)]
7979
pub struct Span<T>
8080
where
81-
T: SpanValue,
81+
T: SpanText,
8282
{
8383
pub service: T,
8484
pub name: T,
@@ -108,7 +108,7 @@ where
108108
#[derive(Clone, Debug, Default, PartialEq, Serialize)]
109109
pub struct SpanLink<T>
110110
where
111-
T: SpanValue,
111+
T: SpanText,
112112
{
113113
pub trace_id: u64,
114114
pub trace_id_high: u64,

trace-utils/src/span/v04/trace_utils.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
//! Trace-utils functionalities implementation for tinybytes based spans
55
6-
use super::{Span, SpanValue};
6+
use super::{Span, SpanText};
77
use std::collections::HashMap;
88

99
/// Span metric the mini agent must set for the backend to recognize top level span
@@ -15,7 +15,7 @@ const PARTIAL_VERSION_KEY: &str = "_dd.partial_version";
1515

1616
fn set_top_level_span<'a, T>(span: &mut Span<T>, is_top_level: bool)
1717
where
18-
T: SpanValue + From<&'a str>,
18+
T: SpanText + From<&'a str>,
1919
{
2020
if is_top_level {
2121
span.metrics.insert(TOP_LEVEL_KEY.into(), 1.0);
@@ -32,7 +32,7 @@ where
3232
/// ancestor of other spans belonging to this service and attached to it).
3333
pub fn compute_top_level_span<'a, T>(trace: &mut [Span<T>])
3434
where
35-
T: SpanValue + Clone + From<&'a str>,
35+
T: SpanText + Clone + From<&'a str>,
3636
{
3737
let mut span_id_to_service: HashMap<u64, T> = HashMap::new();
3838
for span in trace.iter() {
@@ -59,15 +59,15 @@ where
5959
}
6060

6161
/// Return true if the span has a top level key set
62-
pub fn has_top_level<T: SpanValue>(span: &Span<T>) -> bool {
62+
pub fn has_top_level<T: SpanText>(span: &Span<T>) -> bool {
6363
span.metrics
6464
.get(TRACER_TOP_LEVEL_KEY)
6565
.is_some_and(|v| *v == 1.0)
6666
|| span.metrics.get(TOP_LEVEL_KEY).is_some_and(|v| *v == 1.0)
6767
}
6868

6969
/// Returns true if a span should be measured (i.e., it should get trace metrics calculated).
70-
pub fn is_measured<T: SpanValue>(span: &Span<T>) -> bool {
70+
pub fn is_measured<T: SpanText>(span: &Span<T>) -> bool {
7171
span.metrics.get(MEASURED_KEY).is_some_and(|v| *v == 1.0)
7272
}
7373

@@ -76,7 +76,7 @@ pub fn is_measured<T: SpanValue>(span: &Span<T>) -> bool {
7676
/// When incomplete, a partial snapshot has a metric _dd.partial_version which is a positive
7777
/// integer. The metric usually increases each time a new version of the same span is sent by
7878
/// the tracer
79-
pub fn is_partial_snapshot<T: SpanValue>(span: &Span<T>) -> bool {
79+
pub fn is_partial_snapshot<T: SpanText>(span: &Span<T>) -> bool {
8080
span.metrics
8181
.get(PARTIAL_VERSION_KEY)
8282
.is_some_and(|v| *v >= 0.0)

0 commit comments

Comments
 (0)