libdatadog 7.0.0.1.0-x86_64-linux → 10.0.0.1.0-x86_64-linux

Sign up to get free protection for your applications and to get access to all the features.
Files changed (27) hide show
  1. checksums.yaml +4 -4
  2. data/lib/libdatadog/version.rb +1 -1
  3. data/lib/libdatadog.rb +8 -0
  4. data/vendor/{libdatadog-7.0.0 → libdatadog-10.0.0}/x86_64-linux/libdatadog-x86_64-unknown-linux-gnu/LICENSE-3rdparty.yml +3187 -495
  5. data/vendor/{libdatadog-7.0.0 → libdatadog-10.0.0}/x86_64-linux/libdatadog-x86_64-unknown-linux-gnu/bin/libdatadog-crashtracking-receiver +0 -0
  6. data/vendor/{libdatadog-7.0.0 → libdatadog-10.0.0}/x86_64-linux/libdatadog-x86_64-unknown-linux-gnu/include/datadog/common.h +261 -45
  7. data/vendor/{libdatadog-7.0.0/x86_64-linux-musl/libdatadog-x86_64-alpine-linux-musl → libdatadog-10.0.0/x86_64-linux/libdatadog-x86_64-unknown-linux-gnu}/include/datadog/profiling.h +245 -8
  8. data/vendor/libdatadog-10.0.0/x86_64-linux/libdatadog-x86_64-unknown-linux-gnu/include/datadog/telemetry.h +288 -0
  9. data/vendor/libdatadog-10.0.0/x86_64-linux/libdatadog-x86_64-unknown-linux-gnu/lib/libdatadog_profiling.so +0 -0
  10. data/vendor/{libdatadog-7.0.0 → libdatadog-10.0.0}/x86_64-linux-musl/libdatadog-x86_64-alpine-linux-musl/LICENSE-3rdparty.yml +3187 -495
  11. data/vendor/{libdatadog-7.0.0 → libdatadog-10.0.0}/x86_64-linux-musl/libdatadog-x86_64-alpine-linux-musl/bin/libdatadog-crashtracking-receiver +0 -0
  12. data/vendor/{libdatadog-7.0.0 → libdatadog-10.0.0}/x86_64-linux-musl/libdatadog-x86_64-alpine-linux-musl/include/datadog/common.h +261 -45
  13. data/vendor/{libdatadog-7.0.0/x86_64-linux/libdatadog-x86_64-unknown-linux-gnu → libdatadog-10.0.0/x86_64-linux-musl/libdatadog-x86_64-alpine-linux-musl}/include/datadog/profiling.h +245 -8
  14. data/vendor/libdatadog-10.0.0/x86_64-linux-musl/libdatadog-x86_64-alpine-linux-musl/include/datadog/telemetry.h +288 -0
  15. data/vendor/{libdatadog-7.0.0 → libdatadog-10.0.0}/x86_64-linux-musl/libdatadog-x86_64-alpine-linux-musl/lib/libdatadog_profiling.so +0 -0
  16. metadata +22 -22
  17. data/vendor/libdatadog-7.0.0/x86_64-linux/libdatadog-x86_64-unknown-linux-gnu/include/datadog/telemetry.h +0 -290
  18. data/vendor/libdatadog-7.0.0/x86_64-linux/libdatadog-x86_64-unknown-linux-gnu/lib/libdatadog_profiling.so +0 -0
  19. data/vendor/libdatadog-7.0.0/x86_64-linux-musl/libdatadog-x86_64-alpine-linux-musl/include/datadog/telemetry.h +0 -290
  20. /data/vendor/{libdatadog-7.0.0 → libdatadog-10.0.0}/x86_64-linux/libdatadog-x86_64-unknown-linux-gnu/LICENSE +0 -0
  21. /data/vendor/{libdatadog-7.0.0 → libdatadog-10.0.0}/x86_64-linux/libdatadog-x86_64-unknown-linux-gnu/NOTICE +0 -0
  22. /data/vendor/{libdatadog-7.0.0 → libdatadog-10.0.0}/x86_64-linux/libdatadog-x86_64-unknown-linux-gnu/include/datadog/blazesym.h +0 -0
  23. /data/vendor/{libdatadog-7.0.0 → libdatadog-10.0.0}/x86_64-linux/libdatadog-x86_64-unknown-linux-gnu/lib/pkgconfig/datadog_profiling_with_rpath.pc +0 -0
  24. /data/vendor/{libdatadog-7.0.0 → libdatadog-10.0.0}/x86_64-linux-musl/libdatadog-x86_64-alpine-linux-musl/LICENSE +0 -0
  25. /data/vendor/{libdatadog-7.0.0 → libdatadog-10.0.0}/x86_64-linux-musl/libdatadog-x86_64-alpine-linux-musl/NOTICE +0 -0
  26. /data/vendor/{libdatadog-7.0.0 → libdatadog-10.0.0}/x86_64-linux-musl/libdatadog-x86_64-alpine-linux-musl/include/datadog/blazesym.h +0 -0
  27. /data/vendor/{libdatadog-7.0.0 → libdatadog-10.0.0}/x86_64-linux-musl/libdatadog-x86_64-alpine-linux-musl/lib/pkgconfig/datadog_profiling_with_rpath.pc +0 -0
