libddprof 0.5.0.1.0.beta1-x86_64-linux → 0.6.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 (18) hide show
  1. checksums.yaml +4 -4
  2. data/lib/libddprof/version.rb +2 -2
  3. data/lib/libddprof.rb +0 -5
  4. data/vendor/{libddprof-0.5.0 → libddprof-0.6.0}/x86_64-linux/libddprof-x86_64-unknown-linux-gnu/LICENSE +0 -0
  5. data/vendor/{libddprof-0.5.0/x86_64-linux-musl/libddprof-x86_64-alpine-linux-musl → libddprof-0.6.0/x86_64-linux/libddprof-x86_64-unknown-linux-gnu}/LICENSE-3rdparty.yml +306 -88
  6. data/vendor/{libddprof-0.5.0 → libddprof-0.6.0}/x86_64-linux/libddprof-x86_64-unknown-linux-gnu/NOTICE +0 -0
  7. data/vendor/{libddprof-0.5.0/x86_64-linux-musl/libddprof-x86_64-alpine-linux-musl → libddprof-0.6.0/x86_64-linux/libddprof-x86_64-unknown-linux-gnu}/include/ddprof/ffi.h +231 -131
  8. data/vendor/libddprof-0.6.0/x86_64-linux/libddprof-x86_64-unknown-linux-gnu/lib/libddprof_ffi.so +0 -0
  9. data/vendor/{libddprof-0.5.0 → libddprof-0.6.0}/x86_64-linux/libddprof-x86_64-unknown-linux-gnu/lib/pkgconfig/ddprof_ffi_with_rpath.pc +1 -1
  10. data/vendor/{libddprof-0.5.0 → libddprof-0.6.0}/x86_64-linux-musl/libddprof-x86_64-alpine-linux-musl/LICENSE +0 -0
  11. data/vendor/{libddprof-0.5.0/x86_64-linux/libddprof-x86_64-unknown-linux-gnu → libddprof-0.6.0/x86_64-linux-musl/libddprof-x86_64-alpine-linux-musl}/LICENSE-3rdparty.yml +306 -88
  12. data/vendor/{libddprof-0.5.0 → libddprof-0.6.0}/x86_64-linux-musl/libddprof-x86_64-alpine-linux-musl/NOTICE +0 -0
  13. data/vendor/{libddprof-0.5.0/x86_64-linux/libddprof-x86_64-unknown-linux-gnu → libddprof-0.6.0/x86_64-linux-musl/libddprof-x86_64-alpine-linux-musl}/include/ddprof/ffi.h +231 -131
  14. data/vendor/libddprof-0.6.0/x86_64-linux-musl/libddprof-x86_64-alpine-linux-musl/lib/libddprof_ffi.so +0 -0
  15. data/vendor/{libddprof-0.5.0 → libddprof-0.6.0}/x86_64-linux-musl/libddprof-x86_64-alpine-linux-musl/lib/pkgconfig/ddprof_ffi_with_rpath.pc +1 -1
  16. metadata +16 -16
  17. data/vendor/libddprof-0.5.0/x86_64-linux/libddprof-x86_64-unknown-linux-gnu/lib/libddprof_ffi.so +0 -0
  18. data/vendor/libddprof-0.5.0/x86_64-linux-musl/libddprof-x86_64-alpine-linux-musl/lib/libddprof_ffi.so +0 -0
@@ -9,7 +9,10 @@
9
9
  #include <stddef.h>
10
10
  #include <stdint.h>
11
11
 
12
- typedef struct ddprof_ffi_Exporter ddprof_ffi_Exporter;
12
+ #define DDPROF_FFI_CHARSLICE_C(string) \
13
+ /* NOTE: Compilation fails if you pass in a char* instead of a literal */ ((ddprof_ffi_CharSlice) {.ptr = "" string, .len = sizeof(string) - 1})
14
+
15
+ typedef struct ddprof_ffi_CancellationToken ddprof_ffi_CancellationToken;
13
16
 
14
17
  typedef struct ddprof_ffi_Profile ddprof_ffi_Profile;
