Skip to content

Commit 36c07fd

Browse files
committed
feat: implement threaded sidecar connection for PHP tracer
Signed-off-by: Alexandre Rulleau <[email protected]>
1 parent 12004d3 commit 36c07fd

File tree

16 files changed

+622
-122
lines changed

16 files changed

+622
-122
lines changed

Cargo.lock

Lines changed: 111 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components-rs/common.h

Lines changed: 112 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -306,13 +306,54 @@ typedef enum ddog_Log {
306306
DDOG_LOG_HOOK_TRACE = (5 | (4 << 4)),
307307
} ddog_Log;
308308

309+
typedef enum ddog_InBodyLocation {
310+
DDOG_IN_BODY_LOCATION_NONE,
311+
DDOG_IN_BODY_LOCATION_START,
312+
DDOG_IN_BODY_LOCATION_END,
313+
} ddog_InBodyLocation;
314+
315+
typedef enum ddog_EvaluateAt {
316+
DDOG_EVALUATE_AT_ENTRY,
317+
DDOG_EVALUATE_AT_EXIT,
318+
} ddog_EvaluateAt;
319+
309320
typedef enum ddog_MetricKind {
310321
DDOG_METRIC_KIND_COUNT,
311322
DDOG_METRIC_KIND_GAUGE,
312323
DDOG_METRIC_KIND_HISTOGRAM,
313324
DDOG_METRIC_KIND_DISTRIBUTION,
314325
} ddog_MetricKind;
315326

