libdatadog 0.7.0.1.1-x86_64-linux → 0.8.0.1.0-x86_64-linux
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/libdatadog/version.rb +2 -2
- data/lib/libdatadog.rb +1 -1
- data/vendor/{libdatadog-0.7.0 → libdatadog-0.8.0}/x86_64-linux/libdatadog-x86_64-unknown-linux-gnu/LICENSE +0 -0
- data/vendor/{libdatadog-0.7.0/x86_64-linux-musl/libdatadog-x86_64-alpine-linux-musl → libdatadog-0.8.0/x86_64-linux/libdatadog-x86_64-unknown-linux-gnu}/LICENSE-3rdparty.yml +7 -143
- data/vendor/{libdatadog-0.7.0 → libdatadog-0.8.0}/x86_64-linux/libdatadog-x86_64-unknown-linux-gnu/NOTICE +0 -0
- data/vendor/libdatadog-0.8.0/x86_64-linux/libdatadog-x86_64-unknown-linux-gnu/include/datadog/common.h +430 -0
- data/vendor/libdatadog-0.8.0/x86_64-linux/libdatadog-x86_64-unknown-linux-gnu/include/datadog/profiling.h +212 -0
- data/vendor/libdatadog-0.8.0/x86_64-linux/libdatadog-x86_64-unknown-linux-gnu/lib/libdatadog_profiling.so +0 -0
- data/vendor/{libdatadog-0.7.0/x86_64-linux/libdatadog-x86_64-unknown-linux-gnu/lib/pkgconfig/ddprof_ffi_with_rpath.pc → libdatadog-0.8.0/x86_64-linux/libdatadog-x86_64-unknown-linux-gnu/lib/pkgconfig/datadog_profiling_with_rpath.pc} +3 -3
- data/vendor/{libdatadog-0.7.0 → libdatadog-0.8.0}/x86_64-linux-musl/libdatadog-x86_64-alpine-linux-musl/LICENSE +0 -0
- data/vendor/{libdatadog-0.7.0/x86_64-linux/libdatadog-x86_64-unknown-linux-gnu → libdatadog-0.8.0/x86_64-linux-musl/libdatadog-x86_64-alpine-linux-musl}/LICENSE-3rdparty.yml +7 -143
- data/vendor/{libdatadog-0.7.0 → libdatadog-0.8.0}/x86_64-linux-musl/libdatadog-x86_64-alpine-linux-musl/NOTICE +0 -0
- data/vendor/libdatadog-0.8.0/x86_64-linux-musl/libdatadog-x86_64-alpine-linux-musl/include/datadog/common.h +430 -0
- data/vendor/libdatadog-0.8.0/x86_64-linux-musl/libdatadog-x86_64-alpine-linux-musl/include/datadog/profiling.h +212 -0
- data/vendor/libdatadog-0.8.0/x86_64-linux-musl/libdatadog-x86_64-alpine-linux-musl/lib/libdatadog_profiling.so +0 -0
- data/vendor/{libdatadog-0.7.0/x86_64-linux-musl/libdatadog-x86_64-alpine-linux-musl/lib/pkgconfig/ddprof_ffi_with_rpath.pc → libdatadog-0.8.0/x86_64-linux-musl/libdatadog-x86_64-alpine-linux-musl/lib/pkgconfig/datadog_profiling_with_rpath.pc} +3 -3
- metadata +16 -14
- data/vendor/libdatadog-0.7.0/x86_64-linux/libdatadog-x86_64-unknown-linux-gnu/include/ddprof/ffi.h +0 -591
- data/vendor/libdatadog-0.7.0/x86_64-linux/libdatadog-x86_64-unknown-linux-gnu/lib/libddprof_ffi.so +0 -0
- data/vendor/libdatadog-0.7.0/x86_64-linux-musl/libdatadog-x86_64-alpine-linux-musl/include/ddprof/ffi.h +0 -591
- data/vendor/libdatadog-0.7.0/x86_64-linux-musl/libdatadog-x86_64-alpine-linux-musl/lib/libddprof_ffi.so +0 -0
File without changes
|
@@ -0,0 +1,430 @@
|
|
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 DDOG_COMMON_H
|
6
|
+
#define DDOG_COMMON_H
|
7
|
+
|
8
|
+
#include <stdbool.h>
|
9
|
+
#include <stddef.h>
|
10
|
+
#include <stdint.h>
|
11
|
+
|
12
|
+
#if defined(_MSC_VER)
|
13
|
+
#define DDOG_CHARSLICE_C(string) \
|
14
|
+
/* NOTE: Compilation fails if you pass in a char* instead of a literal */ {.ptr = "" string, .len = sizeof(string) - 1}
|
15
|
+
#else
|
16
|
+
#define DDOG_CHARSLICE_C(string) \
|
17
|
+
/* NOTE: Compilation fails if you pass in a char* instead of a literal */ ((ddog_CharSlice){ .ptr = "" string, .len = sizeof(string) - 1 })
|
18
|
+
#endif
|
19
|
+
|
20
|
+
#if defined(__cplusplus) && (__cplusplus >= 201703L)
|
21
|
+
# define DDOG_CHECK_RETURN [[nodiscard]]
|
22
|
+
#elif defined(_Check_return_) /* SAL */
|
23
|
+
# define DDOG_CHECK_RETURN _Check_return_
|
24
|
+
#elif (defined(__has_attribute) && __has_attribute(warn_unused_result)) || \
|
25
|
+
(defined(__GNUC__) && (__GNUC__ >= 4))
|
26
|
+
# define DDOG_CHECK_RETURN __attribute__((__warn_unused_result__))
|
27
|
+
#else
|
28
|
+
# define DDOG_CHECK_RETURN
|
29
|
+
#endif
|
30
|
+
|
31
|
+
typedef struct ddog_Tag ddog_Tag;
|
32
|
+
|
33
|
+
/**
|
34
|
+
* Holds the raw parts of a Rust Vec; it should only be created from Rust,
|
35
|
+
* never from C.
|
36
|
+
* The names ptr and len were chosen to minimize conversion from a previous
|
37
|
+
* Buffer type which this has replaced to become more general.
|
38
|
+
*/
|
39
|
+
typedef struct ddog_Vec_tag {
|
40
|
+
const struct ddog_Tag *ptr;
|
41
|
+
uintptr_t len;
|
42
|
+
uintptr_t capacity;
|
43
|
+
} ddog_Vec_tag;
|
44
|
+
|
45
|
+
/**
|
46
|
+
* Holds the raw parts of a Rust Vec; it should only be created from Rust,
|
47
|
+
* never from C.
|
48
|
+
* The names ptr and len were chosen to minimize conversion from a previous
|
49
|
+
* Buffer type which this has replaced to become more general.
|
50
|
+
*/
|
51
|
+
typedef struct ddog_Vec_u8 {
|
52
|
+
const uint8_t *ptr;
|
53
|
+
uintptr_t len;
|
54
|
+
uintptr_t capacity;
|
55
|
+
} ddog_Vec_u8;
|
56
|
+
|
57
|
+
typedef enum ddog_PushTagResult_Tag {
|
58
|
+
DDOG_PUSH_TAG_RESULT_OK,
|
59
|
+
DDOG_PUSH_TAG_RESULT_ERR,
|
60
|
+
} ddog_PushTagResult_Tag;
|
61
|
+
|
62
|
+
typedef struct ddog_PushTagResult {
|
63
|
+
ddog_PushTagResult_Tag tag;
|
64
|
+
union {
|
65
|
+
struct {
|
66
|
+
struct ddog_Vec_u8 err;
|
67
|
+
};
|
68
|
+
};
|
69
|
+
} ddog_PushTagResult;
|
70
|
+
|
71
|
+
/**
|
72
|
+
* Remember, the data inside of each member is potentially coming from FFI,
|
73
|
+
* so every operation on it is unsafe!
|
74
|
+
*/
|
75
|
+
typedef struct ddog_Slice_c_char {
|
76
|
+
const char *ptr;
|
77
|
+
uintptr_t len;
|
78
|
+
} ddog_Slice_c_char;
|
79
|
+
|
80
|
+
typedef struct ddog_Slice_c_char ddog_CharSlice;
|
81
|
+
|
82
|
+
typedef struct ddog_ParseTagsResult {
|
83
|
+
struct ddog_Vec_tag tags;
|
84
|
+
struct ddog_Vec_u8 *error_message;
|
85
|
+
} ddog_ParseTagsResult;
|
86
|
+
|
87
|
+
typedef struct ddog_CancellationToken ddog_CancellationToken;
|
88
|
+
|
89
|
+
typedef struct ddog_Profile ddog_Profile;
|
90
|
+
|
91
|
+
typedef struct ddog_ProfileExporter ddog_ProfileExporter;
|
92
|
+
|
93
|
+
/**
|
94
|
+
* This type only exists to workaround a bug in cbindgen; may be removed in the
|
95
|
+
* future.
|
96
|
+
*/
|
97
|
+
typedef struct ddog_Request ddog_Request;
|
98
|
+
|
99
|
+
typedef enum ddog_NewProfileExporterResult_Tag {
|
100
|
+
DDOG_NEW_PROFILE_EXPORTER_RESULT_OK,
|
101
|
+
DDOG_NEW_PROFILE_EXPORTER_RESULT_ERR,
|
102
|
+
} ddog_NewProfileExporterResult_Tag;
|
103
|
+
|
104
|
+
typedef struct ddog_NewProfileExporterResult {
|
105
|
+
ddog_NewProfileExporterResult_Tag tag;
|
106
|
+
union {
|
107
|
+
struct {
|
108
|
+
struct ddog_ProfileExporter *ok;
|
109
|
+
};
|
110
|
+
struct {
|
111
|
+
struct ddog_Vec_u8 err;
|
112
|
+
};
|
113
|
+
};
|
114
|
+
} ddog_NewProfileExporterResult;
|
115
|
+
|
116
|
+
typedef enum ddog_Endpoint_Tag {
|
117
|
+
DDOG_ENDPOINT_AGENT,
|
118
|
+
DDOG_ENDPOINT_AGENTLESS,
|
119
|
+
} ddog_Endpoint_Tag;
|
120
|
+
|
121
|
+
typedef struct ddog_Endpoint_ddog_Agentless_Body {
|
122
|
+
ddog_CharSlice _0;
|
123
|
+
ddog_CharSlice _1;
|
124
|
+
} ddog_Endpoint_ddog_Agentless_Body;
|
125
|
+
|
126
|
+
typedef struct ddog_Endpoint {
|
127
|
+
ddog_Endpoint_Tag tag;
|
128
|
+
union {
|
129
|
+
struct {
|
130
|
+
ddog_CharSlice agent;
|
131
|
+
};
|
132
|
+
ddog_Endpoint_ddog_Agentless_Body AGENTLESS;
|
133
|
+
};
|
134
|
+
} ddog_Endpoint;
|
135
|
+
|
136
|
+
/**
|
137
|
+
* Represents time since the Unix Epoch in seconds plus nanoseconds.
|
138
|
+
*/
|
139
|
+
typedef struct ddog_Timespec {
|
140
|
+
int64_t seconds;
|
141
|
+
uint32_t nanoseconds;
|
142
|
+
} ddog_Timespec;
|
143
|
+
|
144
|
+
/**
|
145
|
+
* Remember, the data inside of each member is potentially coming from FFI,
|
146
|
+
* so every operation on it is unsafe!
|
147
|
+
*/
|
148
|
+
typedef struct ddog_Slice_u8 {
|
149
|
+
const uint8_t *ptr;
|
150
|
+
uintptr_t len;
|
151
|
+
} ddog_Slice_u8;
|
152
|
+
|
153
|
+
/**
|
154
|
+
* Use to represent bytes -- does not need to be valid UTF-8.
|
155
|
+
*/
|
156
|
+
typedef struct ddog_Slice_u8 ddog_ByteSlice;
|
157
|
+
|
158
|
+
typedef struct ddog_File {
|
159
|
+
ddog_CharSlice name;
|
160
|
+
ddog_ByteSlice file;
|
161
|
+
} ddog_File;
|
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 ddog_Slice_file {
|
168
|
+
const struct ddog_File *ptr;
|
169
|
+
uintptr_t len;
|
170
|
+
} ddog_Slice_file;
|
171
|
+
|
172
|
+
typedef struct ddog_HttpStatus {
|
173
|
+
uint16_t code;
|
174
|
+
} ddog_HttpStatus;
|
175
|
+
|
176
|
+
typedef enum ddog_SendResult_Tag {
|
177
|
+
DDOG_SEND_RESULT_HTTP_RESPONSE,
|
178
|
+
DDOG_SEND_RESULT_ERR,
|
179
|
+
} ddog_SendResult_Tag;
|
180
|
+
|
181
|
+
typedef struct ddog_SendResult {
|
182
|
+
ddog_SendResult_Tag tag;
|
183
|
+
union {
|
184
|
+
struct {
|
185
|
+
struct ddog_HttpStatus http_response;
|
186
|
+
};
|
187
|
+
struct {
|
188
|
+
struct ddog_Vec_u8 err;
|
189
|
+
};
|
190
|
+
};
|
191
|
+
} ddog_SendResult;
|
192
|
+
|
193
|
+
typedef struct ddog_ValueType {
|
194
|
+
ddog_CharSlice type_;
|
195
|
+
ddog_CharSlice unit;
|
196
|
+
} ddog_ValueType;
|
197
|
+
|
198
|
+
/**
|
199
|
+
* Remember, the data inside of each member is potentially coming from FFI,
|
200
|
+
* so every operation on it is unsafe!
|
201
|
+
*/
|
202
|
+
typedef struct ddog_Slice_value_type {
|
203
|
+
const struct ddog_ValueType *ptr;
|
204
|
+
uintptr_t len;
|
205
|
+
} ddog_Slice_value_type;
|
206
|
+
|
207
|
+
typedef struct ddog_Period {
|
208
|
+
struct ddog_ValueType type_;
|
209
|
+
int64_t value;
|
210
|
+
} ddog_Period;
|
211
|
+
|
212
|
+
typedef struct ddog_Mapping {
|
213
|
+
/**
|
214
|
+
* Address at which the binary (or DLL) is loaded into memory.
|
215
|
+
*/
|
216
|
+
uint64_t memory_start;
|
217
|
+
/**
|
218
|
+
* The limit of the address range occupied by this mapping.
|
219
|
+
*/
|
220
|
+
uint64_t memory_limit;
|
221
|
+
/**
|
222
|
+
* Offset in the binary that corresponds to the first mapped address.
|
223
|
+
*/
|
224
|
+
uint64_t file_offset;
|
225
|
+
/**
|
226
|
+
* The object this entry is loaded from. This can be a filename on
|
227
|
+
* disk for the main binary and shared libraries, or virtual
|
228
|
+
* abstractions like "[vdso]".
|
229
|
+
*/
|
230
|
+
ddog_CharSlice filename;
|
231
|
+
/**
|
232
|
+
* A string that uniquely identifies a particular program version
|
233
|
+
* with high probability. E.g., for binaries generated by GNU tools,
|
234
|
+
* it could be the contents of the .note.gnu.build-id field.
|
235
|
+
*/
|
236
|
+
ddog_CharSlice build_id;
|
237
|
+
} ddog_Mapping;
|
238
|
+
|
239
|
+
typedef struct ddog_Function {
|
240
|
+
/**
|
241
|
+
* Name of the function, in human-readable form if available.
|
242
|
+
*/
|
243
|
+
ddog_CharSlice name;
|
244
|
+
/**
|
245
|
+
* Name of the function, as identified by the system.
|
246
|
+
* For instance, it can be a C++ mangled name.
|
247
|
+
*/
|
248
|
+
ddog_CharSlice system_name;
|
249
|
+
/**
|
250
|
+
* Source file containing the function.
|
251
|
+
*/
|
252
|
+
ddog_CharSlice filename;
|
253
|
+
/**
|
254
|
+
* Line number in source file.
|
255
|
+
*/
|
256
|
+
int64_t start_line;
|
257
|
+
} ddog_Function;
|
258
|
+
|
259
|
+
typedef struct ddog_Line {
|
260
|
+
/**
|
261
|
+
* The corresponding profile.Function for this line.
|
262
|
+
*/
|
263
|
+
struct ddog_Function function;
|
264
|
+
/**
|
265
|
+
* Line number in source code.
|
266
|
+
*/
|
267
|
+
int64_t line;
|
268
|
+
} ddog_Line;
|
269
|
+
|
270
|
+
/**
|
271
|
+
* Remember, the data inside of each member is potentially coming from FFI,
|
272
|
+
* so every operation on it is unsafe!
|
273
|
+
*/
|
274
|
+
typedef struct ddog_Slice_line {
|
275
|
+
const struct ddog_Line *ptr;
|
276
|
+
uintptr_t len;
|
277
|
+
} ddog_Slice_line;
|
278
|
+
|
279
|
+
typedef struct ddog_Location {
|
280
|
+
/**
|
281
|
+
* todo: how to handle unknown mapping?
|
282
|
+
*/
|
283
|
+
struct ddog_Mapping mapping;
|
284
|
+
/**
|
285
|
+
* The instruction address for this location, if available. It
|
286
|
+
* should be within [Mapping.memory_start...Mapping.memory_limit]
|
287
|
+
* for the corresponding mapping. A non-leaf address may be in the
|
288
|
+
* middle of a call instruction. It is up to display tools to find
|
289
|
+
* the beginning of the instruction if necessary.
|
290
|
+
*/
|
291
|
+
uint64_t address;
|
292
|
+
/**
|
293
|
+
* Multiple line indicates this location has inlined functions,
|
294
|
+
* where the last entry represents the caller into which the
|
295
|
+
* preceding entries were inlined.
|
296
|
+
*
|
297
|
+
* E.g., if memcpy() is inlined into printf:
|
298
|
+
* line[0].function_name == "memcpy"
|
299
|
+
* line[1].function_name == "printf"
|
300
|
+
*/
|
301
|
+
struct ddog_Slice_line lines;
|
302
|
+
/**
|
303
|
+
* Provides an indication that multiple symbols map to this location's
|
304
|
+
* address, for example due to identical code folding by the linker. In that
|
305
|
+
* case the line information above represents one of the multiple
|
306
|
+
* symbols. This field must be recomputed when the symbolization state of the
|
307
|
+
* profile changes.
|
308
|
+
*/
|
309
|
+
bool is_folded;
|
310
|
+
} ddog_Location;
|
311
|
+
|
312
|
+
/**
|
313
|
+
* Remember, the data inside of each member is potentially coming from FFI,
|
314
|
+
* so every operation on it is unsafe!
|
315
|
+
*/
|
316
|
+
typedef struct ddog_Slice_location {
|
317
|
+
const struct ddog_Location *ptr;
|
318
|
+
uintptr_t len;
|
319
|
+
} ddog_Slice_location;
|
320
|
+
|
321
|
+
/**
|
322
|
+
* Remember, the data inside of each member is potentially coming from FFI,
|
323
|
+
* so every operation on it is unsafe!
|
324
|
+
*/
|
325
|
+
typedef struct ddog_Slice_i64 {
|
326
|
+
const int64_t *ptr;
|
327
|
+
uintptr_t len;
|
328
|
+
} ddog_Slice_i64;
|
329
|
+
|
330
|
+
typedef struct ddog_Label {
|
331
|
+
ddog_CharSlice key;
|
332
|
+
/**
|
333
|
+
* At most one of the following must be present
|
334
|
+
*/
|
335
|
+
ddog_CharSlice str;
|
336
|
+
int64_t num;
|
337
|
+
/**
|
338
|
+
* Should only be present when num is present.
|
339
|
+
* Specifies the units of num.
|
340
|
+
* Use arbitrary string (for example, "requests") as a custom count unit.
|
341
|
+
* If no unit is specified, consumer may apply heuristic to deduce the unit.
|
342
|
+
* Consumers may also interpret units like "bytes" and "kilobytes" as memory
|
343
|
+
* units and units like "seconds" and "nanoseconds" as time units,
|
344
|
+
* and apply appropriate unit conversions to these.
|
345
|
+
*/
|
346
|
+
ddog_CharSlice num_unit;
|
347
|
+
} ddog_Label;
|
348
|
+
|
349
|
+
/**
|
350
|
+
* Remember, the data inside of each member is potentially coming from FFI,
|
351
|
+
* so every operation on it is unsafe!
|
352
|
+
*/
|
353
|
+
typedef struct ddog_Slice_label {
|
354
|
+
const struct ddog_Label *ptr;
|
355
|
+
uintptr_t len;
|
356
|
+
} ddog_Slice_label;
|
357
|
+
|
358
|
+
typedef struct ddog_Sample {
|
359
|
+
/**
|
360
|
+
* The leaf is at locations[0].
|
361
|
+
*/
|
362
|
+
struct ddog_Slice_location locations;
|
363
|
+
/**
|
364
|
+
* The type and unit of each value is defined by the corresponding
|
365
|
+
* entry in Profile.sample_type. All samples must have the same
|
366
|
+
* number of values, the same as the length of Profile.sample_type.
|
367
|
+
* When aggregating multiple samples into a single sample, the
|
368
|
+
* result has a list of values that is the element-wise sum of the
|
369
|
+
* lists of the originals.
|
370
|
+
*/
|
371
|
+
struct ddog_Slice_i64 values;
|
372
|
+
/**
|
373
|
+
* label includes additional context for this sample. It can include
|
374
|
+
* things like a thread id, allocation size, etc
|
375
|
+
*/
|
376
|
+
struct ddog_Slice_label labels;
|
377
|
+
} ddog_Sample;
|
378
|
+
|
379
|
+
typedef struct ddog_EncodedProfile {
|
380
|
+
struct ddog_Timespec start;
|
381
|
+
struct ddog_Timespec end;
|
382
|
+
struct ddog_Vec_u8 buffer;
|
383
|
+
} ddog_EncodedProfile;
|
384
|
+
|
385
|
+
typedef enum ddog_SerializeResult_Tag {
|
386
|
+
DDOG_SERIALIZE_RESULT_OK,
|
387
|
+
DDOG_SERIALIZE_RESULT_ERR,
|
388
|
+
} ddog_SerializeResult_Tag;
|
389
|
+
|
390
|
+
typedef struct ddog_SerializeResult {
|
391
|
+
ddog_SerializeResult_Tag tag;
|
392
|
+
union {
|
393
|
+
struct {
|
394
|
+
struct ddog_EncodedProfile ok;
|
395
|
+
};
|
396
|
+
struct {
|
397
|
+
struct ddog_Vec_u8 err;
|
398
|
+
};
|
399
|
+
};
|
400
|
+
} ddog_SerializeResult;
|
401
|
+
|
402
|
+
DDOG_CHECK_RETURN struct ddog_Vec_tag ddog_Vec_tag_new(void);
|
403
|
+
|
404
|
+
void ddog_Vec_tag_drop(struct ddog_Vec_tag);
|
405
|
+
|
406
|
+
void ddog_PushTagResult_drop(struct ddog_PushTagResult);
|
407
|
+
|
408
|
+
/**
|
409
|
+
* Creates a new Tag from the provided `key` and `value` by doing a utf8
|
410
|
+
* lossy conversion, and pushes into the `vec`. The strings `key` and `value`
|
411
|
+
* are cloned to avoid FFI lifetime issues.
|
412
|
+
*
|
413
|
+
* # Safety
|
414
|
+
* The `vec` must be a valid reference.
|
415
|
+
* The CharSlices `key` and `value` must point to at least many bytes as their
|
416
|
+
* `.len` properties claim.
|
417
|
+
*/
|
418
|
+
DDOG_CHECK_RETURN
|
419
|
+
struct ddog_PushTagResult ddog_Vec_tag_push(struct ddog_Vec_tag *vec,
|
420
|
+
ddog_CharSlice key,
|
421
|
+
ddog_CharSlice value);
|
422
|
+
|
423
|
+
/**
|
424
|
+
* # Safety
|
425
|
+
* The `string`'s .ptr must point to a valid object at least as large as its
|
426
|
+
* .len property.
|
427
|
+
*/
|
428
|
+
DDOG_CHECK_RETURN struct ddog_ParseTagsResult ddog_Vec_tag_parse(ddog_CharSlice string);
|
429
|
+
|
430
|
+
#endif /* DDOG_COMMON_H */
|
@@ -0,0 +1,212 @@
|
|
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 DDOG_PROFILING_H
|
6
|
+
#define DDOG_PROFILING_H
|
7
|
+
|
8
|
+
#include <stdbool.h>
|
9
|
+
#include <stddef.h>
|
10
|
+
#include <stdint.h>
|
11
|
+
#include "datadog/common.h"
|
12
|
+
|
13
|
+
void ddog_NewProfileExporterResult_drop(struct ddog_NewProfileExporterResult result);
|
14
|
+
|
15
|
+
/**
|
16
|
+
* Creates an endpoint that uses the agent.
|
17
|
+
* # Arguments
|
18
|
+
* * `base_url` - Contains a URL with scheme, host, and port e.g. "https://agent:8126/".
|
19
|
+
*/
|
20
|
+
struct ddog_Endpoint ddog_Endpoint_agent(ddog_CharSlice base_url);
|
21
|
+
|
22
|
+
/**
|
23
|
+
* Creates an endpoint that uses the Datadog intake directly aka agentless.
|
24
|
+
* # Arguments
|
25
|
+
* * `site` - Contains a host and port e.g. "datadoghq.com".
|
26
|
+
* * `api_key` - Contains the Datadog API key.
|
27
|
+
*/
|
28
|
+
struct ddog_Endpoint ddog_Endpoint_agentless(ddog_CharSlice site, ddog_CharSlice api_key);
|
29
|
+
|
30
|
+
DDOG_CHECK_RETURN
|
31
|
+
struct ddog_NewProfileExporterResult ddog_ProfileExporter_new(ddog_CharSlice family,
|
32
|
+
const struct ddog_Vec_tag *tags,
|
33
|
+
struct ddog_Endpoint endpoint);
|
34
|
+
|
35
|
+
void ddog_ProfileExporter_delete(struct ddog_ProfileExporter *exporter);
|
36
|
+
|
37
|
+
/**
|
38
|
+
* Builds a Request object based on the profile data supplied.
|
39
|
+
*
|
40
|
+
* # Safety
|
41
|
+
* The `exporter` and the files inside of the `files` slice need to have been
|
42
|
+
* created by this module.
|
43
|
+
*/
|
44
|
+
struct ddog_Request *ddog_ProfileExporter_build(struct ddog_ProfileExporter *exporter,
|
45
|
+
struct ddog_Timespec start,
|
46
|
+
struct ddog_Timespec end,
|
47
|
+
struct ddog_Slice_file files,
|
48
|
+
const struct ddog_Vec_tag *additional_tags,
|
49
|
+
uint64_t timeout_ms);
|
50
|
+
|
51
|
+
/**
|
52
|
+
* Sends the request, returning the HttpStatus.
|
53
|
+
*
|
54
|
+
* # Arguments
|
55
|
+
* * `exporter` - borrows the exporter for sending the request
|
56
|
+
* * `request` - takes ownership of the request
|
57
|
+
* * `cancel` - borrows the cancel, if any
|
58
|
+
*
|
59
|
+
* # Safety
|
60
|
+
* All non-null arguments MUST have been created by created by apis in this module.
|
61
|
+
*/
|
62
|
+
DDOG_CHECK_RETURN
|
63
|
+
struct ddog_SendResult ddog_ProfileExporter_send(struct ddog_ProfileExporter *exporter,
|
64
|
+
struct ddog_Request *request,
|
65
|
+
struct ddog_CancellationToken *cancel);
|
66
|
+
|
67
|
+
void ddog_Request_drop(struct ddog_Request *_request);
|
68
|
+
|
69
|
+
/**
|
70
|
+
* Can be passed as an argument to send and then be used to asynchronously cancel it from a different thread.
|
71
|
+
*/
|
72
|
+
DDOG_CHECK_RETURN
|
73
|
+
struct ddog_CancellationToken *ddog_CancellationToken_new(void);
|
74
|
+
|
75
|
+
/**
|
76
|
+
* A cloned CancellationToken is connected to the CancellationToken it was created from.
|
77
|
+
* Either the cloned or the original token can be used to cancel or provided as arguments to send.
|
78
|
+
* The useful part is that they have independent lifetimes and can be dropped separately.
|
79
|
+
*
|
80
|
+
* Thus, it's possible to do something like:
|
81
|
+
* ```c
|
82
|
+
* cancel_t1 = ddog_CancellationToken_new();
|
83
|
+
* cancel_t2 = ddog_CancellationToken_clone(cancel_t1);
|
84
|
+
*
|
85
|
+
* // On thread t1:
|
86
|
+
* ddog_ProfileExporter_send(..., cancel_t1);
|
87
|
+
* ddog_CancellationToken_drop(cancel_t1);
|
88
|
+
*
|
89
|
+
* // On thread t2:
|
90
|
+
* ddog_CancellationToken_cancel(cancel_t2);
|
91
|
+
* ddog_CancellationToken_drop(cancel_t2);
|
92
|
+
* ```
|
93
|
+
*
|
94
|
+
* Without clone, both t1 and t2 would need to synchronize to make sure neither was using the cancel
|
95
|
+
* before it could be dropped. With clone, there is no need for such synchronization, both threads
|
96
|
+
* have their own cancel and should drop that cancel after they are done with it.
|
97
|
+
*/
|
98
|
+
DDOG_CHECK_RETURN
|
99
|
+
struct ddog_CancellationToken *ddog_CancellationToken_clone(struct ddog_CancellationToken *cancel);
|
100
|
+
|
101
|
+
/**
|
102
|
+
* Cancel send that is being called in another thread with the given token.
|
103
|
+
* Note that cancellation is a terminal state; cancelling a token more than once does nothing.
|
104
|
+
* Returns `true` if token was successfully cancelled.
|
105
|
+
*/
|
106
|
+
bool ddog_CancellationToken_cancel(struct ddog_CancellationToken *cancel);
|
107
|
+
|
108
|
+
void ddog_CancellationToken_drop(struct ddog_CancellationToken *_cancel);
|
109
|
+
|
110
|
+
void ddog_SendResult_drop(struct ddog_SendResult result);
|
111
|
+
|
112
|
+
/**
|
113
|
+
* Create a new profile with the given sample types. Must call
|
114
|
+
* `ddog_Profile_free` when you are done with the profile.
|
115
|
+
*
|
116
|
+
* # Arguments
|
117
|
+
* * `sample_types`
|
118
|
+
* * `period` - Optional period of the profile. Passing None/null translates to zero values.
|
119
|
+
* * `start_time` - Optional time the profile started at. Passing None/null will use the current
|
120
|
+
* time.
|
121
|
+
*
|
122
|
+
* # Safety
|
123
|
+
* All slices must be have pointers that are suitably aligned for their type
|
124
|
+
* and must have the correct number of elements for the slice.
|
125
|
+
*/
|
126
|
+
DDOG_CHECK_RETURN
|
127
|
+
struct ddog_Profile *ddog_Profile_new(struct ddog_Slice_value_type sample_types,
|
128
|
+
const struct ddog_Period *period,
|
129
|
+
const struct ddog_Timespec *start_time);
|
130
|
+
|
131
|
+
/**
|
132
|
+
* # Safety
|
133
|
+
* The `profile` must point to an object created by another FFI routine in this
|
134
|
+
* module, such as `ddog_Profile_with_sample_types`.
|
135
|
+
*/
|
136
|
+
void ddog_Profile_free(struct ddog_Profile *_profile);
|
137
|
+
|
138
|
+
/**
|
139
|
+
* # Safety
|
140
|
+
* The `profile` ptr must point to a valid Profile object created by this
|
141
|
+
* module. All pointers inside the `sample` need to be valid for the duration
|
142
|
+
* of this call.
|
143
|
+
* This call is _NOT_ thread-safe.
|
144
|
+
*/
|
145
|
+
uint64_t ddog_Profile_add(struct ddog_Profile *profile, struct ddog_Sample sample);
|
146
|
+
|
147
|
+
/**
|
148
|
+
* Associate an endpoint to a given local root span id.
|
149
|
+
* During the serialization of the profile, an endpoint label will be added
|
150
|
+
* to all samples that contain a matching local root span id label.
|
151
|
+
*
|
152
|
+
* Note: calling this API causes the "trace endpoint" and "local root span id" strings
|
153
|
+
* to be interned, even if no matching sample is found.
|
154
|
+
*
|
155
|
+
* # Arguments
|
156
|
+
* * `profile` - a reference to the profile that will contain the samples.
|
157
|
+
* * `local_root_span_id` - the value of the local root span id label to look for.
|
158
|
+
* * `endpoint` - the value of the endpoint label to add for matching samples.
|
159
|
+
*
|
160
|
+
* # Safety
|
161
|
+
* The `profile` ptr must point to a valid Profile object created by this
|
162
|
+
* module.
|
163
|
+
* This call is _NOT_ thread-safe.
|
164
|
+
*/
|
165
|
+
void ddog_Profile_set_endpoint(struct ddog_Profile *profile,
|
166
|
+
ddog_CharSlice local_root_span_id,
|
167
|
+
ddog_CharSlice endpoint);
|
168
|
+
|
169
|
+
/**
|
170
|
+
* Serialize the aggregated profile. Don't forget to clean up the result by
|
171
|
+
* calling ddog_SerializeResult_drop.
|
172
|
+
*
|
173
|
+
* # Arguments
|
174
|
+
* * `profile` - a reference to the profile being serialized.
|
175
|
+
* * `end_time` - optional end time of the profile. If None/null is passed, the current time will
|
176
|
+
* be used.
|
177
|
+
* * `duration_nanos` - Optional duration of the profile. Passing None or a negative duration will
|
178
|
+
* mean the duration will based on the end time minus the start time, but
|
179
|
+
* under anomalous conditions this may fail as system clocks can be adjusted,
|
180
|
+
* or the programmer accidentally passed an earlier time. The duration of
|
181
|
+
* the serialized profile will be set to zero for these cases.
|
182
|
+
*
|
183
|
+
* # Safety
|
184
|
+
* The `profile` must point to a valid profile object.
|
185
|
+
* The `end_time` must be null or otherwise point to a valid TimeSpec object.
|
186
|
+
* The `duration_nanos` must be null or otherwise point to a valid i64.
|
187
|
+
*/
|
188
|
+
struct ddog_SerializeResult ddog_Profile_serialize(const struct ddog_Profile *profile,
|
189
|
+
const struct ddog_Timespec *end_time,
|
190
|
+
const int64_t *duration_nanos);
|
191
|
+
|
192
|
+
void ddog_SerializeResult_drop(struct ddog_SerializeResult _result);
|
193
|
+
|
194
|
+
DDOG_CHECK_RETURN struct ddog_Slice_u8 ddog_Vec_u8_as_slice(const struct ddog_Vec_u8 *vec);
|
195
|
+
|
196
|
+
/**
|
197
|
+
* Resets all data in `profile` except the sample types and period. Returns
|
198
|
+
* true if it successfully reset the profile and false otherwise. The profile
|
199
|
+
* remains valid if false is returned.
|
200
|
+
*
|
201
|
+
* # Arguments
|
202
|
+
* * `profile` - A mutable reference to the profile to be reset.
|
203
|
+
* * `start_time` - The time of the profile (after reset). Pass None/null to use the current time.
|
204
|
+
*
|
205
|
+
* # Safety
|
206
|
+
* The `profile` must meet all the requirements of a mutable reference to the profile. Given this
|
207
|
+
* can be called across an FFI boundary, the compiler cannot enforce this.
|
208
|
+
* If `time` is not null, it must point to a valid Timespec object.
|
209
|
+
*/
|
210
|
+
bool ddog_Profile_reset(struct ddog_Profile *profile, const struct ddog_Timespec *start_time);
|
211
|
+
|
212
|
+
#endif /* DDOG_PROFILING_H */
|
Binary file
|
@@ -8,10 +8,10 @@ exec_prefix=${prefix}
|
|
8
8
|
libdir=${exec_prefix}/lib
|
9
9
|
includedir=${prefix}/include
|
10
10
|
|
11
|
-
Name:
|
11
|
+
Name: datadog_profiling
|
12
12
|
Description: Contains common code used to implement Datadog's Continuous Profilers. (Dynamic linking variant, sets rpath)
|
13
|
-
Version:
|
13
|
+
Version: @DDog_VERSION@
|
14
14
|
Requires:
|
15
|
-
Libs: -L${libdir} -
|
15
|
+
Libs: -L${libdir} -ldatadog_profiling -Wl,-rpath,${libdir}
|
16
16
|
Libs.private:
|
17
17
|
Cflags: -I${includedir}
|