15
18
 
@@ -21,15 +24,19 @@ typedef struct ddprof_ffi_ProfileExporterV3 ddprof_ffi_ProfileExporterV3;
21
24
  */
22
25
  typedef struct ddprof_ffi_Request ddprof_ffi_Request;
23
26
 
27
+ typedef struct ddprof_ffi_Tag ddprof_ffi_Tag;
28
+
24
29
  /**
25
- * Buffer holds the raw parts of a Rust Vec; it should only be created from
26
- * Rust, never from C.
30
+ * Holds the raw parts of a Rust Vec; it should only be created from Rust,
31
+ * never from C.
32
+ * The names ptr and len were chosen to minimize conversion from a previous
33
+ * Buffer type which this has replaced to become more general.
27
34
  */
28
- typedef struct ddprof_ffi_Buffer {
35
+ typedef struct ddprof_ffi_Vec_u8 {
29
36
  const uint8_t *ptr;
30
- size_t len;
31
- size_t capacity;
32
- } ddprof_ffi_Buffer;
37
+ uintptr_t len;
38
+ uintptr_t capacity;
39
+ } ddprof_ffi_Vec_u8;
33
40
 
34
41
  typedef enum ddprof_ffi_NewProfileExporterV3Result_Tag {
35
42
  DDPROF_FFI_NEW_PROFILE_EXPORTER_V3_RESULT_OK,
@@ -43,48 +50,21 @@ typedef struct ddprof_ffi_NewProfileExporterV3Result {
43
50
  struct ddprof_ffi_ProfileExporterV3 *ok;
44
51
  };
45
52
  struct {
46
- struct ddprof_ffi_Buffer err;
53
+ struct ddprof_ffi_Vec_u8 err;
47
54
  };
48
55
  };
49
56
  } ddprof_ffi_NewProfileExporterV3Result;
50
57
 
51
- typedef struct ddprof_ffi_HttpStatus {
52
- uint16_t code;
53
- } ddprof_ffi_HttpStatus;
54
-
55
- typedef enum ddprof_ffi_SendResult_Tag {
56
- DDPROF_FFI_SEND_RESULT_HTTP_RESPONSE,
57
- DDPROF_FFI_SEND_RESULT_FAILURE,
58
- } ddprof_ffi_SendResult_Tag;
59
-
60
- typedef struct ddprof_ffi_SendResult {
61
- ddprof_ffi_SendResult_Tag tag;
62
- union {
63
- struct {
64
- struct ddprof_ffi_HttpStatus http_response;
65
- };
66
- struct {
67
- struct ddprof_ffi_Buffer failure;
68
- };
69
- };
70
- } ddprof_ffi_SendResult;
71
-
72
- typedef struct ddprof_ffi_Slice_u8 {
73
- const uint8_t *ptr;
74
- size_t len;
75
- } ddprof_ffi_Slice_u8;
76
-
77
- typedef struct ddprof_ffi_Slice_u8 ddprof_ffi_ByteSlice;
78
-
79
- typedef struct ddprof_ffi_Field {
80
- const char *name;
81
- ddprof_ffi_ByteSlice value;
82
- } ddprof_ffi_Field;
58
+ /**
59
+ * Remember, the data inside of each member is potentially coming from FFI,
60
+ * so every operation on it is unsafe!
61
+ */
62
+ typedef struct ddprof_ffi_Slice_c_char {
63
+ const char *ptr;
64
+ uintptr_t len;
65
+ } ddprof_ffi_Slice_c_char;
83
66
 
84
- typedef struct ddprof_ffi_Slice_field {
85
- const struct ddprof_ffi_Field *ptr;
86
- size_t len;
87
- } ddprof_ffi_Slice_field;
67
+ typedef struct ddprof_ffi_Slice_c_char ddprof_ffi_CharSlice;
88
68
 
