Skip to content

Commit

Permalink
add test for failing to deser traces to improve coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
ajgajg1134 committed Nov 22, 2024
1 parent 6e8a1f9 commit 0c710ed
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions data-pipeline/src/trace_exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1324,6 +1324,32 @@ mod tests {
);
}

#[test]
#[cfg_attr(miri, ignore)]
fn invalid_traces() {
let stats_socket = net::UdpSocket::bind("127.0.0.1:0").expect("failed to bind host socket");
let _ = stats_socket.set_read_timeout(Some(Duration::from_millis(500)));

let fake_agent = MockServer::start();

let exporter = build_test_exporter(
fake_agent.url("/v0.4/traces"),
stats_socket.local_addr().unwrap().to_string(),
);

let _result = exporter
.send(b"some_bad_payload", 1)
.expect("failed to send trace");

assert_eq!(
&format!(
"datadog.libdatadog.deser_traces.errors:1|c|#libdatadog_version:{}",
env!("CARGO_PKG_VERSION")
),
&read(&stats_socket)
);
}

#[test]
#[cfg_attr(miri, ignore)]
fn health_metrics_error() {
Expand Down

0 comments on commit 0c710ed

Please sign in to comment.