Skip to content

Add span decoder for slices #883

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion data-pipeline/src/trace_exporter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ impl TraceExporter {

fn send_deser_ser(&self, data: tinybytes::Bytes) -> Result<String, TraceExporterError> {
// TODO base on input format
let (mut traces, size) = match msgpack_decoder::v04::decoder::from_slice(data) {
let (mut traces, size) = match msgpack_decoder::v04::decoder::from_bytes(data) {
Ok(res) => res,
Err(err) => {
error!("Error deserializing trace from request body: {err}");
Expand Down
15 changes: 15 additions & 0 deletions tinybytes/src/bytes_string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,21 @@ impl BytesString {
}
}

/// Creates a `BytesString` from a string slice within the given buffer.
///
/// # Arguments
///
/// * `bytes` - A `tinybytes::Bytes` instance that will be converted into a `BytesString`.
/// * `slice` - The string slice pointing into the given bytes that will form the `BytesString`.
pub fn try_from_bytes_slice(bytes: &Bytes, slice: &str) -> Option<Self> {
// SAFETY: This is safe as a str slice is definitely a valid UTF-8 slice.
unsafe {
Some(Self::from_bytes_unchecked(
bytes.slice_ref(slice.as_bytes())?,
))
}
}

/// Creates a `BytesString` from a `tinybytes::Bytes` instance without validating the bytes.
///
/// This function does not perform any validation on the provided bytes, and assumes that the
Expand Down
1 change: 1 addition & 0 deletions trace-utils/src/msgpack_decoder/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright 2024-Present Datadog, Inc. https://www.datadoghq.com/
// SPDX-License-Identifier: Apache-2.0

/// Decoding logic for V04 encoded trace payload
pub mod v04;
Loading
Loading