@@ -83,6 +83,32 @@ typedef struct ddog_Slice_CChar {
83
83
  */
84
84
  typedef struct ddog_Slice_CChar ddog_CharSlice;
85
85
 
86
+ typedef enum ddog_Option_Error_Tag {
87
+ DDOG_OPTION_ERROR_SOME_ERROR,
88
+ DDOG_OPTION_ERROR_NONE_ERROR,
89
+ } ddog_Option_Error_Tag;
90
+
91
+ typedef struct ddog_Option_Error {
92
+ ddog_Option_Error_Tag tag;
93
+ union {
94
+ struct {
95
+ struct ddog_Error some;
96
+ };
97
+ };
98
+ } ddog_Option_Error;
99
+
100
+ typedef struct ddog_Option_Error ddog_MaybeError;
101
+
102
+ /**
103
+ * A wrapper for returning owned strings from FFI
104
+ */
105
+ typedef struct ddog_StringWrapper {
106
+ /**
107
+ * This is a String stuffed into the vec.
108
+ */
109
+ struct ddog_Vec_U8 message;
110
+ } ddog_StringWrapper;
111
+
86
112
  /**
87
113
  * Holds the raw parts of a Rust Vec; it should only be created from Rust,
88
114
  * never from C.
@@ -112,14 +138,10 @@ typedef struct ddog_Vec_Tag_ParseResult {
112
138
  struct ddog_Error *error_message;
113
139
  } ddog_Vec_Tag_ParseResult;
114
140
 
115
- typedef enum ddog_prof_CrashtrackerResolveFrames {
116
- DDOG_PROF_CRASHTRACKER_RESOLVE_FRAMES_NEVER,
117
- /**
118
- * Resolving frames in process is experimental, and can fail/crash
119
- */
120
- DDOG_PROF_CRASHTRACKER_RESOLVE_FRAMES_EXPERIMENTAL_IN_PROCESS,
121
- DDOG_PROF_CRASHTRACKER_RESOLVE_FRAMES_IN_RECEIVER,
122
- } ddog_prof_CrashtrackerResolveFrames;
141
+ typedef enum ddog_prof_DemangleOptions {
142
+ DDOG_PROF_DEMANGLE_OPTIONS_COMPLETE,
143
+ DDOG_PROF_DEMANGLE_OPTIONS_NAME_ONLY,
144
+ } ddog_prof_DemangleOptions;
123
145
 
124
146
  /**
125
147
  * This enum represents operations a profiler might be engaged in.
@@ -143,6 +165,23 @@ typedef enum ddog_prof_ProfilingOpTypes {
143
165
  DDOG_PROF_PROFILING_OP_TYPES_SIZE,
144
166
  } ddog_prof_ProfilingOpTypes;
145
167
 
168
+ /**
169
+ * Stacktrace collection occurs in the context of a crashing process.
170
+ * If the stack is sufficiently corruputed, it is possible (but unlikely),
171
+ * for stack trace collection itself to crash.
172
+ * We recommend fully enabling stacktrace collection, but having an environment
173
+ * variable to allow downgrading the collector.
174
+ */
175
+ typedef enum ddog_prof_StacktraceCollection {
176
+ /**
177
+ * Stacktrace collection occurs in the
178
+ */
179
+ DDOG_PROF_STACKTRACE_COLLECTION_DISABLED,
180
+ DDOG_PROF_STACKTRACE_COLLECTION_WITHOUT_SYMBOLS,
181
+ DDOG_PROF_STACKTRACE_COLLECTION_ENABLED_WITH_INPROCESS_SYMBOLS,
182
+ DDOG_PROF_STACKTRACE_COLLECTION_ENABLED_WITH_SYMBOLS_IN_RECEIVER,
183
+ } ddog_prof_StacktraceCollection;
184
+
146
185
  typedef struct ddog_CancellationToken ddog_CancellationToken;
147
186
 
148
187
  typedef struct ddog_prof_Exporter ddog_prof_Exporter;
@@ -152,16 +191,16 @@ typedef struct ddog_prof_ProfiledEndpointsStats ddog_prof_ProfiledEndpointsStats
152
191
  typedef struct ddog_prof_Exporter_Request ddog_prof_Exporter_Request;
153
192
 
154
193
  /**
155
- * A generic result type for when a profiling operation may fail, but there's
156
- * nothing to return in the case of success.
194
+ * A generic result type for when a crashtracking operation may fail,
195
+ * but there's nothing to return in the case of success.
157
196
  */