89
69
  typedef enum ddprof_ffi_EndpointV3_Tag {
90
70
  DDPROF_FFI_ENDPOINT_V3_AGENT,
@@ -92,29 +72,31 @@ typedef enum ddprof_ffi_EndpointV3_Tag {
92
72
  } ddprof_ffi_EndpointV3_Tag;
93
73
 
94
74
  typedef struct ddprof_ffi_EndpointV3_ddprof_ffi_Agentless_Body {
95
- ddprof_ffi_ByteSlice _0;
96
- ddprof_ffi_ByteSlice _1;
75
+ ddprof_ffi_CharSlice _0;
76
+ ddprof_ffi_CharSlice _1;
97
77
  } ddprof_ffi_EndpointV3_ddprof_ffi_Agentless_Body;
98
78
 
99
79
  typedef struct ddprof_ffi_EndpointV3 {
100
80
  ddprof_ffi_EndpointV3_Tag tag;
101
81
  union {
102
82
  struct {
103
- ddprof_ffi_ByteSlice agent;
83
+ ddprof_ffi_CharSlice agent;
104
84
  };
105
85
  ddprof_ffi_EndpointV3_ddprof_ffi_Agentless_Body AGENTLESS;
106
86
  };
107
87
  } ddprof_ffi_EndpointV3;
108
88
 
109
- typedef struct ddprof_ffi_Tag {
110
- ddprof_ffi_ByteSlice name;
111
- ddprof_ffi_ByteSlice value;
112
- } ddprof_ffi_Tag;
113
-
114
- typedef struct ddprof_ffi_Slice_tag {
89
+ /**
90
+ * Holds the raw parts of a Rust Vec; it should only be created from Rust,
91
+ * never from C.
92
+ * The names ptr and len were chosen to minimize conversion from a previous
93
+ * Buffer type which this has replaced to become more general.
94
+ */
95
+ typedef struct ddprof_ffi_Vec_tag {
115
96
  const struct ddprof_ffi_Tag *ptr;
116
- size_t len;
117
- } ddprof_ffi_Slice_tag;
97
+ uintptr_t len;
98
+ uintptr_t capacity;
99
+ } ddprof_ffi_Vec_tag;
118
100
 
119
101
  /**
120
102
  * Represents time since the Unix Epoch in seconds plus nanoseconds.
@@ -124,29 +106,67 @@ typedef struct ddprof_ffi_Timespec {
124
106
  uint32_t nanoseconds;
125
107
  } ddprof_ffi_Timespec;
126
108
 
109
+ /**
110
+ * Remember, the data inside of each member is potentially coming from FFI,
111
+ * so every operation on it is unsafe!
112
+ */
113
+ typedef struct ddprof_ffi_Slice_u8 {
114
+ const uint8_t *ptr;
115
+ uintptr_t len;
116
+ } ddprof_ffi_Slice_u8;
117
+
118
+ /**
119
+ * Use to represent bytes -- does not need to be valid UTF-8.
120
+ */
121
+ typedef struct ddprof_ffi_Slice_u8 ddprof_ffi_ByteSlice;
122
+
127
123
  typedef struct ddprof_ffi_File {
128
- ddprof_ffi_ByteSlice name;
124
+ ddprof_ffi_CharSlice name;
129
125
  ddprof_ffi_ByteSlice file;
130
126
  } ddprof_ffi_File;
131
127
 
128
+ /**
129
+ * Remember, the data inside of each member is potentially coming from FFI,
130
+ * so every operation on it is unsafe!
131
+ */
132
132
  typedef struct ddprof_ffi_Slice_file {
133
133
  const struct ddprof_ffi_File *ptr;
134
- size_t len;
134
+ uintptr_t len;
135
135
  } ddprof_ffi_Slice_file;
136
136
 
137
- typedef struct ddprof_ffi_Slice_c_char {
138
- const char *ptr;
139
- size_t len;
140
- } ddprof_ffi_Slice_c_char;
137
+ typedef struct ddprof_ffi_HttpStatus {
138
+ uint16_t code;
139
+ } ddprof_ffi_HttpStatus;
140
+
141
+ typedef enum ddprof_ffi_SendResult_Tag {
142
+ DDPROF_FFI_SEND_RESULT_HTTP_RESPONSE,
143
+ DDPROF_FFI_SEND_RESULT_FAILURE,
144
+ } ddprof_ffi_SendResult_Tag;
145
+
146
+ typedef struct ddprof_ffi_SendResult {
147
+ ddprof_ffi_SendResult_Tag tag;
148
+ union {
149
+ struct {
150
+ struct ddprof_ffi_HttpStatus http_response;
151
+ };
152
+ struct {
153
+ struct ddprof_ffi_Vec_u8 failure;
154
+ };
155
+ };
156
+ } ddprof_ffi_SendResult;
141
157
 
142
158
  typedef struct ddprof_ffi_ValueType {
143
- struct ddprof_ffi_Slice_c_char type_;
144
- struct ddprof_ffi_Slice_c_char unit;
159
+ ddprof_ffi_CharSlice type_;
160
+ ddprof_ffi_CharSlice unit;
145
161
  } ddprof_ffi_ValueType;
146
162
 
163
+ /**
164
+ * Remember, the data inside of each member is potentially coming from FFI,
165
+ * so every operation on it is unsafe!
166
+ */
147
167
  typedef struct ddprof_ffi_Slice_value_type {
148
168
  const struct ddprof_ffi_ValueType *ptr;
149
- size_t len;
169
+ uintptr_t len;
150
170
  } ddprof_ffi_Slice_value_type;
151
171
 
152
172
  typedef struct ddprof_ffi_Period {
@@ -172,29 +192,29 @@ typedef struct ddprof_ffi_Mapping {
172
192
  * disk for the main binary and shared libraries, or virtual
173
193
  * abstractions like "[vdso]".
174
194
  */
175
- struct ddprof_ffi_Slice_c_char filename;
195
+ ddprof_ffi_CharSlice filename;
176
196
  /**
177
197
  * A string that uniquely identifies a particular program version
178
198
  * with high probability. E.g., for binaries generated by GNU tools,
179
199
  * it could be the contents of the .note.gnu.build-id field.
180
200
  */
181
- struct ddprof_ffi_Slice_c_char build_id;
201
+ ddprof_ffi_CharSlice build_id;
182
202
  } ddprof_ffi_Mapping;
183
203
 
184
204
  typedef struct ddprof_ffi_Function {
185
205
  /**
186
206
  * Name of the function, in human-readable form if available.
187
207
  */
188
- struct ddprof_ffi_Slice_c_char name;
208
+ ddprof_ffi_CharSlice name;
189
209
  /**
190
210
  * Name of the function, as identified by the system.
191
211
  * For instance, it can be a C++ mangled name.
192
212
  */
193
- struct ddprof_ffi_Slice_c_char system_name;
213
+ ddprof_ffi_CharSlice system_name;
194
214
  /**
195
215
  * Source file containing the function.
196
216
  */
197
- struct ddprof_ffi_Slice_c_char filename;
217
+ ddprof_ffi_CharSlice filename;
198
218
  /**
199
219
  * Line number in source file.
200
220
  */
@@ -212,9 +232,13 @@ typedef struct ddprof_ffi_Line {
212
232
  int64_t line;
213
233
  } ddprof_ffi_Line;
214
234
 
235
+ /**
236
+ * Remember, the data inside of each member is potentially coming from FFI,
237
+ * so every operation on it is unsafe!
238
+ */
215
239
  typedef struct ddprof_ffi_Slice_line {
216
240
  const struct ddprof_ffi_Line *ptr;
217
- size_t len;
241
+ uintptr_t len;
218
242
  } ddprof_ffi_Slice_line;
219
243
 
220
244
  typedef struct ddprof_ffi_Location {
@@ -250,22 +274,30 @@ typedef struct ddprof_ffi_Location {
250
274
  bool is_folded;
251
275
  } ddprof_ffi_Location;
252
276
 
277
+ /**
278
+ * Remember, the data inside of each member is potentially coming from FFI,
279
+ * so every operation on it is unsafe!
280
+ */
253
281
  typedef struct ddprof_ffi_Slice_location {
254
282
  const struct ddprof_ffi_Location *ptr;
255
- size_t len;
283
+ uintptr_t len;
256
284
  } ddprof_ffi_Slice_location;
257
285
 
286
+ /**
287
+ * Remember, the data inside of each member is potentially coming from FFI,
288
+ * so every operation on it is unsafe!
289
+ */
258
290
  typedef struct ddprof_ffi_Slice_i64 {
259
291
  const int64_t *ptr;
260
- size_t len;
292
+ uintptr_t len;
261
293
  } ddprof_ffi_Slice_i64;
262
294
 
263
295
  typedef struct ddprof_ffi_Label {
264
- struct ddprof_ffi_Slice_c_char key;
296
+ ddprof_ffi_CharSlice key;
265
297
  /**
266
298
  * At most one of the following must be present
267
299
  */
268
- struct ddprof_ffi_Slice_c_char str;
300
+ ddprof_ffi_CharSlice str;
269
301
  int64_t num;
270
302
  /**
271
303
  * Should only be present when num is present.
@@ -276,12 +308,16 @@ typedef struct ddprof_ffi_Label {
276
308
  * units and units like "seconds" and "nanoseconds" as time units,
277
309
  * and apply appropriate unit conversions to these.
278
310
  */
279
- struct ddprof_ffi_Slice_c_char num_unit;
311
+ ddprof_ffi_CharSlice num_unit;
280
312
  } ddprof_ffi_Label;
281
313
 
314
+ /**
315
+ * Remember, the data inside of each member is potentially coming from FFI,
316
+ * so every operation on it is unsafe!
317
+ */
282
318
  typedef struct ddprof_ffi_Slice_label {
283
319
  const struct ddprof_ffi_Label *ptr;
284
- size_t len;
320
+ uintptr_t len;
285
321
  } ddprof_ffi_Slice_label;
286
322
 
287
323
  typedef struct ddprof_ffi_Sample {
@@ -308,61 +344,66 @@ typedef struct ddprof_ffi_Sample {
308
344
  typedef struct ddprof_ffi_EncodedProfile {
309
345
  struct ddprof_ffi_Timespec start;
310
346
  struct ddprof_ffi_Timespec end;
311
- struct ddprof_ffi_Buffer buffer;
347
+ struct ddprof_ffi_Vec_u8 buffer;
312
348
  } ddprof_ffi_EncodedProfile;
313
349
 
314
- void ddprof_ffi_NewProfileExporterV3Result_dtor(struct ddprof_ffi_NewProfileExporterV3Result result);
350
+ typedef enum ddprof_ffi_SerializeResult_Tag {
351
+ DDPROF_FFI_SERIALIZE_RESULT_OK,
352
+ DDPROF_FFI_SERIALIZE_RESULT_ERR,
353
+ } ddprof_ffi_SerializeResult_Tag;
315
354
 
316
- /**
317
- * Create a new Exporter, initializing the TLS stack.
318
- */
319
- struct ddprof_ffi_Exporter *ddprof_ffi_Exporter_new(void);
355
+ typedef struct ddprof_ffi_SerializeResult {
356
+ ddprof_ffi_SerializeResult_Tag tag;
357
+ union {
358
+ struct {
359
+ struct ddprof_ffi_EncodedProfile ok;
360
+ };
361
+ struct {
362
+ struct ddprof_ffi_Vec_u8 err;
363
+ };
364
+ };
365
+ } ddprof_ffi_SerializeResult;
320
366
 
321
- /**
322
- * # Safety
323
- * All pointers must point to valid objects for that type. If they are used as
324
- * arrays, such as in Slice, then they must be valid for the associated number
325
- * of elements. All pointers must be aligned.
326
- */
327
- struct ddprof_ffi_SendResult ddprof_ffi_Exporter_send(struct ddprof_ffi_Exporter *exporter_ptr,
328
- const char *http_method,
329
- const char *url,
330
- struct ddprof_ffi_Slice_field headers,
331
- ddprof_ffi_ByteSlice body,
332
- uint64_t timeout_ms);
367
+ typedef enum ddprof_ffi_PushTagResult_Tag {
368
+ DDPROF_FFI_PUSH_TAG_RESULT_OK,
369
+ DDPROF_FFI_PUSH_TAG_RESULT_ERR,
370
+ } ddprof_ffi_PushTagResult_Tag;
333
371
 
334
- /**
335
- * Clears the contents of the Buffer, leaving length and capacity of 0.
336
- * # Safety
337
- * The `buffer` must be created by Rust, or null.
338
- */
339
- void ddprof_ffi_Buffer_reset(struct ddprof_ffi_Buffer *buffer);
372
+ typedef struct ddprof_ffi_PushTagResult {
373
+ ddprof_ffi_PushTagResult_Tag tag;
374
+ union {
375
+ struct {
376
+ struct ddprof_ffi_Vec_u8 err;
377
+ };
378
+ };
379
+ } ddprof_ffi_PushTagResult;
340
380
 
341
- /**
342
- * Destroys the Exporter.
343
- */
344
- void ddprof_ffi_Exporter_delete(struct ddprof_ffi_Exporter *exporter);
381
+ typedef struct ddprof_ffi_ParseTagsResult {
382
+ struct ddprof_ffi_Vec_tag tags;
383
+ struct ddprof_ffi_Vec_u8 *error_message;
384
+ } ddprof_ffi_ParseTagsResult;
385
+
386
+ void ddprof_ffi_NewProfileExporterV3Result_drop(struct ddprof_ffi_NewProfileExporterV3Result result);
345
387
 
346
388
  /**
347
389
  * Creates an endpoint that uses the agent.
348
390
  * # Arguments
349
- * * `base_url` - a ByteSlice which contains a URL with scheme, host, and port
350
- * e.g. "https://agent:8126/"
391
+ * * `base_url` - Contains a URL with scheme, host, and port e.g. "https://agent:8126/".
351
392
  */
352
- struct ddprof_ffi_EndpointV3 ddprof_ffi_EndpointV3_agent(ddprof_ffi_ByteSlice base_url);
393
+ struct ddprof_ffi_EndpointV3 ddprof_ffi_EndpointV3_agent(ddprof_ffi_CharSlice base_url);
353
394
 
354
395
  /**
355
396
  * Creates an endpoint that uses the Datadog intake directly aka agentless.
356
397
  * # Arguments
357
- * * `site` - a ByteSlice which contains a host and port e.g.
358
- * "datadoghq.com"
359
- * * `api_key` - A ByteSlice which contains the Datadog API key.
398
+ * * `site` - Contains a host and port e.g. "datadoghq.com".
399
+ * * `api_key` - Contains the Datadog API key.
360
400
  */
361
- struct ddprof_ffi_EndpointV3 ddprof_ffi_EndpointV3_agentless(ddprof_ffi_ByteSlice site,
362
- ddprof_ffi_ByteSlice api_key);
401
+ struct ddprof_ffi_EndpointV3 ddprof_ffi_EndpointV3_agentless(ddprof_ffi_CharSlice site,
402
+ ddprof_ffi_CharSlice api_key);
363
403
 
364
- struct ddprof_ffi_NewProfileExporterV3Result ddprof_ffi_ProfileExporterV3_new(ddprof_ffi_ByteSlice family,
365
- struct ddprof_ffi_Slice_tag tags,
404
+ __attribute__((warn_unused_result))
405
+ struct ddprof_ffi_NewProfileExporterV3Result ddprof_ffi_ProfileExporterV3_new(ddprof_ffi_CharSlice family,
406
+ const struct ddprof_ffi_Vec_tag *tags,
366
407
  struct ddprof_ffi_EndpointV3 endpoint);
367
408
 
368
409
  void ddprof_ffi_ProfileExporterV3_delete(struct ddprof_ffi_ProfileExporterV3 *exporter);
@@ -378,6 +419,7 @@ struct ddprof_ffi_Request *ddprof_ffi_ProfileExporterV3_build(struct ddprof_ffi_
378
419
  struct ddprof_ffi_Timespec start,
379
420
  struct ddprof_ffi_Timespec end,
380
421
  struct ddprof_ffi_Slice_file files,
422
+ const struct ddprof_ffi_Vec_tag *additional_tags,
381
423
  uint64_t timeout_ms);
382
424
 
383
425
  /**
@@ -386,13 +428,58 @@ struct ddprof_ffi_Request *ddprof_ffi_ProfileExporterV3_build(struct ddprof_ffi_
386
428
  * # Arguments
387
429
  * * `exporter` - borrows the exporter for sending the request
388
430
  * * `request` - takes ownership of the request
431
+ * * `cancel` - borrows the cancel, if any
389
432
  *
390
433
  * # Safety
391
- * If the `exporter` and `request` are non-null, then they need to have been
392
- * created by apis in this module.
434
+ * All non-null arguments MUST have been created by created by apis in this module.
393
435
  */
436
+ __attribute__((warn_unused_result))
394
437
  struct ddprof_ffi_SendResult ddprof_ffi_ProfileExporterV3_send(struct ddprof_ffi_ProfileExporterV3 *exporter,
395
- struct ddprof_ffi_Request *request);
438
+ struct ddprof_ffi_Request *request,
439
+ struct ddprof_ffi_CancellationToken *cancel);
440
+
441
+ /**
442
+ * Can be passed as an argument to send and then be used to asynchronously cancel it from a different thread.
443
+ */
444
+ __attribute__((warn_unused_result))
445
+ struct ddprof_ffi_CancellationToken *ddprof_ffi_CancellationToken_new(void);
446
+
447
+ /**
448
+ * A cloned CancellationToken is connected to the CancellationToken it was created from.
449
+ * Either the cloned or the original token can be used to cancel or provided as arguments to send.
450
+ * The useful part is that they have independent lifetimes and can be dropped separately.
451
+ *
452
+ * Thus, it's possible to do something like:
453
+ * ```c
454
+ * cancel_t1 = ddprof_ffi_CancellationToken_new();
455
+ * cancel_t2 = ddprof_ffi_CancellationToken_clone(cancel_t1);
456
+ *
457
+ * // On thread t1:
458
+ * ddprof_ffi_ProfileExporterV3_send(..., cancel_t1);
459
+ * ddprof_ffi_CancellationToken_drop(cancel_t1);
460
+ *
461
+ * // On thread t2:
462
+ * ddprof_ffi_CancellationToken_cancel(cancel_t2);
463
+ * ddprof_ffi_CancellationToken_drop(cancel_t2);
464
+ * ```
465
+ *
466
+ * Without clone, both t1 and t2 would need to synchronize to make sure neither was using the cancel
467
+ * before it could be dropped. With clone, there is no need for such synchronization, both threads
468
+ * have their own cancel and should drop that cancel after they are done with it.
469
+ */
470
+ __attribute__((warn_unused_result))
471
+ struct ddprof_ffi_CancellationToken *ddprof_ffi_CancellationToken_clone(struct ddprof_ffi_CancellationToken *cancel);
472
+
473
+ /**
474
+ * Cancel send that is being called in another thread with the given token.
475
+ * Note that cancellation is a terminal state; cancelling a token more than once does nothing.
476
+ * Returns `true` if token was successfully cancelled.
477
+ */
478
+ bool ddprof_ffi_CancellationToken_cancel(struct ddprof_ffi_CancellationToken *cancel);
479
+
480
+ void ddprof_ffi_CancellationToken_drop(struct ddprof_ffi_CancellationToken *_cancel);
481
+
482
+ void ddprof_ffi_SendResult_drop(struct ddprof_ffi_SendResult result);
396
483
 
397
484
  /**
398
485
  * Create a new profile with the given sample types. Must call
@@ -423,20 +510,16 @@ uint64_t ddprof_ffi_Profile_add(struct ddprof_ffi_Profile *profile,
423
510
  struct ddprof_ffi_Sample sample);
424
511
 
425
512
  /**
426
- * Destroys the `encoded_profile`
427
- * # Safety
428
- * Only safe on profiles created by `ddprof_ffi_Profile_serialize`.
513
+ * Serialize the aggregated profile. Don't forget to clean up the result by
514
+ * calling ddprof_ffi_SerializeResult_drop.
429
515
  */
430
- void ddprof_ffi_EncodedProfile_delete(struct ddprof_ffi_EncodedProfile *encoded_profile);
516
+ __attribute__((warn_unused_result))
517
+ struct ddprof_ffi_SerializeResult ddprof_ffi_Profile_serialize(const struct ddprof_ffi_Profile *profile);
518
+
519
+ void ddprof_ffi_SerializeResult_drop(struct ddprof_ffi_SerializeResult result);
431
520
 
432
- /**
433
- * Serialize the aggregated profile. Be sure to check the return value and if
434
- * it's non-null then call `ddprof_ffi_EncodedProfile_delete` on it once
435
- * done with it.
436
- * result to free it.
437
- */
438
521
  __attribute__((warn_unused_result))
439
- struct ddprof_ffi_EncodedProfile *ddprof_ffi_Profile_serialize(const struct ddprof_ffi_Profile *profile);
522
+ struct ddprof_ffi_Slice_u8 ddprof_ffi_Vec_u8_as_slice(const struct ddprof_ffi_Vec_u8 *vec);
440
523
 
441
524
  /**
442
525
  * Resets all data in `profile` except the sample types and period. Returns
@@ -445,11 +528,28 @@ struct ddprof_ffi_EncodedProfile *ddprof_ffi_Profile_serialize(const struct ddpr
445
528
  */
446
529
  bool ddprof_ffi_Profile_reset(struct ddprof_ffi_Profile *profile);
447
530
 
531
+ __attribute__((warn_unused_result)) struct ddprof_ffi_Vec_tag ddprof_ffi_Vec_tag_new(void);
532
+
533
+ void ddprof_ffi_Vec_tag_drop(struct ddprof_ffi_Vec_tag);
534
+
535
+ void ddprof_ffi_PushTagResult_drop(struct ddprof_ffi_PushTagResult);
536
+
448
537
  /**
538
+ * Creates a new Tag from the provided `key` and `value` by doing a utf8
539
+ * lossy conversion, and pushes into the `vec`. The strings `key` and `value`
540
+ * are cloned to avoid FFI lifetime issues.
541
+ *
449
542
  * # Safety
450
- * Only pass buffers which were created by ddprof routines; do not create one
451
- * in C and then pass it in. Only call this once per buffer.
543
+ * The `vec` must be a valid reference.
544
+ * The CharSlices `key` and `value` must point to at least many bytes as their
545
+ * `.len` properties claim.
452
546
  */
453
- void ddprof_ffi_Buffer_free(struct ddprof_ffi_Buffer *buffer);
547
+ __attribute__((warn_unused_result))
548
+ struct ddprof_ffi_PushTagResult ddprof_ffi_Vec_tag_push(struct ddprof_ffi_Vec_tag *vec,
549
+ ddprof_ffi_CharSlice key,
550
+ ddprof_ffi_CharSlice value);
551
+
552
+ __attribute__((warn_unused_result))
553
+ struct ddprof_ffi_ParseTagsResult ddprof_ffi_Vec_tag_parse(ddprof_ffi_CharSlice string);
454
554
 
455
555
  #endif /* DDPROF_FFI_H */
@@ -10,7 +10,7 @@ includedir=${prefix}/include
10
10
 
11
11
  Name: ddprof_ffi
12
12
  Description: Contains common code used to implement Datadog's Continuous Profilers. (Dynamic linking variant, sets rpath)
13
- Version: 0.4.0-rc.1
13
+ Version: 0.6.0
14
14
  Requires:
15
15
  Libs: -L${libdir} -lddprof_ffi -Wl,-rpath,${libdir}
16
16
  Libs.private: