Skip to content

Commit

Permalink
Merge branch 'main' into levi/split-net
Browse files Browse the repository at this point in the history
  • Loading branch information
morrisonlevi committed Dec 4, 2024
2 parents 1cf5035 + a3c1bd4 commit c665eb4
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 36 deletions.
19 changes: 9 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion LICENSE-3rdparty.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22948,7 +22948,7 @@ third_party_libraries:
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
- package_name: rustls
package_version: 0.23.16
package_version: 0.23.18
repository: https://github.com/rustls/rustls
license: Apache-2.0 OR ISC OR MIT
licenses:
Expand Down
7 changes: 6 additions & 1 deletion builder/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,12 @@ impl Builder {

pub fn add_cmake(&self) {
let libs = arch::NATIVE_LIBS.to_owned();
let cmake_path: PathBuf = [&self.target_dir, "DatadogConfig.cmake"].iter().collect();
let cmake_dir: PathBuf = [&self.target_dir, "cmake"].iter().collect();
fs::create_dir_all(cmake_dir).expect("Failed to create cmake dir");

let cmake_path: PathBuf = [&self.target_dir, "cmake", "DatadogConfig.cmake"]
.iter()
.collect();
let mut origin = project_root();
origin.push("cmake");
origin.push("DatadogConfig.cmake.in");
Expand Down
7 changes: 5 additions & 2 deletions builder/src/crashtracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@ pub struct CrashTracker {
impl CrashTracker {
fn gen_binaries(&self) -> Result<()> {
if arch::BUILD_CRASHTRACKER {
let mut datadog_root = project_root();
datadog_root.push(self.target_dir.as_ref());

let mut crashtracker_dir = project_root();
crashtracker_dir.push("crashtracker");
let _dst = cmake::Config::new(crashtracker_dir.to_str().unwrap())
.define("Datadog_ROOT", self.target_dir.as_ref())
.define("CMAKE_INSTALL_PREFIX", self.target_dir.as_ref())
.define("Datadog_ROOT", datadog_root.to_str().unwrap())
.define("CMAKE_INSTALL_PREFIX", self.target_dir.to_string())
.build();
}

Expand Down
3 changes: 1 addition & 2 deletions data-pipeline-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,4 @@ build_common = { path = "../build-common" }
[dependencies]
data-pipeline = { path = "../data-pipeline" }
ddcommon-ffi = { path = "../ddcommon-ffi", default-features = false }
bytes = "1.4"
libc = "0.2.153"
tinybytes = { path = "../tinybytes" }
16 changes: 13 additions & 3 deletions data-pipeline-ffi/src/trace_exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,27 @@ pub unsafe extern "C" fn ddog_trace_exporter_free(handle: Box<TraceExporter>) {
///
/// * `handle` - The handle to the TraceExporter instance.
/// * `trace` - The traces to send to the Datadog Agent in the input format used to create the
/// TraceExporter.
/// TraceExporter. The memory for the trace must be valid for the life of the call to this
/// function.
/// * `trace_count` - The number of traces to send to the Datadog Agent.
#[no_mangle]
pub unsafe extern "C" fn ddog_trace_exporter_send(
handle: &TraceExporter,
trace: ByteSlice,
trace_count: usize,
) -> MaybeError {
// TODO - handle errors - https://datadoghq.atlassian.net/browse/APMSP-1095
// necessary that the trace be static for the life of the FFI function call as the caller
// currently owns the memory.
//APMSP-1621 - Properly fix this sharp-edge by allocating memory on the Rust side
let static_trace: ByteSlice<'static> = std::mem::transmute(trace);

// TODO: APMSP-1095 - properly handle errors from the send call
handle
.send(trace.as_bytes(), trace_count)
.send(
tinybytes::Bytes::from_static(static_trace.as_slice()),
trace_count,
)
.unwrap_or(String::from(""));

MaybeError::None
}
4 changes: 3 additions & 1 deletion data-pipeline/examples/send-traces-with-stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ fn main() {
traces.push(trace);
}
let data = rmp_serde::to_vec_named(&traces).unwrap();
exporter.send(&data, 100).unwrap();
let data_as_bytes = tinybytes::Bytes::from(data);

exporter.send(data_as_bytes, 100).unwrap();
exporter.shutdown(None).unwrap();
}
31 changes: 15 additions & 16 deletions data-pipeline/src/trace_exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,15 +254,11 @@ impl TraceExporter {

/// Send msgpack serialized traces to the agent
#[allow(missing_docs)]
pub fn send(&self, data: &[u8], trace_count: usize) -> Result<String, String> {
pub fn send(&self, data: tinybytes::Bytes, trace_count: usize) -> Result<String, String> {
self.check_agent_info();
match self.input_format {
TraceExporterInputFormat::Proxy => self.send_proxy(data, trace_count),
TraceExporterInputFormat::V04 => {
self.send_deser_ser(tinybytes::Bytes::copy_from_slice(data))
// TODO: APMSP-1582 - Refactor data-pipeline-ffi so we can leverage a type that
// implements tinybytes::UnderlyingBytes trait to avoid copying
}
TraceExporterInputFormat::Proxy => self.send_proxy(data.as_ref(), trace_count),
TraceExporterInputFormat::V04 => self.send_deser_ser(data),
}
}

Expand Down Expand Up @@ -1188,7 +1184,7 @@ mod tests {
..Default::default()
}];

let data = rmp_serde::to_vec_named(&vec![trace_chunk]).unwrap();
let data = tinybytes::Bytes::from(rmp_serde::to_vec_named(&vec![trace_chunk]).unwrap());

// Wait for the info fetcher to get the config
while mock_info.hits() == 0 {
Expand All @@ -1197,7 +1193,7 @@ mod tests {
})
}

exporter.send(data.as_slice(), 1).unwrap();
exporter.send(data, 1).unwrap();
exporter.shutdown(None).unwrap();

mock_traces.assert();
Expand Down Expand Up @@ -1315,8 +1311,10 @@ mod tests {
..Default::default()
}],
];
let bytes = rmp_serde::to_vec_named(&traces).expect("failed to serialize static trace");
let _result = exporter.send(&bytes, 1).expect("failed to send trace");
let bytes = tinybytes::Bytes::from(
rmp_serde::to_vec_named(&traces).expect("failed to serialize static trace"),
);
let _result = exporter.send(bytes, 1).expect("failed to send trace");

assert_eq!(
&format!(
Expand Down Expand Up @@ -1347,9 +1345,8 @@ mod tests {
stats_socket.local_addr().unwrap().to_string(),
);

let _result = exporter
.send(b"some_bad_payload", 1)
.expect("failed to send trace");
let bad_payload = tinybytes::Bytes::copy_from_slice(b"some_bad_payload".as_ref());
let _result = exporter.send(bad_payload, 1).expect("failed to send trace");

assert_eq!(
&format!(
Expand Down Expand Up @@ -1382,8 +1379,10 @@ mod tests {
name: BytesString::from_slice(b"test").unwrap(),
..Default::default()
}]];
let bytes = rmp_serde::to_vec_named(&traces).expect("failed to serialize static trace");
let _result = exporter.send(&bytes, 1).expect("failed to send trace");
let bytes = tinybytes::Bytes::from(
rmp_serde::to_vec_named(&traces).expect("failed to serialize static trace"),
);
let _result = exporter.send(bytes, 1).expect("failed to send trace");

assert_eq!(
&format!(
Expand Down

0 comments on commit c665eb4

Please sign in to comment.