158
- typedef enum ddog_prof_Profile_Result_Tag {
159
- DDOG_PROF_PROFILE_RESULT_OK,
160
- DDOG_PROF_PROFILE_RESULT_ERR,
161
- } ddog_prof_Profile_Result_Tag;
197
+ typedef enum ddog_prof_CrashtrackerResult_Tag {
198
+ DDOG_PROF_CRASHTRACKER_RESULT_OK,
199
+ DDOG_PROF_CRASHTRACKER_RESULT_ERR,
200
+ } ddog_prof_CrashtrackerResult_Tag;
162
201
 
163
- typedef struct ddog_prof_Profile_Result {
164
- ddog_prof_Profile_Result_Tag tag;
202
+ typedef struct ddog_prof_CrashtrackerResult {
203
+ ddog_prof_CrashtrackerResult_Tag tag;
165
204
  union {
166
205
  struct {
167
206
  /**
@@ -174,11 +213,24 @@ typedef struct ddog_prof_Profile_Result {
174
213
  struct ddog_Error err;
175
214
  };
176
215
  };
177
- } ddog_prof_Profile_Result;
216
+ } ddog_prof_CrashtrackerResult;
217
+
218
+ typedef struct ddog_prof_Slice_CharSlice {
219
+ /**
220
+ * Must be non-null and suitably aligned for the underlying type.
221
+ */
222
+ const ddog_CharSlice *ptr;
223
+ /**
224
+ * The number of elements (not bytes) that `.ptr` points to. Must be less
225
+ * than or equal to [isize::MAX].
226
+ */
227
+ uintptr_t len;
228
+ } ddog_prof_Slice_CharSlice;
178
229
 
179
230
  typedef enum ddog_prof_Endpoint_Tag {
180
231
  DDOG_PROF_ENDPOINT_AGENT,
181
232
  DDOG_PROF_ENDPOINT_AGENTLESS,
233
+ DDOG_PROF_ENDPOINT_FILE,
182
234
  } ddog_prof_Endpoint_Tag;
183
235
 
184
236
  typedef struct ddog_prof_Endpoint_ddog_prof_Agentless_Body {
@@ -193,19 +245,47 @@ typedef struct ddog_prof_Endpoint {
193
245
  ddog_CharSlice agent;
194
246
  };
195
247
  ddog_prof_Endpoint_ddog_prof_Agentless_Body AGENTLESS;
248
+ struct {
249
+ ddog_CharSlice file;
250
+ };
196
251
  };
197
252
  } ddog_prof_Endpoint;
198
253
 
199
254
  typedef struct ddog_prof_CrashtrackerConfiguration {
200
- /**
201
- * Should the crashtracker attempt to collect a stacktrace for the crash
202
- */
203
- bool collect_stacktrace;
255
+ struct ddog_prof_Slice_CharSlice additional_files;
204
256
  bool create_alt_stack;
205
257
  /**
206
- * The endpoint to send the crash repor to (can be a file://)
258
+ * The endpoint to send the crash report to (can be a file://)
259
+ *
260
+ * If ProfilingEndpoint is left to a zero value (enum value for Agent + empty charslice),
261
+ * the crashtracker will infer the agent host from env variables.
207
262
  */
208
263
  struct ddog_prof_Endpoint endpoint;
264
+ enum ddog_prof_StacktraceCollection resolve_frames;
265
+ uint64_t timeout_secs;
266
+ } ddog_prof_CrashtrackerConfiguration;
267
+
268
+ typedef struct ddog_prof_EnvVar {
269
+ ddog_CharSlice key;
270
+ ddog_CharSlice val;
271
+ } ddog_prof_EnvVar;
272
+
273
+ typedef struct ddog_prof_Slice_EnvVar {
274
+ /**
275
+ * Must be non-null and suitably aligned for the underlying type.
276
+ */
277
+ const struct ddog_prof_EnvVar *ptr;
278
+ /**
279
+ * The number of elements (not bytes) that `.ptr` points to. Must be less
280
+ * than or equal to [isize::MAX].
281
+ */
282
+ uintptr_t len;
283
+ } ddog_prof_Slice_EnvVar;
284
+
285
+ typedef struct ddog_prof_CrashtrackerReceiverConfig {
286
+ struct ddog_prof_Slice_CharSlice args;
287
+ struct ddog_prof_Slice_EnvVar env;
288
+ ddog_CharSlice path_to_receiver_binary;
209
289
  /**
210
290
  * Optional filename to forward stderr to (useful for logging/debugging)
211
291
  */
@@ -214,12 +294,7 @@ typedef struct ddog_prof_CrashtrackerConfiguration {
214
294
  * Optional filename to forward stdout to (useful for logging/debugging)
215
295
  */
216
296
  ddog_CharSlice optional_stdout_filename;
217
- ddog_CharSlice path_to_receiver_binary;
218
- /**
219
- * Whether/when we should attempt to resolve frames
220
- */
221
- enum ddog_prof_CrashtrackerResolveFrames resolve_frames;
222
- } ddog_prof_CrashtrackerConfiguration;
297
+ } ddog_prof_CrashtrackerReceiverConfig;
223
298
 
224
299
  typedef struct ddog_prof_CrashtrackerMetadata {
225
300
  ddog_CharSlice profiling_library_name;
@@ -231,6 +306,122 @@ typedef struct ddog_prof_CrashtrackerMetadata {
231
306
  const struct ddog_Vec_Tag *tags;
232
307
  } ddog_prof_CrashtrackerMetadata;
233
308
 
309
+ /**
310
+ * Represents a CrashInfo. Do not access its member for any reason, only use
311
+ * the C API functions on this struct.
312
+ */
313
+ typedef struct ddog_prof_CrashInfo {
314
+ struct ddog_prof_CrashInfo *inner;
315
+ } ddog_prof_CrashInfo;
316
+
317
+ /**
318
+ * Returned by [ddog_prof_Profile_new].
319
+ */
320
+ typedef enum ddog_prof_CrashInfoNewResult_Tag {
321
+ DDOG_PROF_CRASH_INFO_NEW_RESULT_OK,
322
+ DDOG_PROF_CRASH_INFO_NEW_RESULT_ERR,
323
+ } ddog_prof_CrashInfoNewResult_Tag;
324
+
325
+ typedef struct ddog_prof_CrashInfoNewResult {
326
+ ddog_prof_CrashInfoNewResult_Tag tag;
327
+ union {
328
+ struct {
329
+ struct ddog_prof_CrashInfo ok;
330
+ };
331
+ struct {
332
+ struct ddog_Error err;
333
+ };
334
+ };
335
+ } ddog_prof_CrashInfoNewResult;
336
+
337
+ typedef struct ddog_prof_SigInfo {
338
+ uint64_t signum;
339
+ ddog_CharSlice signame;
340
+ } ddog_prof_SigInfo;
341
+
342
+ typedef enum ddog_prof_Option_U32_Tag {
343
+ DDOG_PROF_OPTION_U32_SOME_U32,
344
+ DDOG_PROF_OPTION_U32_NONE_U32,
345
+ } ddog_prof_Option_U32_Tag;
346
+
347
+ typedef struct ddog_prof_Option_U32 {
348
+ ddog_prof_Option_U32_Tag tag;
349
+ union {
350
+ struct {
351
+ uint32_t some;
352
+ };
353
+ };
354
+ } ddog_prof_Option_U32;
355
+
356
+ typedef struct ddog_prof_StackFrameNames {
357
+ struct ddog_prof_Option_U32 colno;
358
+ ddog_CharSlice filename;
359
+ struct ddog_prof_Option_U32 lineno;
360
+ ddog_CharSlice name;
361
+ } ddog_prof_StackFrameNames;
362
+
363
+ typedef struct ddog_prof_Slice_StackFrameNames {
364
+ /**
365
+ * Must be non-null and suitably aligned for the underlying type.
366
+ */
367
+ const struct ddog_prof_StackFrameNames *ptr;
368
+ /**
369
+ * The number of elements (not bytes) that `.ptr` points to. Must be less
370
+ * than or equal to [isize::MAX].
371
+ */
372
+ uintptr_t len;
373
+ } ddog_prof_Slice_StackFrameNames;
374
+
375
+ typedef struct ddog_prof_StackFrame {
376
+ uintptr_t ip;
377
+ uintptr_t module_base_address;
378
+ struct ddog_prof_Slice_StackFrameNames names;
379
+ uintptr_t sp;
380
+ uintptr_t symbol_address;
381
+ } ddog_prof_StackFrame;
382
+
383
+ typedef struct ddog_prof_Slice_StackFrame {
384
+ /**
385
+ * Must be non-null and suitably aligned for the underlying type.
386
+ */
387
+ const struct ddog_prof_StackFrame *ptr;
388
+ /**
389
+ * The number of elements (not bytes) that `.ptr` points to. Must be less
390
+ * than or equal to [isize::MAX].
391
+ */
392
+ uintptr_t len;
393
+ } ddog_prof_Slice_StackFrame;
394
+
395
+ /**
396
+ * A wrapper for returning owned strings from FFI
397
+ */
398
+ typedef struct ddog_prof_StringWrapper {
399
+ /**
400
+ * This is a String stuffed into the vec.
401
+ */
402
+ struct ddog_Vec_U8 message;
403
+ } ddog_prof_StringWrapper;
404
+
405
+ /**
406
+ * Returned by [ddog_prof_Profile_new].
407
+ */
408
+ typedef enum ddog_prof_StringWrapperResult_Tag {
409
+ DDOG_PROF_STRING_WRAPPER_RESULT_OK,
410
+ DDOG_PROF_STRING_WRAPPER_RESULT_ERR,
411
+ } ddog_prof_StringWrapperResult_Tag;
412
+
413
+ typedef struct ddog_prof_StringWrapperResult {
414
+ ddog_prof_StringWrapperResult_Tag tag;
415
+ union {
416
+ struct {
417
+ struct ddog_prof_StringWrapper ok;
418
+ };
419
+ struct {
420
+ struct ddog_Error err;
421
+ };
422
+ };
423
+ } ddog_prof_StringWrapperResult;
424
+
234
425
  typedef struct ddog_Slice_U8 {
235
426
  /**
236
427
  * Must be non-null and suitably aligned for the underlying type.
@@ -378,6 +569,31 @@ typedef struct ddog_prof_Period {
378
569
  int64_t value;
379
570
  } ddog_prof_Period;
380
571
 
572
+ /**
573
+ * A generic result type for when a profiling operation may fail, but there's
574
+ * nothing to return in the case of success.
575
+ */
576
+ typedef enum ddog_prof_Profile_Result_Tag {
577
+ DDOG_PROF_PROFILE_RESULT_OK,
578
+ DDOG_PROF_PROFILE_RESULT_ERR,
579
+ } ddog_prof_Profile_Result_Tag;
580
+
581
+ typedef struct ddog_prof_Profile_Result {
582
+ ddog_prof_Profile_Result_Tag tag;
583
+ union {
584
+ struct {
585
+ /**
586
+ * Do not use the value of Ok. This value only exists to overcome
587
+ * Rust -> C code generation.
588
+ */
589
+ bool ok;
590
+ };
591
+ struct {
592
+ struct ddog_Error err;
593
+ };
594
+ };
595
+ } ddog_prof_Profile_Result;
596
+
381
597
  typedef struct ddog_prof_Mapping {
382
598
  /**
383
599
  * Address at which the binary (or DLL) is loaded into memory.
@@ -618,27 +834,11 @@ typedef struct ddog_TelemetryWorkerBuilder ddog_TelemetryWorkerBuilder;
618
834
  *
619
835
  * The worker won't send data to the agent until you call `TelemetryWorkerHandle::send_start`
620
836
  *
621
- * To stop the worker, call `TelemetryWorkerHandle::send_stop` which trigger flush aynchronously
837
+ * To stop the worker, call `TelemetryWorkerHandle::send_stop` which trigger flush asynchronously
622
838
  * then `TelemetryWorkerHandle::wait_for_shutdown`
623
839
  */
624
840
  typedef struct ddog_TelemetryWorkerHandle ddog_TelemetryWorkerHandle;
625
841
 
626
- typedef enum ddog_Option_VecU8_Tag {
627
- DDOG_OPTION_VEC_U8_SOME_VEC_U8,
628
- DDOG_OPTION_VEC_U8_NONE_VEC_U8,
629
- } ddog_Option_VecU8_Tag;
630
-
631
- typedef struct ddog_Option_VecU8 {
632
- ddog_Option_VecU8_Tag tag;
633
- union {
634
- struct {
635
- struct ddog_Vec_U8 some;
636
- };
637
- };
638
- } ddog_Option_VecU8;
639
-
640
- typedef struct ddog_Option_VecU8 ddog_MaybeError;
641
-
642
842
  typedef enum ddog_Option_Bool_Tag {
643
843
  DDOG_OPTION_BOOL_SOME_BOOL,
644
844
  DDOG_OPTION_BOOL_NONE_BOOL,
@@ -676,6 +876,8 @@ void ddog_Error_drop(struct ddog_Error *error);
676
876
  */
677
877
  ddog_CharSlice ddog_Error_message(const struct ddog_Error *error);
678
878
 
879
+ void ddog_MaybeError_drop(ddog_MaybeError);
880
+
679
881
  DDOG_CHECK_RETURN struct ddog_Endpoint *ddog_endpoint_from_url(ddog_CharSlice url);
680
882
 
681
883
  DDOG_CHECK_RETURN struct ddog_Endpoint *ddog_endpoint_from_api_key(ddog_CharSlice api_key);
@@ -687,6 +889,20 @@ struct ddog_Error *ddog_endpoint_from_api_key_and_site(ddog_CharSlice api_key,
687
889
 
688
890
  void ddog_endpoint_drop(struct ddog_Endpoint*);
689
891
 
892
+ /**
893
+ * # Safety
894
+ * Only pass null or a valid reference to a `ddog_StringWrapper`.
895
+ */
896
+ void ddog_StringWrapper_drop(struct ddog_StringWrapper *s);
897
+
898
+ /**
899
+ * Returns a CharSlice of the message that is valid until the StringWrapper
900
+ * is dropped.
901
+ * # Safety
902
+ * Only pass null or a valid reference to a `ddog_StringWrapper`.
903
+ */
904
+ ddog_CharSlice ddog_StringWrapper_message(const struct ddog_StringWrapper *s);
905
+
690
906
  DDOG_CHECK_RETURN struct ddog_Vec_Tag ddog_Vec_Tag_new(void);
691
907
 
692
908
  void ddog_Vec_Tag_drop(struct ddog_Vec_Tag);
@@ -16,23 +16,251 @@
16
16
  extern "C" {
17
17
  #endif // __cplusplus
18
18
 
19
+ /**
20
+ * Cleans up after the crash-tracker:
21
+ * Unregister the crash handler, restore the previous handler (if any), and
22
+ * shut down the receiver. Note that the use of this function is optional:
23
+ * the receiver will automatically shutdown when the pipe is closed on program
24
+ * exit.
25
+ *
26
+ * # Preconditions
27
+ * This function assumes that the crash-tracker has previously been
28
+ * initialized.
29
+ * # Safety
30
+ * Crash-tracking functions are not reentrant.
31
+ * No other crash-handler functions should be called concurrently.
32
+ * # Atomicity
33
+ * This function is not atomic. A crash during its execution may lead to
34
+ * unexpected crash-handling behaviour.
35
+ */
36
+ DDOG_CHECK_RETURN struct ddog_prof_CrashtrackerResult ddog_prof_Crashtracker_shutdown(void);
37
+
38
+ /**
39
+ * Reinitialize the crash-tracking infrastructure after a fork.
40
+ * This should be one of the first things done after a fork, to minimize the
41
+ * 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.
44
+ * NOTE: An alternative design would be to have a 1:many sidecar listening on a
45
+ * socket instead of 1:1 receiver listening on a pipe, but the only real
46
+ * advantage would be to have fewer processes in `ps -a`.
47
+ *
48
+ * # Preconditions
49
+ * This function assumes that the crash-tracker has previously been
50
+ * initialized.
51
+ * # Safety
52
+ * Crash-tracking functions are not reentrant.
53
+ * No other crash-handler functions should be called concurrently.
54
+ * # Atomicity
55
+ * This function is not atomic. A crash during its execution may lead to
56
+ * unexpected crash-handling behaviour.
57
+ */
58
+ DDOG_CHECK_RETURN
59
+ struct ddog_prof_CrashtrackerResult ddog_prof_Crashtracker_update_on_fork(struct ddog_prof_CrashtrackerConfiguration config,
60
+ struct ddog_prof_CrashtrackerReceiverConfig receiver_config,
61
+ struct ddog_prof_CrashtrackerMetadata metadata);
62
+
63
+ /**
64
+ * Receives data from a crash collector via a pipe on `stdin`, formats it into
65
+ * `CrashInfo` json, and emits it to the endpoint/file defined in `config`.
66
+ *
67
+ * At a high-level, this exists because doing anything in a
68
+ * signal handler is dangerous, so we fork a sidecar to do the stuff we aren't
69
+ * allowed to do in the handler.
70
+ *
71
+ * See comments in [profiling/crashtracker/mod.rs] for a full architecture
72
+ * description.
73
+ * # Safety
74
+ * No safety concerns
75
+ */
76
+ DDOG_CHECK_RETURN
77
+ struct ddog_prof_CrashtrackerResult ddog_prof_Crashtracker_receiver_entry_point(void);
78
+
79
+ /**
80
+ * Initialize the crash-tracking infrastructure.
81
+ *
82
+ * # Preconditions
83
+ * None.
84
+ * # Safety
85
+ * Crash-tracking functions are not reentrant.
86
+ * No other crash-handler functions should be called concurrently.
87
+ * # Atomicity
88
+ * This function is not atomic. A crash during its execution may lead to
89
+ * unexpected crash-handling behaviour.
90
+ */
91
+ DDOG_CHECK_RETURN
92
+ struct ddog_prof_CrashtrackerResult ddog_prof_Crashtracker_init(struct ddog_prof_CrashtrackerConfiguration config,
93
+ struct ddog_prof_CrashtrackerReceiverConfig receiver_config,
94
+ struct ddog_prof_CrashtrackerMetadata metadata);
95
+
96
+ /**
97
+ * Resets all counters to 0.
98
+ * Expected to be used after a fork, to reset the counters on the child
99
+ * ATOMICITY:
100
+ * This is NOT ATOMIC.
101
+ * Should only be used when no conflicting updates can occur,
102
+ * e.g. after a fork but before profiling ops start on the child.
103
+ * # Safety
104
+ * No safety concerns.
105
+ */
106
+ DDOG_CHECK_RETURN struct ddog_prof_CrashtrackerResult ddog_prof_Crashtracker_reset_counters(void);
107
+
108
+ /**
109
+ * Atomically increments the count associated with `op`.
110
+ * Useful for tracking what operations were occuring when a crash occurred.
111
+ *
112
+ * # Safety
113
+ * No safety concerns.
114
+ */
115
+ DDOG_CHECK_RETURN
116
+ struct ddog_prof_CrashtrackerResult ddog_prof_Crashtracker_begin_profiling_op(enum ddog_prof_ProfilingOpTypes op);
117
+
118
+ /**
119
+ * Atomically decrements the count associated with `op`.
120
+ * Useful for tracking what operations were occuring when a crash occurred.
121
+ *
122
+ * # Safety
123
+ * No safety concerns.
124
+ */
125
+ DDOG_CHECK_RETURN
126
+ struct ddog_prof_CrashtrackerResult ddog_prof_Crashtracker_end_profiling_op(enum ddog_prof_ProfilingOpTypes op);
127
+
128
+ /**
129
+ * Create a new crashinfo, and returns an opaque reference to it.
130
+ * # Safety
131
+ * No safety issues.
132
+ */
133
+ DDOG_CHECK_RETURN struct ddog_prof_CrashInfoNewResult ddog_crashinfo_new(void);
134
+
135
+ /**
136
+ * # Safety
137
+ * The `crash_info` can be null, but if non-null it must point to a CrashInfo
138
+ * made by this module, which has not previously been dropped.
139
+ */
140
+ void ddog_crashinfo_drop(struct ddog_prof_CrashInfo *crashinfo);
141
+
142
+ /**
143
+ * Adds a "counter" variable, with the given value. Useful for determining if
144
+ * "interesting" operations were occurring when the crash did.
145
+ *
146
+ * # Safety
147
+ * `crashinfo` must be a valid pointer to a `CrashInfo` object.
148
+ * `name` should be a valid reference to a utf8 encoded String.
149
+ * The string is copied into the crashinfo, so it does not need to outlive this
150
+ * call.
151
+ */
19
152
  DDOG_CHECK_RETURN
20
- struct ddog_prof_Profile_Result ddog_prof_Crashtracker_begin_profiling_op(enum ddog_prof_ProfilingOpTypes op);
153
+ struct ddog_prof_CrashtrackerResult ddog_crashinfo_add_counter(struct ddog_prof_CrashInfo *crashinfo,
154
+ ddog_CharSlice name,
155
+ int64_t val);
21
156
 
157
+ /**
158
+ * Adds the contents of "file" to the crashinfo
159
+ *
160
+ * # Safety
161
+ * `crashinfo` must be a valid pointer to a `CrashInfo` object.
162
+ * `name` should be a valid reference to a utf8 encoded String.
163
+ * The string is copied into the crashinfo, so it does not need to outlive this
164
+ * call.
165
+ */
22
166
  DDOG_CHECK_RETURN
23
- struct ddog_prof_Profile_Result ddog_prof_Crashtracker_end_profiling_op(enum ddog_prof_ProfilingOpTypes op);
167
+ struct ddog_prof_CrashtrackerResult ddog_crashinfo_add_file(struct ddog_prof_CrashInfo *crashinfo,
168
+ ddog_CharSlice name);
24
169
 
25
- DDOG_CHECK_RETURN struct ddog_prof_Profile_Result ddog_prof_Crashtracker_shutdown(void);
170
+ /**
171
+ * Adds the tag with given "key" and "value" to the crashinfo
172
+ *
173
+ * # Safety
174
+ * `crashinfo` must be a valid pointer to a `CrashInfo` object.
175
+ * `key` should be a valid reference to a utf8 encoded String.
176
+ * `value` should be a valid reference to a utf8 encoded String.
177
+ * The string is copied into the crashinfo, so it does not need to outlive this
178
+ * call.
179
+ */
180
+ DDOG_CHECK_RETURN
181
+ struct ddog_prof_CrashtrackerResult ddog_crashinfo_add_tag(struct ddog_prof_CrashInfo *crashinfo,
182
+ ddog_CharSlice key,
183
+ ddog_CharSlice value);
26
184
 
185
+ /**
186
+ * Sets the crashinfo metadata
187
+ *
188
+ * # Safety
189
+ * `crashinfo` must be a valid pointer to a `CrashInfo` object.
190
+ * All references inside `metadata` must be valid.
191
+ * Strings are copied into the crashinfo, and do not need to outlive this call.
192
+ */
27
193
  DDOG_CHECK_RETURN
28
- struct ddog_prof_Profile_Result ddog_prof_Crashtracker_update_on_fork(struct ddog_prof_CrashtrackerConfiguration config,
29
- struct ddog_prof_CrashtrackerMetadata metadata);
194
+ struct ddog_prof_CrashtrackerResult ddog_crashinfo_set_metadata(struct ddog_prof_CrashInfo *crashinfo,
195
+ struct ddog_prof_CrashtrackerMetadata metadata);
30
196
 
31
- DDOG_CHECK_RETURN struct ddog_prof_Profile_Result ddog_prof_Crashtracker_receiver_entry_point(void);
197
+ /**
198
+ * Sets the crashinfo siginfo
199
+ *
200
+ * # Safety
201
+ * `crashinfo` must be a valid pointer to a `CrashInfo` object.
202
+ * All references inside `metadata` must be valid.
203
+ * Strings are copied into the crashinfo, and do not need to outlive this call.
204
+ */
205
+ DDOG_CHECK_RETURN
206
+ struct ddog_prof_CrashtrackerResult ddog_crashinfo_set_siginfo(struct ddog_prof_CrashInfo *crashinfo,
207
+ struct ddog_prof_SigInfo siginfo);
32
208
 
209
+ /**
210
+ * If `thread_id` is empty, sets `stacktrace` as the default stacktrace.
211
+ * Otherwise, adds an additional stacktrace with id "thread_id".
212
+ *
213
+ * # Safety
214
+ * `crashinfo` must be a valid pointer to a `CrashInfo` object.
215
+ * All references inside `stacktraces` must be valid.
216
+ * Strings are copied into the crashinfo, and do not need to outlive this call.
217
+ */
33
218
  DDOG_CHECK_RETURN
34
- struct ddog_prof_Profile_Result ddog_prof_Crashtracker_init(struct ddog_prof_CrashtrackerConfiguration config,
35
- struct ddog_prof_CrashtrackerMetadata metadata);
219
+ struct ddog_prof_CrashtrackerResult ddog_crashinfo_set_stacktrace(struct ddog_prof_CrashInfo *crashinfo,
220
+ ddog_CharSlice thread_id,
221
+ struct ddog_prof_Slice_StackFrame stacktrace);
222
+
223
+ /**
224
+ * Sets the timestamp to the given unix timestamp
225
+ *
226
+ * # Safety
227
+ * `crashinfo` must be a valid pointer to a `CrashInfo` object.
228
+ */
229
+ DDOG_CHECK_RETURN
230
+ struct ddog_prof_CrashtrackerResult ddog_crashinfo_set_timestamp(struct ddog_prof_CrashInfo *crashinfo,
231
+ int64_t secs,
232
+ uint32_t nsecs);
233
+
234
+ /**
235
+ * Sets the timestamp to the current time
236
+ *
237
+ * # Safety
238
+ * `crashinfo` must be a valid pointer to a `CrashInfo` object.
239
+ */
240
+ DDOG_CHECK_RETURN
241
+ struct ddog_prof_CrashtrackerResult ddog_crashinfo_set_timestamp_to_now(struct ddog_prof_CrashInfo *crashinfo);
242
+
243
+ /**
244
+ * Exports `crashinfo` to the backend at `endpoint`
245
+ * Note that we support the "file://" endpoint for local file output.
246
+ * # Safety
247
+ * `crashinfo` must be a valid pointer to a `CrashInfo` object.
248
+ */
249
+ DDOG_CHECK_RETURN
250
+ struct ddog_prof_CrashtrackerResult ddog_crashinfo_upload_to_endpoint(struct ddog_prof_CrashInfo *crashinfo,
251
+ struct ddog_prof_CrashtrackerConfiguration config);
252
+
253
+ /**
254
+ * Demangles the string "name".
255
+ * If demangling fails, returns an empty string ""
256
+ *
257
+ * # Safety
258
+ * `name` should be a valid reference to a utf8 encoded String.
259
+ * The string is copied into the result, and does not need to outlive this call
260
+ */
261
+ DDOG_CHECK_RETURN
262
+ struct ddog_prof_StringWrapperResult ddog_demangle(ddog_CharSlice name,
263
+ enum ddog_prof_DemangleOptions options);
36
264
 
37
265
  DDOG_CHECK_RETURN struct ddog_prof_Exporter_Slice_File ddog_prof_Exporter_Slice_File_empty(void);
38
266
 
@@ -51,6 +279,15 @@ struct ddog_prof_Endpoint ddog_prof_Endpoint_agent(ddog_CharSlice base_url);
51
279
  */
52
280
  struct ddog_prof_Endpoint ddog_prof_Endpoint_agentless(ddog_CharSlice site, ddog_CharSlice api_key);
53
281
 
282
+ /**
283
+ * Creates an endpoint that writes to a file.
284
+ * Useful for local debugging.
285
+ * Currently only supported by the crashtracker.
286
+ * # Arguments
287
+ * * `filename` - Path to the output file "/tmp/file.txt".
288
+ */
289
+ struct ddog_prof_Endpoint ddog_Endpoint_file(ddog_CharSlice filename);
290
+
54
291
  /**
55
292
  * Creates a new exporter to be used to report profiling data.
56
293
  * # Arguments