Skip to content

Commit ac0a7cc

Browse files
committed
Update libdatadog
1 parent 5400c59 commit ac0a7cc

3 files changed

Lines changed: 276 additions & 4 deletions

File tree

components-rs/common.h

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,59 @@ typedef enum ddog_LogLevel {
166166
DDOG_LOG_LEVEL_DEBUG,
167167
} ddog_LogLevel;
168168

169+
typedef enum ddog_MetricNamespace {
170+
DDOG_METRIC_NAMESPACE_TRACERS,
171+
DDOG_METRIC_NAMESPACE_PROFILERS,
172+
DDOG_METRIC_NAMESPACE_RUM,
173+
DDOG_METRIC_NAMESPACE_APPSEC,
174+
DDOG_METRIC_NAMESPACE_IDE_PLUGINS,
175+
DDOG_METRIC_NAMESPACE_LIVE_DEBUGGER,
176+
DDOG_METRIC_NAMESPACE_IAST,
177+
DDOG_METRIC_NAMESPACE_GENERAL,
178+
DDOG_METRIC_NAMESPACE_TELEMETRY,
179+
DDOG_METRIC_NAMESPACE_APM,
180+
DDOG_METRIC_NAMESPACE_SIDECAR,
181+
} ddog_MetricNamespace;
182+
183+
typedef enum ddog_MetricType {
184+
DDOG_METRIC_TYPE_GAUGE,
185+
DDOG_METRIC_TYPE_COUNT,
186+
DDOG_METRIC_TYPE_DISTRIBUTION,
187+
} ddog_MetricType;
188+
189+
typedef enum ddog_TelemetryWorkerBuilderBoolProperty {
190+
DDOG_TELEMETRY_WORKER_BUILDER_BOOL_PROPERTY_CONFIG_TELEMETRY_DEBUG_LOGGING_ENABLED,
191+
} ddog_TelemetryWorkerBuilderBoolProperty;
192+
193+
typedef enum ddog_TelemetryWorkerBuilderEndpointProperty {
194+
DDOG_TELEMETRY_WORKER_BUILDER_ENDPOINT_PROPERTY_CONFIG_ENDPOINT,
195+
} ddog_TelemetryWorkerBuilderEndpointProperty;
196+
197+
typedef enum ddog_TelemetryWorkerBuilderStrProperty {
198+
DDOG_TELEMETRY_WORKER_BUILDER_STR_PROPERTY_APPLICATION_SERVICE_VERSION,
199+
DDOG_TELEMETRY_WORKER_BUILDER_STR_PROPERTY_APPLICATION_ENV,
200+
DDOG_TELEMETRY_WORKER_BUILDER_STR_PROPERTY_APPLICATION_RUNTIME_NAME,
201+
DDOG_TELEMETRY_WORKER_BUILDER_STR_PROPERTY_APPLICATION_RUNTIME_VERSION,
202+
DDOG_TELEMETRY_WORKER_BUILDER_STR_PROPERTY_APPLICATION_RUNTIME_PATCHES,
203+
DDOG_TELEMETRY_WORKER_BUILDER_STR_PROPERTY_HOST_CONTAINER_ID,
204+
DDOG_TELEMETRY_WORKER_BUILDER_STR_PROPERTY_HOST_OS,
205+
DDOG_TELEMETRY_WORKER_BUILDER_STR_PROPERTY_HOST_KERNEL_NAME,
206+
DDOG_TELEMETRY_WORKER_BUILDER_STR_PROPERTY_HOST_KERNEL_RELEASE,
207+
DDOG_TELEMETRY_WORKER_BUILDER_STR_PROPERTY_HOST_KERNEL_VERSION,
208+
DDOG_TELEMETRY_WORKER_BUILDER_STR_PROPERTY_RUNTIME_ID,
209+
} ddog_TelemetryWorkerBuilderStrProperty;
210+
169211
typedef struct ddog_TelemetryWorkerBuilder ddog_TelemetryWorkerBuilder;
170212

213+
/**
214+
* TelemetryWorkerHandle is a handle which allows interactions with the telemetry worker.
215+
* The handle is safe to use across threads.
216+
*
217+
* The worker won't send data to the agent until you call `TelemetryWorkerHandle::send_start`
218+
*
219+
* To stop the worker, call `TelemetryWorkerHandle::send_stop` which trigger flush aynchronously
220+
* then `TelemetryWorkerHandle::wait_for_shutdown`
221+
*/
171222
typedef struct ddog_TelemetryWorkerHandle ddog_TelemetryWorkerHandle;
172223

