Skip to content

Commit

Permalink
Adapt to latest libdatadog
Browse files Browse the repository at this point in the history
  • Loading branch information
bwoebi committed Nov 13, 2024
1 parent 4766cfb commit a420609
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 20 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

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

13 changes: 11 additions & 2 deletions components-rs/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
16 changes: 7 additions & 9 deletions components-rs/crashtracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down Expand Up @@ -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.
Expand All @@ -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);

/**
Expand Down
10 changes: 4 additions & 6 deletions ext/signals.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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"
Expand Down

0 comments on commit a420609

Please sign in to comment.