diff --git a/Cargo.lock b/Cargo.lock index 401bac2592..68e1cb81ae 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -862,9 +862,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.28" +version = "1.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e80e3b6a3ab07840e1cae9b0666a63970dc28e8ed5ffbcdacbfc760c281bfc1" +checksum = "c2e7962b54006dcfcc61cb72735f4d89bb97061dd6a7ed882ec6b8ee53714c6f" dependencies = [ "jobserver", "libc 0.2.159", @@ -1732,6 +1732,7 @@ name = "ddcommon" version = "0.0.1" dependencies = [ "anyhow", + "cc", "futures", "futures-core", "futures-util", @@ -1982,7 +1983,6 @@ dependencies = [ "datadog-trace-protobuf", "ddcommon 0.0.1", "http 0.2.11", - "hyper 0.14.28", "serde", "tracing", ] diff --git a/components-rs/common.h b/components-rs/common.h index 1044c8ad0a..bedd9cb5f2 100644 --- a/components-rs/common.h +++ b/components-rs/common.h @@ -959,14 +959,23 @@ typedef struct ddog_crasht_Slice_CharSlice { typedef struct ddog_crasht_Config { struct ddog_crasht_Slice_CharSlice additional_files; bool create_alt_stack; + bool use_alt_stack; /** * The endpoint to send the crash report to (can be a file://). * If None, the crashtracker will infer the agent host from env variables. */ const struct ddog_Endpoint *endpoint; enum ddog_crasht_StacktraceCollection resolve_frames; - uint64_t timeout_secs; - bool wait_for_receiver; + /** + * Timeout in milliseconds before the signal handler starts tearing things down to return. + * This is given as a uint32_t, but the actual timeout needs to fit inside of an i32 (max + * 2^31-1). This is a limitation of the various interfaces used to guarantee the timeout. + */ + uint32_t timeout_ms; + /** + * Optional filename for a unix domain socket if the receiver is used asynchonously + */ + ddog_CharSlice optional_unix_socket_filename; } ddog_crasht_Config; typedef struct ddog_crasht_EnvVar { diff --git a/components-rs/crashtracker.h b/components-rs/crashtracker.h index 42c18798c3..a3053affaa 100644 --- a/components-rs/crashtracker.h +++ b/components-rs/crashtracker.h @@ -39,8 +39,7 @@ DDOG_CHECK_RETURN struct ddog_crasht_Result ddog_crasht_shutdown(void); * Reinitialize the crash-tracking infrastructure after a fork. * This should be one of the first things done after a fork, to minimize the * chance that a crash occurs between the fork, and this call. - * In particular, reset the counters that track the profiler state machine, - * and start a new receiver to collect data from this fork. + * In particular, reset the counters that track the profiler state machine. * NOTE: An alternative design would be to have a 1:many sidecar listening on a * socket instead of 1:1 receiver listening on a pipe, but the only real * advantage would be to have fewer processes in `ps -a`. @@ -73,15 +72,15 @@ struct ddog_crasht_Result ddog_crasht_update_on_fork(struct ddog_crasht_Config c * unexpected crash-handling behaviour. */ DDOG_CHECK_RETURN -struct ddog_crasht_Result ddog_crasht_init_with_receiver(struct ddog_crasht_Config config, - struct ddog_crasht_ReceiverConfig receiver_config, - struct ddog_crasht_Metadata metadata); +struct ddog_crasht_Result ddog_crasht_init(struct ddog_crasht_Config config, + struct ddog_crasht_ReceiverConfig receiver_config, + struct ddog_crasht_Metadata metadata); /** - * Initialize the crash-tracking infrastructure, writing to an unix socket in case of crash. + * Initialize the crash-tracking infrastructure without launching the receiver. * * # Preconditions - * None. + * Requires `config` to be given with a `unix_socket_path`, which is normally optional. * # Safety * Crash-tracking functions are not reentrant. * No other crash-handler functions should be called concurrently. @@ -90,8 +89,7 @@ struct ddog_crasht_Result ddog_crasht_init_with_receiver(struct ddog_crasht_Conf * unexpected crash-handling behaviour. */ DDOG_CHECK_RETURN -struct ddog_crasht_Result ddog_crasht_init_with_unix_socket(struct ddog_crasht_Config config, - ddog_CharSlice socket_path, +struct ddog_crasht_Result ddog_crasht_init_without_receiver(struct ddog_crasht_Config config, struct ddog_crasht_Metadata metadata); /** diff --git a/ext/signals.c b/ext/signals.c index 4c9e6512b7..c5d85406f0 100644 --- a/ext/signals.c +++ b/ext/signals.c @@ -120,11 +120,10 @@ static void ddtrace_init_crashtracker() { ddog_crasht_Config config = { .endpoint = agent_endpoint, - .timeout_secs = 5, + .timeout_ms = 5000, .resolve_frames = DDOG_CRASHT_STACKTRACE_COLLECTION_ENABLED_WITH_INPROCESS_SYMBOLS, - // Likely running in a container, so wait until the report is uploaded. - // Otherwise, the container shutdown may stop the sidecar before it has finished uploading the crash report. - .wait_for_receiver = getpid() == 1, + .optional_unix_socket_filename = socket_path, + .additional_files = {0}, }; ddog_Vec_Tag tags = ddog_Vec_Tag_new(); @@ -151,9 +150,8 @@ static void ddtrace_init_crashtracker() { }; ddtrace_crashtracker_check_result( - ddog_crasht_init_with_unix_socket( + ddog_crasht_init_without_receiver( config, - socket_path, metadata ), "Cannot initialize CrashTracker"