173224
typedef enum ddog_Option_Bool_Tag {
@@ -184,6 +235,11 @@ typedef struct ddog_Option_Bool {
184235
};
185236
} ddog_Option_Bool;
186237

238+
typedef struct ddog_ContextKey {
239+
uint32_t _0;
240+
enum ddog_MetricType _1;
241+
} ddog_ContextKey;
242+
187243
typedef struct ddog_AgentRemoteConfigReader ddog_AgentRemoteConfigReader;
188244

189245
typedef struct ddog_AgentRemoteConfigWriter_ShmHandle ddog_AgentRemoteConfigWriter_ShmHandle;
@@ -215,6 +271,10 @@ typedef struct ddog_TracerHeaderTags {
215271
bool client_computed_stats;
216272
} ddog_TracerHeaderTags;
217273

274+
#ifdef __cplusplus
275+
extern "C" {
276+
#endif // __cplusplus
277+
218278
/**
219279
* # Safety
220280
* Only pass null or a valid reference to a `ddog_Error`.
@@ -266,4 +326,8 @@ struct ddog_Vec_Tag_PushResult ddog_Vec_Tag_push(struct ddog_Vec_Tag *vec,
266326
*/
267327
DDOG_CHECK_RETURN struct ddog_Vec_Tag_ParseResult ddog_Vec_Tag_parse(ddog_CharSlice string);
268328

329+
#ifdef __cplusplus
330+
} // extern "C"
331+
#endif // __cplusplus
332+
269333
#endif /* DDOG_COMMON_H */

components-rs/telemetry.h

