Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
45 changes: 45 additions & 0 deletions libdd-data-pipeline-ffi/src/trace_exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ pub struct TraceExporterConfig {
client_computed_stats: bool,
telemetry_cfg: Option<TelemetryConfig>,
health_metrics_enabled: bool,
process_tags: Option<String>,
test_session_token: Option<String>,
connection_timeout: Option<u64>,
}
Expand Down Expand Up @@ -389,6 +390,26 @@ pub unsafe extern "C" fn ddog_trace_exporter_config_set_client_computed_stats(
)
}

/// Sets the process tags to be included in the stats payload.
#[no_mangle]
pub unsafe extern "C" fn ddog_trace_exporter_config_set_process_tags(
config: Option<&mut TraceExporterConfig>,
process_tags: CharSlice,
) -> Option<Box<ExporterError>> {
catch_panic!(
if let Option::Some(handle) = config {
handle.process_tags = match sanitize_string(process_tags) {
Ok(s) => Some(s),
Err(e) => return Some(e),
};
None
} else {
gen_error!(ErrorCode::InvalidArgument)
},
gen_error!(ErrorCode::Panic)
)
}

/// Sets the `X-Datadog-Test-Session-Token` header. Only used for testing with the test agent.
#[no_mangle]
pub unsafe extern "C" fn ddog_trace_exporter_config_set_test_session_token(
Expand Down Expand Up @@ -456,6 +477,7 @@ pub unsafe extern "C" fn ddog_trace_exporter_new(
.set_env(config.env.as_ref().unwrap_or(&"".to_string()))
.set_app_version(config.version.as_ref().unwrap_or(&"".to_string()))
.set_service(config.service.as_ref().unwrap_or(&"".to_string()))
.set_process_tags(config.process_tags.as_deref().unwrap_or(""))
.set_input_format(config.input_format)
.set_output_format(config.output_format)
.set_connection_timeout(config.connection_timeout);
Expand Down Expand Up @@ -570,6 +592,7 @@ mod tests {
assert!(!cfg.compute_stats);
assert!(cfg.telemetry_cfg.is_none());
assert!(!cfg.health_metrics_enabled);
assert!(cfg.process_tags.is_none());
assert!(cfg.test_session_token.is_none());
assert!(cfg.connection_timeout.is_none());

Expand Down Expand Up @@ -759,6 +782,28 @@ mod tests {
}
}

#[test]
fn config_process_tags_test() {
unsafe {
let error =
ddog_trace_exporter_config_set_process_tags(None, CharSlice::from("k:v"));
assert_eq!(error.as_ref().unwrap().code, ErrorCode::InvalidArgument);

ddog_trace_exporter_error_free(error);

let mut config = Some(TraceExporterConfig::default());
let error = ddog_trace_exporter_config_set_process_tags(
config.as_mut(),
CharSlice::from("key1:val1,key2:val2"),
);

assert_eq!(error, None);

let cfg = config.unwrap();
assert_eq!(cfg.process_tags.as_ref().unwrap(), "key1:val1,key2:val2");
}
}

#[test]
fn config_client_computed_stats_test() {
unsafe {
Expand Down
12 changes: 8 additions & 4 deletions libdd-data-pipeline/src/stats_exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,13 @@ fn encode_stats_payload(
sequence,
stats: buckets,
git_commit_sha: meta.git_commit_sha.clone(),
process_tags: meta.process_tags.clone(),
// These fields are unused or will be set by the Agent
service: String::new(),
container_id: String::new(),
tags: Vec::new(),
agent_aggregation: String::new(),
image_tag: String::new(),
process_tags: String::new(),
process_tags_hash: 0,
}
}
Expand Down Expand Up @@ -217,6 +217,7 @@ mod tests {
language: "rust".into(),
tracer_version: "0.0.0".into(),
runtime_id: "e39d6d12-0752-489f-b488-cf80006c0378".into(),
process_tags: "key1:value1,key2:value2".into(),
..Default::default()
}
}
Expand Down Expand Up @@ -257,7 +258,8 @@ mod tests {
when.method(POST)
.header("Content-type", "application/msgpack")
.path("/v0.6/stats")
.body_includes("libdatadog-test");
.body_includes("libdatadog-test")
.body_includes("key1:value1,key2:value2");
then.status(200).body("");
})
.await;
Expand Down Expand Up @@ -318,7 +320,8 @@ mod tests {
when.method(POST)
.header("Content-type", "application/msgpack")
.path("/v0.6/stats")
.body_includes("libdatadog-test");
.body_includes("libdatadog-test")
.body_includes("key1:value1,key2:value2");
then.status(200).body("");
})
.await;
Expand Down Expand Up @@ -356,7 +359,8 @@ mod tests {
when.method(POST)
.header("Content-type", "application/msgpack")
.path("/v0.6/stats")
.body_includes("libdatadog-test");
.body_includes("libdatadog-test")
.body_includes("key1:value1,key2:value2");
then.status(200).body("");
})
.await;
Expand Down
7 changes: 7 additions & 0 deletions libdd-data-pipeline/src/trace_exporter/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ pub struct TraceExporterBuilder {
language_interpreter: String,
language_interpreter_vendor: String,
git_commit_sha: String,
process_tags: String,
input_format: TraceExporterInputFormat,
output_format: TraceExporterOutputFormat,
dogstatsd_url: Option<String>,
Expand Down Expand Up @@ -111,6 +112,11 @@ impl TraceExporterBuilder {
self
}

pub fn set_process_tags(&mut self, process_tags: &str) -> &mut Self {
process_tags.clone_into(&mut self.process_tags);
self
}

/// Set the `Datadog-Meta-Tracer-Version` header
pub fn set_tracer_version(&mut self, tracer_version: &str) -> &mut Self {
tracer_version.clone_into(&mut self.tracer_version);
Expand Down Expand Up @@ -309,6 +315,7 @@ impl TraceExporterBuilder {
language_interpreter_vendor: self.language_interpreter_vendor,
language: self.language,
git_commit_sha: self.git_commit_sha,
process_tags: self.process_tags,
client_computed_stats: self.client_computed_stats,
client_computed_top_level: self.client_computed_top_level,
hostname: self.hostname,
Expand Down
1 change: 1 addition & 0 deletions libdd-data-pipeline/src/trace_exporter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ pub struct TracerMetadata {
pub language_interpreter: String,
pub language_interpreter_vendor: String,
pub git_commit_sha: String,
pub process_tags: String,
pub client_computed_stats: bool,
pub client_computed_top_level: bool,
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
[[
{
"name": "stats_process_tags_test_03",
"service": "test-service",
"resource": "test-resource",
"trace_id": 0,
"span_id": 1,
"parent_id": 0,
"type": "web",
"meta": {
"_dd.origin": "cloudfunction",
"env": "test-env",
"functionname": "dummy_function_name",
"origin": "cloudfunction",
"runtime-id": "test-runtime-id-value",
"service": "test-service"
},
"metrics": {
"_top_level": 1.0
},
"duration": 5,
"start": 0
},
{
"name": "stats_process_tags_test_01",
"service": "test-service",
"resource": "test-resource",
"trace_id": 0,
"span_id": 2,
"parent_id": 1,
"meta": {
"env": "test-env",
"runtime-id": "test-runtime-id-value",
"service": "test-service"
},
"metrics": {
"_dd_metric1": 1.0,
"_dd_metric2": 2.0
},
"span_events": [
{
"time_unix_nano": 1727211691770715042,
"name": "test_span"
},
{
"time_unix_nano": 1727211691770716000,
"name": "exception",
"attributes": {
"exception.count": {
"type": 2,
"int_value": 1
},
"exception.escaped": {
"type": 1,
"bool_value": true
},
"exception.lines": {
"type": 4,
"array_value": {
"values": [
{
"type": 0,
"string_value": " File \"<string>\", line 1, in <module>"
},
{
"type": 0,
"string_value": " File \"<string>\", line 1, in divide"
}
]
}
},
"exception.message": {
"type": 0,
"string_value": "Cannot divide by zero"
},
"exception.version": {
"type": 3,
"double_value": 4.2
}
}
}
],
"duration": 5,
"start": 1
},
{
"name": "stats_process_tags_test_02",
"service": "test-service",
"resource": "test-resource",
"trace_id": 0,
"span_id": 3,
"parent_id": 1,
"meta": {
"env": "test-env",
"runtime-id": "test-runtime-id-value",
"service": "test-service"
},
"span_links": [
{
"trace_id": 13930160852258120406,
"trace_id_high": 0,
"span_id": 11788048577503494824,
"attributes": {
"link.name": "Job #123"
}
},
{
"trace_id": 12184699170068370717,
"trace_id_high": 5943849730528564606,
"span_id": 13874630024467741450
}
],
"duration": 5,
"start": 1
}]]
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[
{
"Start": 0,
"Duration": 10000000000,
"Stats": [
{
"Name": "stats_process_tags_test_03",
"Resource": "test-resource",
"Service": "test-service",
"Type": "web",
"HTTPStatusCode": 0,
"Synthetics": false,
"Hits": 1,
"TopLevelHits": 1,
"Duration": 5,
"Errors": 0,
"OkSummary": 37,
"ErrorSummary": 24
}
]
}
]
50 changes: 50 additions & 0 deletions libdd-data-pipeline/tests/test_trace_exporter.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024-Present Datadog, Inc. https://www.datadoghq.com/

Check failure on line 1 in libdd-data-pipeline/tests/test_trace_exporter.rs

View workflow job for this annotation

GitHub Actions / [ubuntu-latest:] test report

libdd-data-pipeline/tests/test_trace_exporter.rs.tracing_integration_tests::stats_snapshot_test

tracing_integration_tests::stats_snapshot_test
// SPDX-License-Identifier: Apache-2.0
#[cfg(test)]
mod tracing_integration_tests {
Expand All @@ -10,6 +10,7 @@
use libdd_trace_utils::test_utils::datadog_test_agent::DatadogTestAgent;
use libdd_trace_utils::test_utils::{create_test_json_span, create_test_v05_span};
use serde_json::json;
use std::time::Duration;
use tokio::task;

fn get_v04_trace_snapshot_test_payload(name_prefix: &str) -> Vec<u8> {
Expand Down Expand Up @@ -327,4 +328,53 @@

test_agent.assert_snapshot(snapshot_name).await;
}

#[cfg_attr(miri, ignore)]
#[tokio::test]
async fn stats_snapshot_test() {

Check failure on line 334 in libdd-data-pipeline/tests/test_trace_exporter.rs

View workflow job for this annotation

GitHub Actions / [ubuntu-latest:${RUST_VERSION}] test report

/home/runner/work/libdatadog/libdatadog/libdd-data-pipeline/tests/test_trace_exporter.rs.tracing_integration_tests::stats_snapshot_test

thread 'tracing_integration_tests::stats_snapshot_test' panicked at /home/runner/work/libdatadog/libdatadog/libdd-trace-utils/src/test_utils/datadog_test_agent.rs:419:9
Raw output
thread 'tracing_integration_tests::stats_snapshot_test' panicked at /home/runner/work/libdatadog/libdatadog/libdd-trace-utils/src/test_utils/datadog_test_agent.rs:419:9:
assertion `left == right` failed: Expected status 200, but got 400 Bad Request. Response body: At request <Request GET /test/session/snapshot >:
   At snapshot (token='stats_snapshot_test'):
    - Directory: /snapshots
    - CI mode: 1
    - Trace File: /snapshots/stats_snapshot_test.json
    - Stats File: /snapshots/stats_snapshot_test_tracestats.json
Trace snapshot file '/snapshots/stats_snapshot_test.json' not found. Perhaps the file was not checked into source control? The snapshot file is automatically generated when the test agent is not in CI mode.
  left: 400
 right: 200
stack backtrace:
   0:     0x55572145126a - std::backtrace_rs::backtrace::libunwind::trace::h886f3b0575353f6e
                               at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
   1:     0x55572145126a - std::backtrace_rs::backtrace::trace_unsynchronized::h652d1041ec67eb09
                               at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x55572145126a - std::sys::backtrace::_print_fmt::hd0317245a04c3039
                               at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/std/src/sys/backtrace.rs:66:9
   3:     0x55572145126a - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h14b23c1989cbd5c2
                               at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/std/src/sys/backtrace.rs:39:26
   4:     0x55572147d143 - core::fmt::rt::Argument::fmt::h43c1e387827e30dc
                               at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/core/src/fmt/rt.rs:177:76
   5:     0x55572147d143 - core::fmt::write::h346b5eee5ed4d7cc
                               at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/core/src/fmt/mod.rs:1189:21
   6:     0x55572144d2c3 - std::io::Write::write_fmt::heeb48dcd4a60b46b
                               at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/std/src/io/mod.rs:1884:15
   7:     0x5557214510b2 - std::sys::backtrace::BacktraceLock::print::h48db11f3fd4983ff
                               at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/std/src/sys/backtrace.rs:42:9
   8:     0x5557214526ed - std::panicking::default_hook::{{closure}}::h65db976b9c0d8674
                               at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/std/src/panicking.rs:268:22
   9:     0x555721452533 - std::panicking::default_hook::h6eb3a1192db1ae36
                               at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/std/src/panicking.rs:295:9
  10:     0x555721452cc7 - std::panicking::rust_panic_with_hook::h370ee1901241e459
                               at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/std/src/panicking.rs:801:13
  11:     0x555721452b5a - std::panicking::begin_panic_handler::{{closure}}::heabfe92676d6d073
                               at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/std/src/panicking.rs:674:13
  12:     0x555721451749 - std::sys::backtrace::__rust_end_short_backtrace::h6e22d229d4fdf49e
                               at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/std/src/sys/backtrace.rs:170:18
  13:     0x5557214527ec - rust_begin_unwind
                               at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/std/src/panicking.rs:665:5
  14:     0x5557205f1670 - core::panicking::panic_fmt::hfae270fab21da3e6
                               at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/core/src/panicking.rs:76:14
  15:     0x5557205f1ad5 - core::panicking::assert_failed_inner::h86f4c2c600565e66
  16:     0x55572060f8a3 - core::panicking::assert_failed::h46484391eb315068
                               at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/core/src/panicking.rs:373:5
  17:     0x5557205f3ad7 - libdd_trace_utils::test_utils::datadog_test_agent::DatadogTestAgent::assert_snapshot::{{closure}}::h4965d586e284f947
                               at /home/runner/work/libdatadog/libdatadog/libdd-trace-utils/src/test_utils/datadog_test_agent.rs:419:9
  18:     0x555720632011 - test_trace_exporter::tracing_integration_tests::stats_snapshot_test::{{closure}}::ha25c58ac36f95a3c
                               at /home/runner/work/libdatadog/libdatadog/libdd-data-pipeline/tests/test_trace_exporter.rs:378:51
  19:     0x55572060cc22 - <core::pin::Pin<P> as core::future::future::Future>::poll::h3d364f6e7998de69
                               at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/core/src/future/future.rs:124:9
  20:     0x55572060cc9d - <core::pin::Pin<P> as core::future::future::Future>::poll::h95c81133a6fa9907
                               at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/core/src/future/future.rs:124:9
  21:     0x55572060ca1f - tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}::{{closure}}::{{closure}}::h31844504e1754c9e
                               at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.49.0/src/runtime/scheduler/current_thread/mod.rs:753:54
  22:     0x55572060c965 - tokio::task::coop::with_budget::hc67f5a4762835216
                               at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.49.0/src/task/coop/mod.rs:167:5
  23:     0x55572060c965 - tokio::task::coop::budget::h4e84565380746b70
                               at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.49.0/src/task/coop/mod.rs:133:5
  24:     0x55572060c965 - tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}::{{closure}}::hf7765c1ed13dd193
                               at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.49.0/src/runtime/scheduler/current_thread/mod.rs:753:25
  25:     0x555720609fa0 - tokio::runtime::scheduler::current_thread::Context::enter::h2e25d7ca929ce72f
                               at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.49.0/src/runtime/scheduler/current_thread/mod.rs:442:19
  26:     0x55572060b78b - tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}::h91527709ab0bc56b
                               at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.49.0/src/runtime/scheduler/current_thread/mod.rs:752:36
  27:     0x55572060b4a4 - tokio::runtime::scheduler::current_thread::CoreGuard::enter::{{closure}}::hdeb0d020261adc3a
                               at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.49.0/src/runtime/scheduler/current_thread/mod.rs:840:68
  28:     0x55572061da2b - tokio::runtime::context::scoped::Scoped<T>::set::h107bbc863ab363c1
                               at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.49.0/src/runtime/context/scoped.rs:40:9
  29:     0x5557206103f9 - tokio::runtime::context::set_scheduler::{{closure}}::hc123d869fb4835f9
                               at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.49.0/src/runtime/context.rs:176:26
  30:     0x55572061b35d - std::thread::local::LocalKey<T>::try_with::hba12877280fe16d9
                               at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/std/src/thread/local.rs:283:12
  31:     0x55572061ab6a - std::thread::local::LocalKey<T>::with::ha33419774c5255e9
                               at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/std/src/thread/local.rs:260:9
  32:     0x55572061036d - tokio::runtime::context::set_scheduler::h50bebeaab2ca2c82
                               at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.49.0/src/runtime/context.rs:176:9
  33:     0x55572060ae10 - tokio::runtime::scheduler::current_thread::CoreGuard::enter::h664fb86bf3626ee6
                               at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.49.0/src/runtime/scheduler/current_thread/mod.rs:840:27
  34:     0x55572060b523 - tokio::runtime::scheduler::current_thread::CoreGuard::block_on::hd6e20b93d302c09d
                               at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.49.0/src/runtime/scheduler/current_thread/mod.rs:740:19
  35:     0x55572060928c - tokio::runtime::scheduler::current_thread::CurrentThread::block_on::{{closure}}::h0a3de7f632a5ce5c
                               at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.49.0/src/runtime/scheduler/current_thread/mod.rs:200:28
  36:     0x5557206106e6 - tokio::runtime::context::runtime::enter_runtime::h988c872e5486cdf9
                               at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.49.0/src/runtime/context/runtime.rs:65:16
  37:     0x555720609041 - tokio::runtime::scheduler::current_thread::CurrentThread::block_on::he7c237b1b7b54667
                               at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.49.0/src/runtime/scheduler/current_thread/mod.rs:188:9
  38:     0x55572061dcb3 - tokio::runtime::runtime::Runtime::block_on_inner::h17e504651aa634ea
                               at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.49.0/src/runtime/runtime.rs:368:47
  39:     0x55572061dfbc - tokio::runtime::runtime::Runtime::block_on::hc0d4706965d9e8aa
                               at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.49.0/src/runtime/runtime.rs:342:13
  40:     0x555720631627 - test_trace_exporter::tracing_integration_tests::stats_snapshot_test::h0676f587b7f1d53b
                               at /home/runner/work/libdatadog/libdatadog/libdd-data-pipeline/tests/test_trace_exporter.rs:378:9
  41:     0x5557206314c7 - test_trace_exporter::tracing_integration_tests::stats_snapshot_test::{{closure}}::hf9dfe6de02389fd4
                               at /home/runner/work/libdatadog/libdatadog/libdd-data-pipeline/tests/test_trace_exporter.rs:334:35
  42:     0x5557205f80d6 - core::ops::function::FnOnce::call_once::h84789c396e8ba156
                               at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/core/src/ops/function.rs:250:5
  43:     0x55572067fe9b - core::ops::function::FnOnce::call_once::hcf459d49f817e971
                               at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/core/src/ops/function.rs:250:5
  44:     0x55572067fe9b - test::__rust_begin_short_backtrace::h812692078d2a7065
                               at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/test/src/lib.rs:632:18
  45:     0x55572067f818 - test::run_test_in_process::{{closure}}::he383169452078072
                               at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/test/src/lib.rs:655:60
  46:     0x55572067f818 - <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::hfd3325d295001553
                               at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/core/src/panic/unwind_safe.rs:272:9
  47:     0x55572067f818 - std::panicking::try::do_call::hd41329e64e1d34ac
                               at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/std/src/panicking.rs:557:40
  48:     0x55572067f818 - std::panicking::try::h7a44da38acd5f700
                               at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/std/src/panicking.rs:520:19
  49:     0x55572067f818 - std::panic::catch_unwind::h84ae8452b3d168cb
                               at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/std/src/panic.rs:358:14
  50:     0x55572067f818 - test::run_test_in_process::h0d23dc8c28915531
                               at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/test/src/lib.rs:655:27
  51:     0x55572067f818 - test::run_test::{{closure}}::h427e5ada87ee2030
                               at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/test/src/lib.rs:576:43
  52:     0x5557206432ea - test::run_test::{{closure}}::hb864816fed1c6cd7
                               at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/test/src/lib.rs:606:41
  53:     0x5557206432ea - std::sys::backtrace::__rust_begin_short_backtrace::ha8680ce782bf69f7
                               at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/std/src/sys/backtrace.rs:154:18
  54:     0x555720646c44 - std::thread::Builder::spawn_unchecked_::{{closure}}::{{closure}}::h05b53495b5672e29
                               at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/std/src/thread/mod.rs:561:17
  55:     0x555720646c44 - <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h2a6a6bcc98d0706b
                               at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/core/src/panic/unwind_safe.rs:272:9
  56:     0x555720646c44 - std::panicking::try::do_call::hccc670c81fea40a7
                               at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/std/src/panicking.rs:557:40
  57:     0x555720646c44 - std::panicking::try::h755e3c65d88973b7
                               at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/std/src/panicking.rs:520:19
  58:     0x555720646c44 - std::panic::catch_unwind::hced8032a948c5bd0
                               at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/std/src/panic.rs:358:14
  59:     0x555720646c44 - std::thread::Builder::spawn_unchecked_::{{closure}}::h3b9e5c9edd874915
                               at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/std/src/thread/mod.rs:559:30
  60:     0x555720646c44 - core::ops::function::FnOnce::call_once{{vtable.shim}}::hbc1380969ae25c01
                               at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/core/src/ops/function.rs:250:5
  61:     0x555721457eab - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h0bbb114b77b490c1
                               at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/alloc/src/boxed.rs:1972:9
  62:     0x555721457eab - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h3673811012fc0688
                               at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/alloc/src/boxed.rs:1972:9
  63:     0x555721457eab - std::sys::pal::unix::thread::Thread::new::thread_start::h0feaf4a9a4b2ecde
                               at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/std/src/sys/pal/unix/thread.rs:105:17
  64:     0x7febd009caa4 - <unknown>
  65:     0x7febd0129c6c - <unknown>
  66:                0x0 - <unknown>
let relative_snapshot_path = "libdd-data-pipeline/tests/snapshots/";
let snapshot_name = "stats_snapshot_test";
let test_agent = DatadogTestAgent::new(Some(relative_snapshot_path), None, &[]).await;
let url = test_agent.get_base_uri().await;
test_agent.start_session(snapshot_name, None).await;

let task_result = task::spawn_blocking(move || {
let mut builder = TraceExporter::builder();
builder
.set_url(url.to_string().as_ref())
.set_language("test-lang")
.set_language_version("2.0")
.set_language_interpreter_vendor("vendor")
.set_language_interpreter("interpreter")
.set_tracer_version("1.0")
.set_env("test_env")
.set_service("test")
.set_hostname("test-host")
.set_process_tags("key1:val1,key2:val2")
.set_test_session_token(snapshot_name)
.enable_stats(Duration::from_secs(10));

let trace_exporter = builder.build().expect("Unable to build TraceExporter");

// Give the info-fetcher worker time to fetch agent info on its first iteration.
// Once the cache is populated, the first send() call will enable stats computation
// via check_agent_info() and spans will be recorded in the concentrator.
std::thread::sleep(Duration::from_secs(1));

let data = get_v04_trace_snapshot_test_payload("stats_test");
trace_exporter
.send(data.as_ref())
.expect("Failed to send traces");

// shutdown force-flushes and sends any remaining stats
trace_exporter
.shutdown(Some(Duration::from_secs(5)))
.expect("Failed to shutdown exporter");
})
.await;

assert!(task_result.is_ok());

test_agent.assert_snapshot(snapshot_name).await;
}
}
Loading