Skip to content

Commit a420609

Browse files
committed
Adapt to latest libdatadog
1 parent 4766cfb commit a420609

File tree

4 files changed

+25
-20
lines changed

4 files changed

+25
-20
lines changed

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components-rs/common.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -959,14 +959,23 @@ typedef struct ddog_crasht_Slice_CharSlice {
959959
typedef struct ddog_crasht_Config {
960960
struct ddog_crasht_Slice_CharSlice additional_files;
961961
bool create_alt_stack;
962+
bool use_alt_stack;
962963
/**
963964
* The endpoint to send the crash report to (can be a file://).
964965
* If None, the crashtracker will infer the agent host from env variables.
965966
*/
966967
const struct ddog_Endpoint *endpoint;
967968
enum ddog_crasht_StacktraceCollection resolve_frames;
968-
uint64_t timeout_secs;
969-
bool wait_for_receiver;
969+
/**
970+
* Timeout in milliseconds before the signal handler starts tearing things down to return.
971+
* This is given as a uint32_t, but the actual timeout needs to fit inside of an i32 (max
972+
* 2^31-1). This is a limitation of the various interfaces used to guarantee the timeout.
973+
*/
974+
uint32_t timeout_ms;
975+
/**
976+
* Optional filename for a unix domain socket if the receiver is used asynchonously
977+
*/
978+
ddog_CharSlice optional_unix_socket_filename;
970979
} ddog_crasht_Config;
971980

972981
typedef struct ddog_crasht_EnvVar {

components-rs/crashtracker.h

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ DDOG_CHECK_RETURN struct ddog_crasht_Result ddog_crasht_shutdown(void);
3939
* Reinitialize the crash-tracking infrastructure after a fork.
4040
* This should be one of the first things done after a fork, to minimize the
4141
* chance that a crash occurs between the fork, and this call.
42-
* In particular, reset the counters that track the profiler state machine,
43-
* and start a new receiver to collect data from this fork.
42+
* In particular, reset the counters that track the profiler state machine.
4443
* NOTE: An alternative design would be to have a 1:many sidecar listening on a
4544
* socket instead of 1:1 receiver listening on a pipe, but the only real
4645
* 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
7372
* unexpected crash-handling behaviour.
7473
*/
7574
DDOG_CHECK_RETURN
76-
struct ddog_crasht_Result ddog_crasht_init_with_receiver(struct ddog_crasht_Config config,
77-
struct ddog_crasht_ReceiverConfig receiver_config,
78-
struct ddog_crasht_Metadata metadata);
75+
struct ddog_crasht_Result ddog_crasht_init(struct ddog_crasht_Config config,
76+
struct ddog_crasht_ReceiverConfig receiver_config,
77+
struct ddog_crasht_Metadata metadata);
7978

8079
/**
81-
* Initialize the crash-tracking infrastructure, writing to an unix socket in case of crash.
80+
* Initialize the crash-tracking infrastructure without launching the receiver.
8281
*
8382
* # Preconditions
84-
* None.
83+
* Requires `config` to be given with a `unix_socket_path`, which is normally optional.
8584
* # Safety
8685
* Crash-tracking functions are not reentrant.
8786
* 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
9089
* unexpected crash-handling behaviour.
9190
*/
9291
DDOG_CHECK_RETURN
93-
struct ddog_crasht_Result ddog_crasht_init_with_unix_socket(struct ddog_crasht_Config config,
94-
ddog_CharSlice socket_path,
92+
struct ddog_crasht_Result ddog_crasht_init_without_receiver(struct ddog_crasht_Config config,
9593
struct ddog_crasht_Metadata metadata);
9694

9795
/**

ext/signals.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,10 @@ static void ddtrace_init_crashtracker() {
120120

121121
ddog_crasht_Config config = {
122122
.endpoint = agent_endpoint,
123-
.timeout_secs = 5,
123+
.timeout_ms = 5000,
124124
.resolve_frames = DDOG_CRASHT_STACKTRACE_COLLECTION_ENABLED_WITH_INPROCESS_SYMBOLS,
125-
// Likely running in a container, so wait until the report is uploaded.
126-
// Otherwise, the container shutdown may stop the sidecar before it has finished uploading the crash report.
127-
.wait_for_receiver = getpid() == 1,
125+
.optional_unix_socket_filename = socket_path,
126+
.additional_files = {0},
128127
};
129128

130129
ddog_Vec_Tag tags = ddog_Vec_Tag_new();
@@ -151,9 +150,8 @@ static void ddtrace_init_crashtracker() {
151150
};
152151

153152
ddtrace_crashtracker_check_result(
154-
ddog_crasht_init_with_unix_socket(
153+
ddog_crasht_init_without_receiver(
155154
config,
156-
socket_path,
157155
metadata
158156
),
159157
"Cannot initialize CrashTracker"

0 commit comments

Comments
 (0)