Lines changed: 211 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ void ddog_MaybeError_drop(ddog_MaybeError);
1717
* # Safety
1818
* * builder should be a non null pointer to a null pointer to a builder
1919
*/
20-
ddog_MaybeError ddog_builder_instantiate(struct ddog_TelemetryWorkerBuilder **builder,
20+
ddog_MaybeError ddog_builder_instantiate(struct ddog_TelemetryWorkerBuilder **out_builder,
2121
ddog_CharSlice service_name,
2222
ddog_CharSlice language_name,
2323
ddog_CharSlice language_version,
@@ -27,7 +27,7 @@ ddog_MaybeError ddog_builder_instantiate(struct ddog_TelemetryWorkerBuilder **bu
2727
* # Safety
2828
* * builder should be a non null pointer to a null pointer to a builder
2929
*/
30-
ddog_MaybeError ddog_builder_instantiate_with_hostname(struct ddog_TelemetryWorkerBuilder **builder,
30+
ddog_MaybeError ddog_builder_instantiate_with_hostname(struct ddog_TelemetryWorkerBuilder **out_builder,
3131
ddog_CharSlice hostname,
3232
ddog_CharSlice service_name,
3333
ddog_CharSlice language_name,
@@ -46,11 +46,181 @@ ddog_MaybeError ddog_builder_with_config(struct ddog_TelemetryWorkerBuilder *bui
4646
enum ddog_ConfigurationOrigin origin);
4747

4848
/**
49+
* Builds the telemetry worker and return a handle to it
50+
*
4951
* # Safety
5052
* * handle should be a non null pointer to a null pointer
5153
*/
5254
ddog_MaybeError ddog_builder_run(struct ddog_TelemetryWorkerBuilder *builder,
53-
struct ddog_TelemetryWorkerHandle **handle);
55+
struct ddog_TelemetryWorkerHandle **out_handle);
56+
57+
/**
58+
* Builds the telemetry worker and return a handle to it. The worker will only process and send
59+
* telemetry metrics and telemetry logs. Any lifecyle/dependency/configuration event will be
60+
* ignored
61+
*
62+
* # Safety
63+
* * handle should be a non null pointer to a null pointer
64+
*/
65+
ddog_MaybeError ddog_builder_run_metric_logs(struct ddog_TelemetryWorkerBuilder *builder,
66+
struct ddog_TelemetryWorkerHandle **out_handle);
67+
68+
ddog_MaybeError ddog_builder_with_str_application_service_version(struct ddog_TelemetryWorkerBuilder *builder,
69+
ddog_CharSlice param);
70+
71+
ddog_MaybeError ddog_builder_with_str_application_env(struct ddog_TelemetryWorkerBuilder *builder,
72+
ddog_CharSlice param);
73+
74+
ddog_MaybeError ddog_builder_with_str_application_runtime_name(struct ddog_TelemetryWorkerBuilder *builder,
75+
ddog_CharSlice param);
76+
77+
ddog_MaybeError ddog_builder_with_str_application_runtime_version(struct ddog_TelemetryWorkerBuilder *builder,
78+
ddog_CharSlice param);
79+
80+
ddog_MaybeError ddog_builder_with_str_application_runtime_patches(struct ddog_TelemetryWorkerBuilder *builder,
81+
ddog_CharSlice param);
82+
83+
ddog_MaybeError ddog_builder_with_str_host_container_id(struct ddog_TelemetryWorkerBuilder *builder,
84+
ddog_CharSlice param);
85+
86+
ddog_MaybeError ddog_builder_with_str_host_os(struct ddog_TelemetryWorkerBuilder *builder,
87+
ddog_CharSlice param);
88+
89+
ddog_MaybeError ddog_builder_with_str_host_kernel_name(struct ddog_TelemetryWorkerBuilder *builder,
90+
ddog_CharSlice param);
91+
92+
ddog_MaybeError ddog_builder_with_str_host_kernel_release(struct ddog_TelemetryWorkerBuilder *builder,
93+
ddog_CharSlice param);
94+
95+
ddog_MaybeError ddog_builder_with_str_host_kernel_version(struct ddog_TelemetryWorkerBuilder *builder,
96+
ddog_CharSlice param);
97+
98+
ddog_MaybeError ddog_builder_with_str_runtime_id(struct ddog_TelemetryWorkerBuilder *builder,
99+
ddog_CharSlice param);
100+
101+
/**
102+
* Sets a property from it's string value.
103+
*
104+
* Available properties:
105+
*
106+
* * application.service_version
107+
*
108+
* * application.env
109+
*
110+
* * application.runtime_name
111+
*
112+
* * application.runtime_version
113+
*
114+
* * application.runtime_patches
115+
*
116+
* * host.container_id
117+
*
118+
* * host.os
119+
*
120+
* * host.kernel_name
121+
*
122+
* * host.kernel_release
123+
*
124+
* * host.kernel_version
125+
*
126+
* * runtime_id
127+
*
128+
*
129+
*/
130+
ddog_MaybeError ddog_builder_with_property_str(struct ddog_TelemetryWorkerBuilder *builder,
131+
enum ddog_TelemetryWorkerBuilderStrProperty property,
132+
ddog_CharSlice param);
133+
134+
/**
135+
* Sets a property from it's string value.
136+
*
137+
* Available properties:
138+
*
139+
* * application.service_version
140+
*
141+
* * application.env
142+
*
143+
* * application.runtime_name
144+
*
145+
* * application.runtime_version
146+
*
147+
* * application.runtime_patches
148+
*
149+
* * host.container_id
150+
*
151+
* * host.os
152+
*
153+
* * host.kernel_name
154+
*
155+
* * host.kernel_release
156+
*
157+
* * host.kernel_version
158+
*
159+
* * runtime_id
160+
*
161+
*
162+
*/
163+
ddog_MaybeError ddog_builder_with_str_named_property(struct ddog_TelemetryWorkerBuilder *builder,
164+
ddog_CharSlice property,
165+
ddog_CharSlice param);
166+
167+
ddog_MaybeError ddog_builder_with_bool_config_telemetry_debug_logging_enabled(struct ddog_TelemetryWorkerBuilder *builder,
168+
bool param);
169+
170+
/**
171+
* Sets a property from it's string value.
172+
*
173+
* Available properties:
174+
*
175+
* * config.telemetry_debug_logging_enabled
176+
*
177+
*
178+
*/
179+
ddog_MaybeError ddog_builder_with_property_bool(struct ddog_TelemetryWorkerBuilder *builder,
180+
enum ddog_TelemetryWorkerBuilderBoolProperty property,
181+
bool param);
182+
183+
/**
184+
* Sets a property from it's string value.
185+
*
186+
* Available properties:
187+
*
188+
* * config.telemetry_debug_logging_enabled
189+
*
190+
*
191+
*/
192+
ddog_MaybeError ddog_builder_with_bool_named_property(struct ddog_TelemetryWorkerBuilder *builder,
193+
ddog_CharSlice property,
194+
bool param);
195+
196+
ddog_MaybeError ddog_builder_with_endpoint_config_endpoint(struct ddog_TelemetryWorkerBuilder *builder,
197+
const struct ddog_Endpoint *param);
198+
199+
/**
200+
* Sets a property from it's string value.
201+
*
202+
* Available properties:
203+
*
204+
* * config.endpoint
205+
*
206+
*
207+
*/
208+
ddog_MaybeError ddog_builder_with_property_endpoint(struct ddog_TelemetryWorkerBuilder *builder,
209+
enum ddog_TelemetryWorkerBuilderEndpointProperty property,
210+
const struct ddog_Endpoint *param);
211+
212+
/**
213+
* Sets a property from it's string value.
214+
*
215+
* Available properties:
216+
*
217+
* * config.endpoint
218+
*
219+
*
220+
*/
221+
ddog_MaybeError ddog_builder_with_endpoint_named_property(struct ddog_TelemetryWorkerBuilder *builder,
222+
ddog_CharSlice property,
223+
const struct ddog_Endpoint *param);
54224

55225
ddog_MaybeError ddog_handle_add_dependency(const struct ddog_TelemetryWorkerHandle *handle,
56226
ddog_CharSlice dependency_name,
@@ -63,6 +233,12 @@ ddog_MaybeError ddog_handle_add_integration(const struct ddog_TelemetryWorkerHan
63233
struct ddog_Option_Bool compatible,
64234
struct ddog_Option_Bool auto_enabled);
65235

236+
/**
237+
* * indentifier: identifies a logging location uniquely. This can for instance be the template
238+
* using for the log message or the concatenated file + line of the origin of the log
239+
* * stack_trace: stack trace associated with the log. If no stack trace is available, an empty
240+
* string should be passed
241+
*/
66242
ddog_MaybeError ddog_handle_add_log(const struct ddog_TelemetryWorkerHandle *handle,
67243
ddog_CharSlice indentifier,
68244
ddog_CharSlice message,
@@ -75,8 +251,40 @@ struct ddog_TelemetryWorkerHandle *ddog_handle_clone(const struct ddog_Telemetry
75251

76252
ddog_MaybeError ddog_handle_stop(const struct ddog_TelemetryWorkerHandle *handle);
77253

254+
/**
255+
* * compatible: should be false if the metric is language specific, true otherwise
256+
*/
257+
struct ddog_ContextKey ddog_handle_register_metric_context(const struct ddog_TelemetryWorkerHandle *handle,
258+
ddog_CharSlice name,
259+
enum ddog_MetricType metric_type,
260+
struct ddog_Vec_Tag tags,
261+
bool common,
262+
enum ddog_MetricNamespace namespace_);
263+
264+
ddog_MaybeError ddog_handle_add_point(const struct ddog_TelemetryWorkerHandle *handle,
265+
const struct ddog_ContextKey *context_key,
266+
double value);
267+
268+
ddog_MaybeError ddog_handle_add_point_with_tags(const struct ddog_TelemetryWorkerHandle *handle,
269+
const struct ddog_ContextKey *context_key,
270+
double value,
271+
struct ddog_Vec_Tag extra_tags);
272+
273+
/**
274+
* This function takes ownership of the handle. It should not be used after calling it
275+
*/
78276
void ddog_handle_wait_for_shutdown(struct ddog_TelemetryWorkerHandle *handle);
79277

278+
/**
279+
* This function takes ownership of the handle. It should not be used after calling it
280+
*/
281+
void ddog_handle_wait_for_shutdown_ms(struct ddog_TelemetryWorkerHandle *handle,
282+
uint64_t wait_for_ms);
283+
284+
/**
285+
* Drops the handle without waiting for shutdown. The worker will continue running in the
286+
* background until it exits by itself
287+
*/
80288
void ddog_handle_drop(struct ddog_TelemetryWorkerHandle *handle);
81289

82290
#endif /* DDOG_TELEMETRY_H */

0 commit comments

Comments
 (0)