327+
typedef enum ddog_SpanProbeTarget {
328+
DDOG_SPAN_PROBE_TARGET_ACTIVE,
329+
DDOG_SPAN_PROBE_TARGET_ROOT,
330+
} ddog_SpanProbeTarget;
331+
332+
typedef enum ddog_ProbeStatus {
333+
DDOG_PROBE_STATUS_RECEIVED,
334+
DDOG_PROBE_STATUS_INSTALLED,
335+
DDOG_PROBE_STATUS_EMITTING,
336+
DDOG_PROBE_STATUS_ERROR,
337+
DDOG_PROBE_STATUS_BLOCKED,
338+
DDOG_PROBE_STATUS_WARNING,
339+
} ddog_ProbeStatus;
340+
341+
typedef enum ddog_ConfigurationOrigin {
342+
DDOG_CONFIGURATION_ORIGIN_ENV_VAR,
343+
DDOG_CONFIGURATION_ORIGIN_CODE,
344+
DDOG_CONFIGURATION_ORIGIN_DD_CONFIG,
345+
DDOG_CONFIGURATION_ORIGIN_REMOTE_CONFIG,
346+
DDOG_CONFIGURATION_ORIGIN_DEFAULT,
347+
DDOG_CONFIGURATION_ORIGIN_LOCAL_STABLE_CONFIG,
348+
DDOG_CONFIGURATION_ORIGIN_FLEET_STABLE_CONFIG,
349+
} ddog_ConfigurationOrigin;
350+
351+
typedef enum ddog_MetricType {
352+
DDOG_METRIC_TYPE_GAUGE,
353+
DDOG_METRIC_TYPE_COUNT,
354+
DDOG_METRIC_TYPE_DISTRIBUTION,
355+
} ddog_MetricType;
356+
316357
typedef enum ddog_MetricNamespace {
317358
DDOG_METRIC_NAMESPACE_TRACERS,
318359
DDOG_METRIC_NAMESPACE_PROFILERS,
@@ -327,20 +368,16 @@ typedef enum ddog_MetricNamespace {
327368
DDOG_METRIC_NAMESPACE_SIDECAR,
328369
} ddog_MetricNamespace;
329370

330-
typedef enum ddog_MetricType {
331-
DDOG_METRIC_TYPE_GAUGE,
332-
DDOG_METRIC_TYPE_COUNT,
333-
DDOG_METRIC_TYPE_DISTRIBUTION,
334-
} ddog_MetricType;
335-
336-
typedef enum ddog_ProbeStatus {
337-
DDOG_PROBE_STATUS_RECEIVED,
338-
DDOG_PROBE_STATUS_INSTALLED,
339-
DDOG_PROBE_STATUS_EMITTING,
340-
DDOG_PROBE_STATUS_ERROR,
341-
DDOG_PROBE_STATUS_BLOCKED,
342-
DDOG_PROBE_STATUS_WARNING,
343-
} ddog_ProbeStatus;
371+
typedef enum ddog_RemoteConfigProduct {
372+
DDOG_REMOTE_CONFIG_PRODUCT_AGENT_CONFIG,
373+
DDOG_REMOTE_CONFIG_PRODUCT_AGENT_TASK,
374+
DDOG_REMOTE_CONFIG_PRODUCT_APM_TRACING,
375+
DDOG_REMOTE_CONFIG_PRODUCT_ASM,
376+
DDOG_REMOTE_CONFIG_PRODUCT_ASM_DATA,
377+
DDOG_REMOTE_CONFIG_PRODUCT_ASM_DD,
378+
DDOG_REMOTE_CONFIG_PRODUCT_ASM_FEATURES,
379+
DDOG_REMOTE_CONFIG_PRODUCT_LIVE_DEBUGGER,
380+
} ddog_RemoteConfigProduct;
344381

345382
typedef enum ddog_RemoteConfigCapabilities {
346383
DDOG_REMOTE_CONFIG_CAPABILITIES_ASM_ACTIVATION = 1,
@@ -388,22 +425,6 @@ typedef enum ddog_RemoteConfigCapabilities {
388425
DDOG_REMOTE_CONFIG_CAPABILITIES_ASM_TRACE_TAGGING_RULES = 43,
389426
} ddog_RemoteConfigCapabilities;
390427

391-
typedef enum ddog_RemoteConfigProduct {
392-
DDOG_REMOTE_CONFIG_PRODUCT_AGENT_CONFIG,
393-
DDOG_REMOTE_CONFIG_PRODUCT_AGENT_TASK,
394-
DDOG_REMOTE_CONFIG_PRODUCT_APM_TRACING,
395-
DDOG_REMOTE_CONFIG_PRODUCT_ASM,
396-
DDOG_REMOTE_CONFIG_PRODUCT_ASM_DATA,
397-
DDOG_REMOTE_CONFIG_PRODUCT_ASM_DD,
398-
DDOG_REMOTE_CONFIG_PRODUCT_ASM_FEATURES,
399-
DDOG_REMOTE_CONFIG_PRODUCT_LIVE_DEBUGGER,
400-
} ddog_RemoteConfigProduct;
401-
402-
typedef enum ddog_SpanProbeTarget {
403-
DDOG_SPAN_PROBE_TARGET_ACTIVE,
404-
DDOG_SPAN_PROBE_TARGET_ROOT,
405-
} ddog_SpanProbeTarget;
406-
407428
typedef struct ddog_DebuggerPayload ddog_DebuggerPayload;
408429

409430
typedef struct ddog_DslString ddog_DslString;
@@ -774,17 +795,17 @@ typedef struct ddog_DebuggerValue ddog_DebuggerValue;
774795

775796
#define ddog_EVALUATOR_RESULT_REDACTED (const void*)-2
776797

777-
typedef enum ddog_DebuggerType {
778-
DDOG_DEBUGGER_TYPE_DIAGNOSTICS,
779-
DDOG_DEBUGGER_TYPE_LOGS,
780-
} ddog_DebuggerType;
781-
782798
typedef enum ddog_FieldType {
783799
DDOG_FIELD_TYPE_STATIC,
784800
DDOG_FIELD_TYPE_ARG,
785801
DDOG_FIELD_TYPE_LOCAL,
786802
} ddog_FieldType;
787803

804+
typedef enum ddog_DebuggerType {
805+
DDOG_DEBUGGER_TYPE_DIAGNOSTICS,
806+
DDOG_DEBUGGER_TYPE_LOGS,
807+
} ddog_DebuggerType;
808+
788809
typedef struct ddog_Entry ddog_Entry;
789810

790811
typedef struct ddog_HashMap_CowStr__Value ddog_HashMap_CowStr__Value;
@@ -913,16 +934,6 @@ typedef struct ddog_OwnedCharSlice {
913934
void (*free)(ddog_CharSlice);
914935
} ddog_OwnedCharSlice;
915936

916-
typedef enum ddog_LogLevel {
917-
DDOG_LOG_LEVEL_ERROR,
918-
DDOG_LOG_LEVEL_WARN,
919-
DDOG_LOG_LEVEL_DEBUG,
920-
} ddog_LogLevel;
921-
922-
typedef enum ddog_TelemetryWorkerBuilderBoolProperty {
923-
DDOG_TELEMETRY_WORKER_BUILDER_BOOL_PROPERTY_CONFIG_TELEMETRY_DEBUG_LOGGING_ENABLED,
924-
} ddog_TelemetryWorkerBuilderBoolProperty;
925-
926937
typedef enum ddog_TelemetryWorkerBuilderEndpointProperty {
927938
DDOG_TELEMETRY_WORKER_BUILDER_ENDPOINT_PROPERTY_CONFIG_ENDPOINT,
928939
} ddog_TelemetryWorkerBuilderEndpointProperty;
@@ -941,6 +952,16 @@ typedef enum ddog_TelemetryWorkerBuilderStrProperty {
941952
DDOG_TELEMETRY_WORKER_BUILDER_STR_PROPERTY_RUNTIME_ID,
942953
} ddog_TelemetryWorkerBuilderStrProperty;
943954

955+
typedef enum ddog_TelemetryWorkerBuilderBoolProperty {
956+
DDOG_TELEMETRY_WORKER_BUILDER_BOOL_PROPERTY_CONFIG_TELEMETRY_DEBUG_LOGGING_ENABLED,
957+
} ddog_TelemetryWorkerBuilderBoolProperty;
958+
959+
typedef enum ddog_LogLevel {
960+
DDOG_LOG_LEVEL_ERROR,
961+
DDOG_LOG_LEVEL_WARN,
962+
DDOG_LOG_LEVEL_DEBUG,
963+
} ddog_LogLevel;
964+
944965
typedef struct ddog_TelemetryWorkerBuilder ddog_TelemetryWorkerBuilder;
945966

946967
/**
@@ -1097,6 +1118,29 @@ typedef enum ddog_crasht_FileType {
10971118
DDOG_CRASHT_FILE_TYPE_PE,
10981119
} ddog_crasht_FileType;
10991120

1121+
/**
1122+
* Stacktrace collection occurs in the context of a crashing process.
1123+
* If the stack is sufficiently corruputed, it is possible (but unlikely),
1124+
* for stack trace collection itself to crash.
1125+
* We recommend fully enabling stacktrace collection, but having an environment
1126+
* variable to allow downgrading the collector.
1127+
*/
1128+
typedef enum ddog_crasht_StacktraceCollection {
1129+
/**
1130+
* Stacktrace collection occurs in the
1131+
*/
1132+
DDOG_CRASHT_STACKTRACE_COLLECTION_DISABLED,
1133+
DDOG_CRASHT_STACKTRACE_COLLECTION_WITHOUT_SYMBOLS,
1134+
/**
1135+
* This option uses `backtrace::resolve_frame_unsynchronized()` to gather symbol information
1136+
* and also unwind inlined functions. Enabling this feature will not only provide symbolic
1137+
* details, but may also yield additional or less stack frames compared to other
1138+
* configurations.
1139+
*/
1140+
DDOG_CRASHT_STACKTRACE_COLLECTION_ENABLED_WITH_INPROCESS_SYMBOLS,
1141+
DDOG_CRASHT_STACKTRACE_COLLECTION_ENABLED_WITH_SYMBOLS_IN_RECEIVER,
1142+
} ddog_crasht_StacktraceCollection;
1143+
11001144
/**
11011145
* This enum represents operations a the tracked library might be engaged in.
11021146
* Currently only implemented for profiling.
@@ -1120,6 +1164,12 @@ typedef enum ddog_crasht_OpTypes {
11201164
DDOG_CRASHT_OP_TYPES_SIZE,
11211165
} ddog_crasht_OpTypes;
11221166

1167+
typedef enum ddog_crasht_ErrorKind {
1168+
DDOG_CRASHT_ERROR_KIND_PANIC,
1169+
DDOG_CRASHT_ERROR_KIND_UNHANDLED_EXCEPTION,
1170+
DDOG_CRASHT_ERROR_KIND_UNIX_SIGNAL,
1171+
} ddog_crasht_ErrorKind;
1172+
11231173
/**
11241174
* See https://man7.org/linux/man-pages/man2/sigaction.2.html
11251175
* MUST REMAIN IN SYNC WITH THE ENUM IN emit_sigcodes.c
@@ -1192,28 +1242,23 @@ typedef enum ddog_crasht_SignalNames {
11921242
DDOG_CRASHT_SIGNAL_NAMES_UNKNOWN,
11931243
} ddog_crasht_SignalNames;
11941244

1195-
/**
1196-
* Stacktrace collection occurs in the context of a crashing process.
1197-
* If the stack is sufficiently corruputed, it is possible (but unlikely),
1198-
* for stack trace collection itself to crash.
1199-
* We recommend fully enabling stacktrace collection, but having an environment
1200-
* variable to allow downgrading the collector.
1201-
*/
1202-
typedef enum ddog_crasht_StacktraceCollection {
1203-
/**
1204-
* Stacktrace collection occurs in the
1205-
*/
1206-
DDOG_CRASHT_STACKTRACE_COLLECTION_DISABLED,
1207-
DDOG_CRASHT_STACKTRACE_COLLECTION_WITHOUT_SYMBOLS,
1208-
/**
1209-
* This option uses `backtrace::resolve_frame_unsynchronized()` to gather symbol information
1210-
* and also unwind inlined functions. Enabling this feature will not only provide symbolic
1211-
* details, but may also yield additional or less stack frames compared to other
1212-
* configurations.
1213-
*/
1214-
DDOG_CRASHT_STACKTRACE_COLLECTION_ENABLED_WITH_INPROCESS_SYMBOLS,
1215-
DDOG_CRASHT_STACKTRACE_COLLECTION_ENABLED_WITH_SYMBOLS_IN_RECEIVER,
1216-
} ddog_crasht_StacktraceCollection;
1245+
typedef enum ddog_crasht_BuildIdType {
1246+
DDOG_CRASHT_BUILD_ID_TYPE_GNU,
1247+
DDOG_CRASHT_BUILD_ID_TYPE_GO,
1248+
DDOG_CRASHT_BUILD_ID_TYPE_PDB,
1249+
DDOG_CRASHT_BUILD_ID_TYPE_SHA1,
1250+
} ddog_crasht_BuildIdType;
1251+
1252+
typedef enum ddog_crasht_FileType {
1253+
DDOG_CRASHT_FILE_TYPE_APK,
1254+
DDOG_CRASHT_FILE_TYPE_ELF,
1255+
DDOG_CRASHT_FILE_TYPE_PE,
1256+
} ddog_crasht_FileType;
1257+
1258+
typedef enum ddog_crasht_DemangleOptions {
1259+
DDOG_CRASHT_DEMANGLE_OPTIONS_COMPLETE,
1260+
DDOG_CRASHT_DEMANGLE_OPTIONS_NAME_ONLY,
1261+
} ddog_crasht_DemangleOptions;
12171262

12181263
typedef struct ddog_crasht_CrashInfo ddog_crasht_CrashInfo;
12191264

components-rs/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
#![feature(linkage)]
44
#![allow(static_mut_refs)] // remove with move to Rust 2024 edition
55

6+
pub mod bytes;
67
pub mod log;
78
pub mod remote_config;
89
pub mod sidecar;
910
pub mod telemetry;
10-
pub mod bytes;
1111

1212
use libdd_common::entity_id::{get_container_id, set_cgroup_file};
1313
use http::uri::{PathAndQuery, Scheme};

0 commit comments

Comments
 (0)