Skip to content

Commit d207172

Browse files
committed
Rename to BytesData
Signed-off-by: Bob Weinand <[email protected]>
1 parent 9b3e236 commit d207172

File tree

4 files changed

+16
-17
lines changed

4 files changed

+16
-17
lines changed

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ impl SpanBytes for Bytes {
9999
/// Trait representing a tuple of (Text, Bytes) types used for different underlying data structures.
100100
/// Note: The functions are internal to the msgpack decoder and should not be used directly: they're
101101
/// only exposed here due to the inavailability of min_specialization in stable Rust.
102-
pub trait TraceData: Default + Debug + Clone + PartialEq + Serialize {
102+
pub trait TraceData: Default + Clone + Debug + PartialEq + Serialize {
103103
type Text: SpanText;
104104
type Bytes: SpanBytes;
105105

@@ -111,9 +111,9 @@ pub trait TraceData: Default + Debug + Clone + PartialEq + Serialize {
111111
}
112112

113113
/// TraceData implementation using `Bytes` and `BytesString`.
114-
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
115-
pub struct TinyData;
116-
impl TraceData for TinyData {
114+
#[derive(Clone, Default, Debug, PartialEq, Serialize)]
115+
pub struct BytesData;
116+
impl TraceData for BytesData {
117117
type Text = BytesString;
118118
type Bytes = Bytes;
119119

@@ -134,7 +134,6 @@ impl TraceData for TinyData {
134134

135135
#[inline]
136136
fn read_string(buf: &mut Bytes) -> Result<BytesString, DecodeError> {
137-
// Note: we need to pass a &'static lifetime here, otherwise it'll complain
138137
read_string_ref_nomut(unsafe { buf.as_mut_slice() }).map(|(str, newbuf)| {
139138
let string = BytesString::from_bytes_slice(buf, str);
140139
*unsafe { buf.as_mut_slice() } = newbuf;
@@ -144,7 +143,7 @@ impl TraceData for TinyData {
144143
}
145144

146145
/// TraceData implementation using `&str` and `&[u8]`.
147-
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
146+
#[derive(Clone, Default, Debug, PartialEq, Serialize)]
148147
pub struct SliceData<'a>(PhantomData<&'a u8>);
149148
impl<'a> TraceData for SliceData<'a> {
150149
type Text = &'a str;

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2023-Present Datadog, Inc. https://www.datadoghq.com/
22
// SPDX-License-Identifier: Apache-2.0
33

4-
use crate::span::{SliceData, SpanKeyParseError, TinyData, TraceData};
4+
use crate::span::{BytesData, SliceData, SpanKeyParseError, TraceData};
55
use crate::tracer_payload::TraceChunks;
66
use serde::ser::SerializeStruct;
77
use serde::Serialize;
@@ -217,19 +217,19 @@ fn is_default<T: Default + PartialEq>(t: &T) -> bool {
217217
t == &T::default()
218218
}
219219

220-
pub type SpanBytes = Span<TinyData>;
221-
pub type SpanLinkBytes = SpanLink<TinyData>;
222-
pub type SpanEventBytes = SpanEvent<TinyData>;
223-
pub type AttributeAnyValueBytes = AttributeAnyValue<TinyData>;
224-
pub type AttributeArrayValueBytes = AttributeArrayValue<TinyData>;
220+
pub type SpanBytes = Span<BytesData>;
221+
pub type SpanLinkBytes = SpanLink<BytesData>;
222+
pub type SpanEventBytes = SpanEvent<BytesData>;
223+
pub type AttributeAnyValueBytes = AttributeAnyValue<BytesData>;
224+
pub type AttributeArrayValueBytes = AttributeArrayValue<BytesData>;
225225

226226
pub type SpanSlice<'a> = Span<SliceData<'a>>;
227227
pub type SpanLinkSlice<'a> = SpanLink<SliceData<'a>>;
228228
pub type SpanEventSlice<'a> = SpanEvent<SliceData<'a>>;
229229
pub type AttributeAnyValueSlice<'a> = AttributeAnyValue<SliceData<'a>>;
230230
pub type AttributeArrayValueSlice<'a> = AttributeArrayValue<SliceData<'a>>;
231231

232-
pub type TraceChunksBytes = TraceChunks<TinyData>;
232+
pub type TraceChunksBytes = TraceChunks<BytesData>;
233233

234234
#[cfg(test)]
235235
mod tests {

datadog-trace-utils/src/test_utils/datadog_test_agent.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ impl DatadogAgentContainerBuilder {
216216
///
217217
/// let data = SendData::new(
218218
/// 100,
219-
/// TracerPayloadCollection::V04(vec![trace.clone()]),
219+
/// TracerPayloadCollection::V04(vec![trace]),
220220
/// TracerHeaderTags::default(),
221221
/// &endpoint,
222222
/// );

datadog-trace-utils/src/tracer_payload.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2024-Present Datadog, Inc. https://www.datadoghq.com/
22
// SPDX-License-Identifier: Apache-2.0
33

4-
use crate::span::{v04, v05, TinyData, TraceData};
4+
use crate::span::{v04, v05, BytesData, TraceData};
55
use crate::trace_utils::collect_trace_chunks;
66
use crate::{msgpack_decoder, trace_utils::cmp_send_data_payloads};
77
use datadog_trace_protobuf::pb;
@@ -29,7 +29,7 @@ pub enum TraceChunks<T: TraceData> {
2929
V05((Vec<T::Text>, Vec<Vec<v05::Span>>)),
3030
}
3131

32-
impl TraceChunks<TinyData> {
32+
impl TraceChunks<BytesData> {
3333
pub fn into_tracer_payload_collection(self) -> TracerPayloadCollection {
3434
match self {
3535
TraceChunks::V04(traces) => TracerPayloadCollection::V04(traces),
@@ -222,7 +222,7 @@ impl TraceChunkProcessor for DefaultTraceChunkProcessor {
222222
pub fn decode_to_trace_chunks(
223223
data: tinybytes::Bytes,
224224
encoding_type: TraceEncoding,
225-
) -> Result<(TraceChunks<TinyData>, usize), anyhow::Error> {
225+
) -> Result<(TraceChunks<BytesData>, usize), anyhow::Error> {
226226
let (data, size) = match encoding_type {
227227
TraceEncoding::V04 => msgpack_decoder::v04::from_bytes(data),
228228
TraceEncoding::V05 => msgpack_decoder::v05::from_bytes(data),

0 commit comments

Comments
 (0)