Skip to content
Merged
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
80 changes: 45 additions & 35 deletions src/native/Cargo.lock

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

14 changes: 7 additions & 7 deletions src/native/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ profiling = ["dep:datadog-profiling-ffi"]

[dependencies]
anyhow = { version = "1.0", optional = true }
datadog-crashtracker = { git = "https://github.com/DataDog/libdatadog", rev = "v20.0.0", optional = true }
datadog-ddsketch = { git = "https://github.com/DataDog/libdatadog", rev = "v20.0.0" }
datadog-library-config = { git = "https://github.com/DataDog/libdatadog", rev = "v20.0.0" }
data-pipeline = { git = "https://github.com/DataDog/libdatadog", rev = "v20.0.0" }
datadog-profiling-ffi = { git = "https://github.com/DataDog/libdatadog", rev = "v20.0.0", optional = true, features = [
datadog-crashtracker = { git = "https://github.com/DataDog/libdatadog", rev = "v21.0.0", optional = true }
datadog-ddsketch = { git = "https://github.com/DataDog/libdatadog", rev = "v21.0.0" }
datadog-library-config = { git = "https://github.com/DataDog/libdatadog", rev = "v21.0.0" }
data-pipeline = { git = "https://github.com/DataDog/libdatadog", rev = "v21.0.0" }
datadog-profiling-ffi = { git = "https://github.com/DataDog/libdatadog", rev = "v21.0.0", optional = true, features = [
"cbindgen",
] }
ddcommon = { git = "https://github.com/DataDog/libdatadog", rev = "v20.0.0" }
ddcommon = { git = "https://github.com/DataDog/libdatadog", rev = "v21.0.0" }
pyo3 = { version = "0.25", features = ["extension-module", "anyhow"] }

[build-dependencies]
pyo3-build-config = "0.25"
build_common = { git = "https://github.com/DataDog/libdatadog", rev = "v20.0.0", features = [
build_common = { git = "https://github.com/DataDog/libdatadog", rev = "v21.0.0", features = [
"cbindgen",
] }

Expand Down
6 changes: 6 additions & 0 deletions src/native/data_pipeline/exceptions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ impl From<TraceExporterErrorPy> for PyErr {
TraceExporterError::Serialization(error) => {
SerializationError::new_err(error.to_string())
}
TraceExporterError::Shutdown(error) => {
InternalError::new_err(format!("Shutdown error: {}", error))
}
TraceExporterError::Telemetry(error) => {
InternalError::new_err(format!("Telemetry error: {}", error))
}
}
}
}
Expand Down
10 changes: 8 additions & 2 deletions src/native/library_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@ impl PyConfigurator {
&ProcessInfo::detect_global("python".to_string()),
);
match res_config {
Ok(config) => {
datadog_library_config::LoggedResult::Ok(config, logs) => {
// Previously, `libdatadog` printed debug logs to stderr. However,
// in v21.0.0, we changed the behavior to buffer them and return
// them in the logs returned by this `LoggedResult`.
for log_msg in logs.iter() {
eprintln!("{}", log_msg);
}
let list = PyList::empty(py);
for c in config.iter() {
let dict = PyDict::new(py);
Expand All @@ -54,7 +60,7 @@ impl PyConfigurator {
}
Ok(list.into())
}
Err(e) => {
datadog_library_config::LoggedResult::Err(e) => {
let err_msg = format!("Failed to get configuration: {e:?}");
Err(PyException::new_err(err_msg))
}
Expand Down
25 changes: 19 additions & 6 deletions tests/internal/crashtracker/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,13 @@ def logs(self):

def wait_for_crash_reports(test_agent_client: TestAgentClient) -> List[TestAgentRequest]:
crash_reports = []
for _ in range(5):
crash_reports = test_agent_client.crash_reports()
if crash_reports:
return crash_reports
for _ in range(10): # 10 iterations * 0.1 second = 1 second total
incoming_reports = test_agent_client.crash_reports()
if incoming_reports:
crash_reports.extend(incoming_reports)
# If we have both crash ping and crash report (2 reports), we can return early
if len(crash_reports) >= 2:
return crash_reports
time.sleep(0.1)

return crash_reports
Expand All @@ -126,8 +129,18 @@ def wait_for_crash_reports(test_agent_client: TestAgentClient) -> List[TestAgent
def get_crash_report(test_agent_client: TestAgentClient) -> TestAgentRequest:
"""Wait for a crash report from the crashtracker listener socket."""
crash_reports = wait_for_crash_reports(test_agent_client)
assert len(crash_reports) == 1
return crash_reports[0]
# We want at least the crash report
assert len(crash_reports) == 2, f"Expected at 2 messages; one ping and one report, got {len(crash_reports)}"

# Find the actual crash report (the one with "is_crash":"true")
actual_crash_report = None
for report in crash_reports:
if b"is_crash:true" in report["body"]:
actual_crash_report = report
break

assert actual_crash_report is not None, "Could not find crash report with 'is_crash:true' tag"
return actual_crash_report


@contextmanager
Expand Down
Loading