libdatadog 0.7.0.1.0.rc1-x86_64-linux

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4 @@
1
+ Datadog libdatadog
2
+ Copyright 2021-2022 Datadog, Inc.
3
+
4
+ This product includes software developed at Datadog (<https://www.datadoghq.com/>).
@@ -0,0 +1,591 @@
1
+ // Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
2
+ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2021-Present Datadog, Inc.
3
+
4
+
5
+ #ifndef DDPROF_FFI_H
6
+ #define DDPROF_FFI_H
7
+
8
+ #include <stdbool.h>
9
+ #include <stddef.h>
10
+ #include <stdint.h>
11
+
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;
16
+
17
+ typedef struct ddprof_ffi_Profile ddprof_ffi_Profile;
18
+
19
+ typedef struct ddprof_ffi_ProfileExporterV3 ddprof_ffi_ProfileExporterV3;
20
+
21
+ /**
22
+ * This type only exists to workaround a bug in cbindgen; may be removed in the
23
+ * future.
24
+ */
25
+ typedef struct ddprof_ffi_Request ddprof_ffi_Request;
26
+
27
+ typedef struct ddprof_ffi_Tag ddprof_ffi_Tag;
28
+
29
+ /**
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.
34
+ */
35
+ typedef struct ddprof_ffi_Vec_u8 {
36
+ const uint8_t *ptr;
37
+ uintptr_t len;
38
+ uintptr_t capacity;
39
+ } ddprof_ffi_Vec_u8;
40
+
41
+ typedef enum ddprof_ffi_NewProfileExporterV3Result_Tag {
42
+ DDPROF_FFI_NEW_PROFILE_EXPORTER_V3_RESULT_OK,
43
+ DDPROF_FFI_NEW_PROFILE_EXPORTER_V3_RESULT_ERR,
44
+ } ddprof_ffi_NewProfileExporterV3Result_Tag;
45
+
46
+ typedef struct ddprof_ffi_NewProfileExporterV3Result {
47
+ ddprof_ffi_NewProfileExporterV3Result_Tag tag;
48
+ union {
49
+ struct {
50
+ struct ddprof_ffi_ProfileExporterV3 *ok;
51
+ };
52
+ struct {
53
+ struct ddprof_ffi_Vec_u8 err;
54
+ };
55
+ };
56
+ } ddprof_ffi_NewProfileExporterV3Result;
57
+
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;
66
+
67
+ typedef struct ddprof_ffi_Slice_c_char ddprof_ffi_CharSlice;
68
+
69
+ typedef enum ddprof_ffi_EndpointV3_Tag {
70
+ DDPROF_FFI_ENDPOINT_V3_AGENT,
71
+ DDPROF_FFI_ENDPOINT_V3_AGENTLESS,
72
+ } ddprof_ffi_EndpointV3_Tag;
73
+
74
+ typedef struct ddprof_ffi_EndpointV3_ddprof_ffi_Agentless_Body {
75
+ ddprof_ffi_CharSlice _0;
76
+ ddprof_ffi_CharSlice _1;
77
+ } ddprof_ffi_EndpointV3_ddprof_ffi_Agentless_Body;
78
+
79
+ typedef struct ddprof_ffi_EndpointV3 {
80
+ ddprof_ffi_EndpointV3_Tag tag;
81
+ union {
82
+ struct {
83
+ ddprof_ffi_CharSlice agent;
84
+ };
85
+ ddprof_ffi_EndpointV3_ddprof_ffi_Agentless_Body AGENTLESS;
86
+ };
87
+ } ddprof_ffi_EndpointV3;
88
+
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 {
96
+ const struct ddprof_ffi_Tag *ptr;
97
+ uintptr_t len;
98
+ uintptr_t capacity;
99
+ } ddprof_ffi_Vec_tag;
100
+
101
+ /**
102
+ * Represents time since the Unix Epoch in seconds plus nanoseconds.
103
+ */
104
+ typedef struct ddprof_ffi_Timespec {
105
+ int64_t seconds;
106
+ uint32_t nanoseconds;
107
+ } ddprof_ffi_Timespec;
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
+
123
+ typedef struct ddprof_ffi_File {
124
+ ddprof_ffi_CharSlice name;
125
+ ddprof_ffi_ByteSlice file;
126
+ } ddprof_ffi_File;
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
+ typedef struct ddprof_ffi_Slice_file {
133
+ const struct ddprof_ffi_File *ptr;
134
+ uintptr_t len;
135
+ } ddprof_ffi_Slice_file;
136
+
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_ERR,
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 err;
154
+ };
155
+ };
156
+ } ddprof_ffi_SendResult;
157
+
158
+ typedef struct ddprof_ffi_ValueType {
159
+ ddprof_ffi_CharSlice type_;
160
+ ddprof_ffi_CharSlice unit;
161
+ } ddprof_ffi_ValueType;
162
+
163
+ /**
164
+ * Remember, the data inside of each member is potentially coming from FFI,
165
+ * so every operation on it is unsafe!
166
+ */
167
+ typedef struct ddprof_ffi_Slice_value_type {
168
+ const struct ddprof_ffi_ValueType *ptr;
169
+ uintptr_t len;
170
+ } ddprof_ffi_Slice_value_type;
171
+
172
+ typedef struct ddprof_ffi_Period {
173
+ struct ddprof_ffi_ValueType type_;
174
+ int64_t value;
175
+ } ddprof_ffi_Period;
176
+
177
+ typedef struct ddprof_ffi_Mapping {
178
+ /**
179
+ * Address at which the binary (or DLL) is loaded into memory.
180
+ */
181
+ uint64_t memory_start;
182
+ /**
183
+ * The limit of the address range occupied by this mapping.
184
+ */
185
+ uint64_t memory_limit;
186
+ /**
187
+ * Offset in the binary that corresponds to the first mapped address.
188
+ */
189
+ uint64_t file_offset;
190
+ /**
191
+ * The object this entry is loaded from. This can be a filename on
192
+ * disk for the main binary and shared libraries, or virtual
193
+ * abstractions like "[vdso]".
194
+ */
195
+ ddprof_ffi_CharSlice filename;
196
+ /**
197
+ * A string that uniquely identifies a particular program version
198
+ * with high probability. E.g., for binaries generated by GNU tools,
199
+ * it could be the contents of the .note.gnu.build-id field.
200
+ */
201
+ ddprof_ffi_CharSlice build_id;
202
+ } ddprof_ffi_Mapping;
203
+
204
+ typedef struct ddprof_ffi_Function {
205
+ /**
206
+ * Name of the function, in human-readable form if available.
207
+ */
208
+ ddprof_ffi_CharSlice name;
209
+ /**
210
+ * Name of the function, as identified by the system.
211
+ * For instance, it can be a C++ mangled name.
212
+ */
213
+ ddprof_ffi_CharSlice system_name;
214
+ /**
215
+ * Source file containing the function.
216
+ */
217
+ ddprof_ffi_CharSlice filename;
218
+ /**
219
+ * Line number in source file.
220
+ */
221
+ int64_t start_line;
222
+ } ddprof_ffi_Function;
223
+
224
+ typedef struct ddprof_ffi_Line {
225
+ /**
226
+ * The corresponding profile.Function for this line.
227
+ */
228
+ struct ddprof_ffi_Function function;
229
+ /**
230
+ * Line number in source code.
231
+ */
232
+ int64_t line;
233
+ } ddprof_ffi_Line;
234
+
235
+ /**
236
+ * Remember, the data inside of each member is potentially coming from FFI,
237
+ * so every operation on it is unsafe!
238
+ */
239
+ typedef struct ddprof_ffi_Slice_line {
240
+ const struct ddprof_ffi_Line *ptr;
241
+ uintptr_t len;
242
+ } ddprof_ffi_Slice_line;
243
+
244
+ typedef struct ddprof_ffi_Location {
245
+ /**
246
+ * todo: how to handle unknown mapping?
247
+ */
248
+ struct ddprof_ffi_Mapping mapping;
249
+ /**
250
+ * The instruction address for this location, if available. It
251
+ * should be within [Mapping.memory_start...Mapping.memory_limit]
252
+ * for the corresponding mapping. A non-leaf address may be in the
253
+ * middle of a call instruction. It is up to display tools to find
254
+ * the beginning of the instruction if necessary.
255
+ */
256
+ uint64_t address;
257
+ /**
258
+ * Multiple line indicates this location has inlined functions,
259
+ * where the last entry represents the caller into which the
260
+ * preceding entries were inlined.
261
+ *
262
+ * E.g., if memcpy() is inlined into printf:
263
+ * line[0].function_name == "memcpy"
264
+ * line[1].function_name == "printf"
265
+ */
266
+ struct ddprof_ffi_Slice_line lines;
267
+ /**
268
+ * Provides an indication that multiple symbols map to this location's
269
+ * address, for example due to identical code folding by the linker. In that
270
+ * case the line information above represents one of the multiple
271
+ * symbols. This field must be recomputed when the symbolization state of the
272
+ * profile changes.
273
+ */
274
+ bool is_folded;
275
+ } ddprof_ffi_Location;
276
+
277
+ /**
278
+ * Remember, the data inside of each member is potentially coming from FFI,
279
+ * so every operation on it is unsafe!
280
+ */
281
+ typedef struct ddprof_ffi_Slice_location {
282
+ const struct ddprof_ffi_Location *ptr;
283
+ uintptr_t len;
284
+ } ddprof_ffi_Slice_location;
285
+
286
+ /**
287
+ * Remember, the data inside of each member is potentially coming from FFI,
288
+ * so every operation on it is unsafe!
289
+ */
290
+ typedef struct ddprof_ffi_Slice_i64 {
291
+ const int64_t *ptr;
292
+ uintptr_t len;
293
+ } ddprof_ffi_Slice_i64;
294
+
295
+ typedef struct ddprof_ffi_Label {
296
+ ddprof_ffi_CharSlice key;
297
+ /**
298
+ * At most one of the following must be present
299
+ */
300
+ ddprof_ffi_CharSlice str;
301
+ int64_t num;
302
+ /**
303
+ * Should only be present when num is present.
304
+ * Specifies the units of num.
305
+ * Use arbitrary string (for example, "requests") as a custom count unit.
306
+ * If no unit is specified, consumer may apply heuristic to deduce the unit.
307
+ * Consumers may also interpret units like "bytes" and "kilobytes" as memory
308
+ * units and units like "seconds" and "nanoseconds" as time units,
309
+ * and apply appropriate unit conversions to these.
310
+ */
311
+ ddprof_ffi_CharSlice num_unit;
312
+ } ddprof_ffi_Label;
313
+
314
+ /**
315
+ * Remember, the data inside of each member is potentially coming from FFI,
316
+ * so every operation on it is unsafe!
317
+ */
318
+ typedef struct ddprof_ffi_Slice_label {
319
+ const struct ddprof_ffi_Label *ptr;
320
+ uintptr_t len;
321
+ } ddprof_ffi_Slice_label;
322
+
323
+ typedef struct ddprof_ffi_Sample {
324
+ /**
325
+ * The leaf is at locations[0].
326
+ */
327
+ struct ddprof_ffi_Slice_location locations;
328
+ /**
329
+ * The type and unit of each value is defined by the corresponding
330
+ * entry in Profile.sample_type. All samples must have the same
331
+ * number of values, the same as the length of Profile.sample_type.
332
+ * When aggregating multiple samples into a single sample, the
333
+ * result has a list of values that is the element-wise sum of the
334
+ * lists of the originals.
335
+ */
336
+ struct ddprof_ffi_Slice_i64 values;
337
+ /**
338
+ * label includes additional context for this sample. It can include
339
+ * things like a thread id, allocation size, etc
340
+ */
341
+ struct ddprof_ffi_Slice_label labels;
342
+ } ddprof_ffi_Sample;
343
+
344
+ typedef struct ddprof_ffi_EncodedProfile {
345
+ struct ddprof_ffi_Timespec start;
346
+ struct ddprof_ffi_Timespec end;
347
+ struct ddprof_ffi_Vec_u8 buffer;
348
+ } ddprof_ffi_EncodedProfile;
349
+
350
+ typedef enum ddprof_ffi_SerializeResult_Tag {
351
+ DDPROF_FFI_SERIALIZE_RESULT_OK,
352
+ DDPROF_FFI_SERIALIZE_RESULT_ERR,
353
+ } ddprof_ffi_SerializeResult_Tag;
354
+
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;
366
+
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;
371
+
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;
380
+
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);
387
+
388
+ /**
389
+ * Creates an endpoint that uses the agent.
390
+ * # Arguments
391
+ * * `base_url` - Contains a URL with scheme, host, and port e.g. "https://agent:8126/".
392
+ */
393
+ struct ddprof_ffi_EndpointV3 ddprof_ffi_EndpointV3_agent(ddprof_ffi_CharSlice base_url);
394
+
395
+ /**
396
+ * Creates an endpoint that uses the Datadog intake directly aka agentless.
397
+ * # Arguments
398
+ * * `site` - Contains a host and port e.g. "datadoghq.com".
399
+ * * `api_key` - Contains the Datadog API key.
400
+ */
401
+ struct ddprof_ffi_EndpointV3 ddprof_ffi_EndpointV3_agentless(ddprof_ffi_CharSlice site,
402
+ ddprof_ffi_CharSlice api_key);
403
+
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,
407
+ struct ddprof_ffi_EndpointV3 endpoint);
408
+
409
+ void ddprof_ffi_ProfileExporterV3_delete(struct ddprof_ffi_ProfileExporterV3 *exporter);
410
+
411
+ /**
412
+ * Builds a Request object based on the profile data supplied.
413
+ *
414
+ * # Safety
415
+ * The `exporter` and the files inside of the `files` slice need to have been
416
+ * created by this module.
417
+ */
418
+ struct ddprof_ffi_Request *ddprof_ffi_ProfileExporterV3_build(struct ddprof_ffi_ProfileExporterV3 *exporter,
419
+ struct ddprof_ffi_Timespec start,
420
+ struct ddprof_ffi_Timespec end,
421
+ struct ddprof_ffi_Slice_file files,
422
+ const struct ddprof_ffi_Vec_tag *additional_tags,
423
+ uint64_t timeout_ms);
424
+
425
+ /**
426
+ * Sends the request, returning the HttpStatus.
427
+ *
428
+ * # Arguments
429
+ * * `exporter` - borrows the exporter for sending the request
430
+ * * `request` - takes ownership of the request
431
+ * * `cancel` - borrows the cancel, if any
432
+ *
433
+ * # Safety
434
+ * All non-null arguments MUST have been created by created by apis in this module.
435
+ */
436
+ __attribute__((warn_unused_result))
437
+ struct ddprof_ffi_SendResult ddprof_ffi_ProfileExporterV3_send(struct ddprof_ffi_ProfileExporterV3 *exporter,
438
+ struct ddprof_ffi_Request *request,
439
+ struct ddprof_ffi_CancellationToken *cancel);
440
+
441
+ void ddprof_ffi_Request_drop(struct ddprof_ffi_Request *_request);
442
+
443
+ /**
444
+ * Can be passed as an argument to send and then be used to asynchronously cancel it from a different thread.
445
+ */
446
+ __attribute__((warn_unused_result))
447
+ struct ddprof_ffi_CancellationToken *ddprof_ffi_CancellationToken_new(void);
448
+
449
+ /**
450
+ * A cloned CancellationToken is connected to the CancellationToken it was created from.
451
+ * Either the cloned or the original token can be used to cancel or provided as arguments to send.
452
+ * The useful part is that they have independent lifetimes and can be dropped separately.
453
+ *
454
+ * Thus, it's possible to do something like:
455
+ * ```c
456
+ * cancel_t1 = ddprof_ffi_CancellationToken_new();
457
+ * cancel_t2 = ddprof_ffi_CancellationToken_clone(cancel_t1);
458
+ *
459
+ * // On thread t1:
460
+ * ddprof_ffi_ProfileExporterV3_send(..., cancel_t1);
461
+ * ddprof_ffi_CancellationToken_drop(cancel_t1);
462
+ *
463
+ * // On thread t2:
464
+ * ddprof_ffi_CancellationToken_cancel(cancel_t2);
465
+ * ddprof_ffi_CancellationToken_drop(cancel_t2);
466
+ * ```
467
+ *
468
+ * Without clone, both t1 and t2 would need to synchronize to make sure neither was using the cancel
469
+ * before it could be dropped. With clone, there is no need for such synchronization, both threads
470
+ * have their own cancel and should drop that cancel after they are done with it.
471
+ */
472
+ __attribute__((warn_unused_result))
473
+ struct ddprof_ffi_CancellationToken *ddprof_ffi_CancellationToken_clone(struct ddprof_ffi_CancellationToken *cancel);
474
+
475
+ /**
476
+ * Cancel send that is being called in another thread with the given token.
477
+ * Note that cancellation is a terminal state; cancelling a token more than once does nothing.
478
+ * Returns `true` if token was successfully cancelled.
479
+ */
480
+ bool ddprof_ffi_CancellationToken_cancel(struct ddprof_ffi_CancellationToken *cancel);
481
+
482
+ void ddprof_ffi_CancellationToken_drop(struct ddprof_ffi_CancellationToken *_cancel);
483
+
484
+ void ddprof_ffi_SendResult_drop(struct ddprof_ffi_SendResult result);
485
+
486
+ /**
487
+ * Create a new profile with the given sample types. Must call
488
+ * `ddprof_ffi_Profile_free` when you are done with the profile.
489
+ *
490
+ * # Arguments
491
+ * * `sample_types`
492
+ * * `period` - Optional period of the profile. Passing None/null translates to zero values.
493
+ * * `start_time` - Optional time the profile started at. Passing None/null will use the current
494
+ * time.
495
+ *
496
+ * # Safety
497
+ * All slices must be have pointers that are suitably aligned for their type
498
+ * and must have the correct number of elements for the slice.
499
+ */
500
+ __attribute__((warn_unused_result))
501
+ struct ddprof_ffi_Profile *ddprof_ffi_Profile_new(struct ddprof_ffi_Slice_value_type sample_types,
502
+ const struct ddprof_ffi_Period *period,
503
+ const struct ddprof_ffi_Timespec *start_time);
504
+
505
+ /**
506
+ * # Safety
507
+ * The `profile` must point to an object created by another FFI routine in this
508
+ * module, such as `ddprof_ffi_Profile_with_sample_types`.
509
+ */
510
+ void ddprof_ffi_Profile_free(struct ddprof_ffi_Profile *_profile);
511
+
512
+ /**
513
+ * # Safety
514
+ * The `profile` ptr must point to a valid Profile object created by this
515
+ * module. All pointers inside the `sample` need to be valid for the duration
516
+ * of this call.
517
+ * This call is _NOT_ thread-safe.
518
+ */
519
+ uint64_t ddprof_ffi_Profile_add(struct ddprof_ffi_Profile *profile,
520
+ struct ddprof_ffi_Sample sample);
521
+
522
+ /**
523
+ * Serialize the aggregated profile. Don't forget to clean up the result by
524
+ * calling ddprof_ffi_SerializeResult_drop.
525
+ *
526
+ * # Arguments
527
+ * * `profile` - a reference to the profile being serialized.
528
+ * * `end_time` - optional end time of the profile. If None/null is passed, the current time will
529
+ * be used.
530
+ * * `duration_nanos` - Optional duration of the profile. Passing None or a negative duration will
531
+ * mean the duration will based on the end time minus the start time, but
532
+ * under anomalous conditions this may fail as system clocks can be adjusted,
533
+ * or the programmer accidentally passed an earlier time. The duration of
534
+ * the serialized profile will be set to zero for these cases.
535
+ *
536
+ * # Safety
537
+ * The `profile` must point to a valid profile object.
538
+ * The `end_time` must be null or otherwise point to a valid TimeSpec object.
539
+ * The `duration_nanos` must be null or otherwise point to a valid i64.
540
+ */
541
+ struct ddprof_ffi_SerializeResult ddprof_ffi_Profile_serialize(const struct ddprof_ffi_Profile *profile,
542
+ const struct ddprof_ffi_Timespec *end_time,
543
+ const int64_t *duration_nanos);
544
+
545
+ void ddprof_ffi_SerializeResult_drop(struct ddprof_ffi_SerializeResult _result);
546
+
547
+ __attribute__((warn_unused_result))
548
+ struct ddprof_ffi_Slice_u8 ddprof_ffi_Vec_u8_as_slice(const struct ddprof_ffi_Vec_u8 *vec);
549
+
550
+ /**
551
+ * Resets all data in `profile` except the sample types and period. Returns
552
+ * true if it successfully reset the profile and false otherwise. The profile
553
+ * remains valid if false is returned.
554
+ *
555
+ * # Arguments
556
+ * * `profile` - A mutable reference to the profile to be reset.
557
+ * * `start_time` - The time of the profile (after reset). Pass None/null to use the current time.
558
+ *
559
+ * # Safety
560
+ * The `profile` must meet all the requirements of a mutable reference to the profile. Given this
561
+ * can be called across an FFI boundary, the compiler cannot enforce this.
562
+ * If `time` is not null, it must point to a valid Timespec object.
563
+ */
564
+ bool ddprof_ffi_Profile_reset(struct ddprof_ffi_Profile *profile,
565
+ const struct ddprof_ffi_Timespec *start_time);
566
+
567
+ __attribute__((warn_unused_result)) struct ddprof_ffi_Vec_tag ddprof_ffi_Vec_tag_new(void);
568
+
569
+ void ddprof_ffi_Vec_tag_drop(struct ddprof_ffi_Vec_tag);
570
+
571
+ void ddprof_ffi_PushTagResult_drop(struct ddprof_ffi_PushTagResult);
572
+
573
+ /**
574
+ * Creates a new Tag from the provided `key` and `value` by doing a utf8
575
+ * lossy conversion, and pushes into the `vec`. The strings `key` and `value`
576
+ * are cloned to avoid FFI lifetime issues.
577
+ *
578
+ * # Safety
579
+ * The `vec` must be a valid reference.
580
+ * The CharSlices `key` and `value` must point to at least many bytes as their
581
+ * `.len` properties claim.
582
+ */
583
+ __attribute__((warn_unused_result))
584
+ struct ddprof_ffi_PushTagResult ddprof_ffi_Vec_tag_push(struct ddprof_ffi_Vec_tag *vec,
585
+ ddprof_ffi_CharSlice key,
586
+ ddprof_ffi_CharSlice value);
587
+
588
+ __attribute__((warn_unused_result))
589
+ struct ddprof_ffi_ParseTagsResult ddprof_ffi_Vec_tag_parse(ddprof_ffi_CharSlice string);
590
+
591
+ #endif /* DDPROF_FFI_H */
@@ -0,0 +1,17 @@
1
+ # Unless explicitly stated otherwise all files in this repository are licensed
2
+ # under the Apache License Version 2.0. This product includes software
3
+ # developed at Datadog (https://www.datadoghq.com/). Copyright 2021-Present
4
+ # Datadog, Inc.
5
+
6
+ prefix=${pcfiledir}/../..
7
+ exec_prefix=${prefix}
8
+ libdir=${exec_prefix}/lib
9
+ includedir=${prefix}/include
10
+
11
+ Name: ddprof_ffi
12
+ Description: Contains common code used to implement Datadog's Continuous Profilers. (Dynamic linking variant, sets rpath)
13
+ Version: 0.7.0-rc.1
14
+ Requires:
15
+ Libs: -L${libdir} -lddprof_ffi -Wl,-rpath,${libdir}
16
+ Libs.private:
17
+ Cflags: -I${includedir}
metadata ADDED
@@ -0,0 +1,61 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: libdatadog
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.7.0.1.0.rc1
5
+ platform: x86_64-linux
6
+ authors:
7
+ - Datadog, Inc.
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-05-31 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: libdatadog is a Rust-based utility library for Datadog's ddtrace gem.
14
+ email:
15
+ - dev@datadoghq.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/libdatadog.rb
21
+ - lib/libdatadog/version.rb
22
+ - vendor/libdatadog-0.7.0/x86_64-linux-musl/libdatadog-x86_64-alpine-linux-musl/LICENSE
23
+ - vendor/libdatadog-0.7.0/x86_64-linux-musl/libdatadog-x86_64-alpine-linux-musl/LICENSE-3rdparty.yml
24
+ - vendor/libdatadog-0.7.0/x86_64-linux-musl/libdatadog-x86_64-alpine-linux-musl/NOTICE
25
+ - vendor/libdatadog-0.7.0/x86_64-linux-musl/libdatadog-x86_64-alpine-linux-musl/include/ddprof/ffi.h
26
+ - vendor/libdatadog-0.7.0/x86_64-linux-musl/libdatadog-x86_64-alpine-linux-musl/lib/libddprof_ffi.so
27
+ - vendor/libdatadog-0.7.0/x86_64-linux-musl/libdatadog-x86_64-alpine-linux-musl/lib/pkgconfig/ddprof_ffi_with_rpath.pc
28
+ - vendor/libdatadog-0.7.0/x86_64-linux/libdatadog-x86_64-unknown-linux-gnu/LICENSE
29
+ - vendor/libdatadog-0.7.0/x86_64-linux/libdatadog-x86_64-unknown-linux-gnu/LICENSE-3rdparty.yml
30
+ - vendor/libdatadog-0.7.0/x86_64-linux/libdatadog-x86_64-unknown-linux-gnu/NOTICE
31
+ - vendor/libdatadog-0.7.0/x86_64-linux/libdatadog-x86_64-unknown-linux-gnu/include/ddprof/ffi.h
32
+ - vendor/libdatadog-0.7.0/x86_64-linux/libdatadog-x86_64-unknown-linux-gnu/lib/libddprof_ffi.so
33
+ - vendor/libdatadog-0.7.0/x86_64-linux/libdatadog-x86_64-unknown-linux-gnu/lib/pkgconfig/ddprof_ffi_with_rpath.pc
34
+ homepage: https://docs.datadoghq.com/tracing/
35
+ licenses:
36
+ - Apache-2.0
37
+ metadata:
38
+ allowed_push_host: https://rubygems.org
39
+ homepage_uri: https://docs.datadoghq.com/tracing/
40
+ source_code_uri: https://github.com/datadog/libdatadog/tree/main/ruby
41
+ rubygems_mfa_required: 'true'
42
+ post_install_message:
43
+ rdoc_options: []
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: 2.1.0
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">"
54
+ - !ruby/object:Gem::Version
55
+ version: 1.3.1
56
+ requirements: []
57
+ rubygems_version: 3.3.7
58
+ signing_key:
59
+ specification_version: 4
60
+ summary: Library of common code used by Datadog Continuous Profiler for Ruby
61
+ test_files: []