Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
151 changes: 106 additions & 45 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ JUNIT_RESULTS_DIR := $(shell pwd)

all: $(BUILD_DIR)/configure $(SO_FILE)

$(BUILD_DIR)/configure: $(M4_FILES) $(BUILD_DIR)/datadog.sym $(BUILD_DIR)/VERSION
$(BUILD_DIR)/configure: $(M4_FILES) $(BUILD_DIR)/datadog.sym $(BUILD_DIR)/datadog-linux.sym $(BUILD_DIR)/VERSION
$(Q) (cd $(BUILD_DIR); phpize && $(SED_I) 's/\/FAILED/\/\\bFAILED/' $(BUILD_DIR)/run-tests.php) # Fix PHP 5.4 exit code bug when running selected tests (FAILED vs XFAILED)

$(BUILD_DIR)/run-tests.php: $(if $(ASSUME_COMPILED),, $(BUILD_DIR)/configure)
Expand Down
1 change: 1 addition & 0 deletions appsec/cmake/extension.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ set_target_properties(zai PROPERTIES POSITION_INDEPENDENT_CODE 1)
include(cmake/pcre2.cmake)

file(GLOB_RECURSE EXT_SOURCE ${EXT_SOURCE_DIR}/*.c ${EXT_SOURCE_DIR}/*.cpp)
list(APPEND EXT_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/../components/context-discovery/context_discovery.c)
add_library(extension SHARED ${EXT_SOURCE})
set_target_properties(extension PROPERTIES
C_VISIBILITY_PRESET hidden
Expand Down
6 changes: 6 additions & 0 deletions cbindgen.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ rename_types = "PascalCase"
"ZendString" = "_zend_string"
"FILE" = "FILE"
"EndpointConfig" = "ddog_crasht_EndpointConfig"
"Config" = "ddog_crasht_Config"
"Metadata" = "ddog_crasht_Metadata"
"AtomicU8" = "uint8_t"
"MaybeOwnedZendString" = "_zend_string *"

[enum]
Expand All @@ -43,5 +46,8 @@ include = [
"datadog-live-debugger",
"datadog-live-debugger-ffi",
"libdd-remote-config",
"libdd-library-config",
"libdd-otel-thread-ctx",
"libdd-otel-thread-ctx-ffi",
"uuid"
]
5 changes: 5 additions & 0 deletions components-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,13 @@ libdd-data-pipeline = { path = "../libdatadog/libdd-data-pipeline" }
libdd-tinybytes = { path = "../libdatadog/libdd-tinybytes" }
libdd-trace-utils = { path = "../libdatadog/libdd-trace-utils" }
libdd-trace-stats = { path = "../libdatadog/libdd-trace-stats" }
libdd-crashtracker = { path = "../libdatadog/libdd-crashtracker" }
libdd-crashtracker-ffi = { path = "../libdatadog/libdd-crashtracker-ffi", default-features = false, features = ["collector"] }
libdd-library-config-ffi = { path = "../libdatadog/libdd-library-config-ffi", default-features = false }
libdd-library-config = { path = "../libdatadog/libdd-library-config", default-features = false, features = ["otel-thread-ctx"] }
libdd-trace-protobuf = { path = "../libdatadog/libdd-trace-protobuf" }
libdd-otel-thread-ctx-ffi = { path = "../libdatadog/libdd-otel-thread-ctx-ffi", default-features = false, features = ["tls-storage"] }
libdd-alloc = { path = "../libdatadog/libdd-alloc" }
spawn_worker = { path = "../libdatadog/spawn_worker" }
anyhow = { version = "1.0" }
const-str = "0.5.6"
Expand Down
63 changes: 39 additions & 24 deletions components-rs/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,11 @@ typedef enum ddog_RemoteConfigCapabilities {
DDOG_REMOTE_CONFIG_CAPABILITIES_APM_TRACING_ENABLE_LIVE_DEBUGGING = 41,
DDOG_REMOTE_CONFIG_CAPABILITIES_ASM_DD_MULTICONFIG = 42,
DDOG_REMOTE_CONFIG_CAPABILITIES_ASM_TRACE_TAGGING_RULES = 43,
DDOG_REMOTE_CONFIG_CAPABILITIES_ASM_EXTENDED_DATA_COLLECTION = 44,
DDOG_REMOTE_CONFIG_CAPABILITIES_APM_TRACING_MULTICONFIG = 45,
DDOG_REMOTE_CONFIG_CAPABILITIES_FFE_FLAG_CONFIGURATION_RULES = 46,
DDOG_REMOTE_CONFIG_CAPABILITIES_DD_DATA_STREAMS_TRANSACTION_EXTRACTORS = 47,
DDOG_REMOTE_CONFIG_CAPABILITIES_LLM_OBS_ACTIVATION = 48,
} ddog_RemoteConfigCapabilities;

typedef enum ddog_RemoteConfigProduct {
Expand All @@ -426,6 +429,7 @@ typedef enum ddog_RemoteConfigProduct {
DDOG_REMOTE_CONFIG_PRODUCT_ASM_FEATURES,
DDOG_REMOTE_CONFIG_PRODUCT_FFE_FLAGS,
DDOG_REMOTE_CONFIG_PRODUCT_LIVE_DEBUGGER,
DDOG_REMOTE_CONFIG_PRODUCT_LIVE_DEBUGGER_SYMBOL_DB,
} ddog_RemoteConfigProduct;

typedef enum ddog_SpanProbeTarget {
Expand All @@ -435,6 +439,10 @@ typedef enum ddog_SpanProbeTarget {

typedef struct ddog_AgentInfoReader ddog_AgentInfoReader;

typedef struct ddog_crasht_Config ddog_crasht_Config;

typedef struct ddog_Configurator ddog_Configurator;

typedef struct ddog_DebuggerPayload ddog_DebuggerPayload;

typedef struct ddog_DslString ddog_DslString;
Expand All @@ -448,6 +456,8 @@ typedef struct ddog_InstanceId ddog_InstanceId;

typedef struct ddog_MaybeShmLimiter ddog_MaybeShmLimiter;

typedef struct ddog_PhpOtelProcessContext ddog_PhpOtelProcessContext;

typedef struct ddog_ProbeCondition ddog_ProbeCondition;

typedef struct ddog_ProbeValue ddog_ProbeValue;
Expand Down Expand Up @@ -478,6 +488,8 @@ typedef struct ddog_SidecarTransport ddog_SidecarTransport;
*/
typedef struct ddog_SpanConcentrator ddog_SpanConcentrator;

typedef struct _zend_string *ddog_OwnedZendString;

typedef struct ddog_FfeResult {
_zend_string * value_json;
_zend_string * variant;
Expand Down Expand Up @@ -524,8 +536,6 @@ typedef struct ddog_Tag {
const struct ddog_DslString *value;
} ddog_Tag;

typedef struct _zend_string *ddog_OwnedZendString;

typedef struct _zend_string *(*ddog_DynamicConfigUpdate)(ddog_CharSlice config,
ddog_OwnedZendString value,
enum ddog_DynamicConfigUpdateMode mode);
Expand Down Expand Up @@ -710,6 +720,24 @@ typedef struct ddog_Vec_DebuggerPayload {
*/
typedef uint64_t ddog_QueueId;

/**
* A generic result type for when an operation may fail,
* but there's nothing to return in the case of success.
*/
typedef enum ddog_VoidResult_Tag {
DDOG_VOID_RESULT_OK,
DDOG_VOID_RESULT_ERR,
} ddog_VoidResult_Tag;

typedef struct ddog_VoidResult {
ddog_VoidResult_Tag tag;
union {
struct {
struct ddog_Error err;
};
};
} ddog_VoidResult;

/**
* A (key, value) pair for peer-service tags, borrowed from PHP/concentrator memory.
*/
Expand Down Expand Up @@ -1110,9 +1138,10 @@ typedef struct ddog_TelemetryWorkerBuilder ddog_TelemetryWorkerBuilder;
* The worker won't send data to the agent until you call `TelemetryWorkerHandle::send_start`
*
* To stop the worker, call `TelemetryWorkerHandle::send_stop` which trigger flush asynchronously
* then `TelemetryWorkerHandle::wait_for_shutdown`
* then `TelemetryWorkerHandle::wait_for_shutdown` (native only — wasm callers rely on the
* SharedRuntime worker JoinHandle instead).
*/
typedef struct ddog_TelemetryWorkerHandle ddog_TelemetryWorkerHandle;
typedef struct ddog_TelemetryWorkerHandle_NativeCapabilities ddog_TelemetryWorkerHandle_NativeCapabilities;

typedef enum ddog_Option_U64_Tag {
DDOG_OPTION_U64_SOME_U64,
Expand All @@ -1128,6 +1157,12 @@ typedef struct ddog_Option_U64 {
};
} ddog_Option_U64;

/**
* FFI-facing alias: the C ABI surface is native-only, so the worker handle is
* always pinned to [`NativeCapabilities`].
*/
typedef struct ddog_TelemetryWorkerHandle_NativeCapabilities ddog_TelemetryWorkerHandle;

typedef enum ddog_Option_Bool_Tag {
DDOG_OPTION_BOOL_SOME_BOOL,
DDOG_OPTION_BOOL_NONE_BOOL,
Expand Down Expand Up @@ -1452,24 +1487,6 @@ typedef struct ddog_crasht_StackFrame ddog_crasht_StackFrame;

typedef struct ddog_crasht_StackTrace ddog_crasht_StackTrace;

/**
* A generic result type for when an operation may fail,
* but there's nothing to return in the case of success.
*/
typedef enum ddog_VoidResult_Tag {
DDOG_VOID_RESULT_OK,
DDOG_VOID_RESULT_ERR,
} ddog_VoidResult_Tag;

typedef struct ddog_VoidResult {
ddog_VoidResult_Tag tag;
union {
struct {
struct ddog_Error err;
};
};
} ddog_VoidResult;

typedef struct ddog_crasht_Slice_CharSlice {
/**
* Should be non-null and suitably aligned for the underlying type. It is
Expand Down Expand Up @@ -1851,8 +1868,6 @@ typedef enum ddog_MetadataKind {
DDOG_METADATA_KIND_CONTAINER_ID = 8,
} ddog_MetadataKind;

typedef struct ddog_Configurator ddog_Configurator;

/**
* This struct MUST be backward compatible.
*/
Expand Down
147 changes: 87 additions & 60 deletions components-rs/datadog.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,23 @@ extern ddog_VecRemoteConfigCapabilities DATADOG_REMOTE_CONFIG_CAPABILITIES;

extern const uint8_t *DDOG_PHP_FUNCTION;

struct ddog_PhpOtelProcessContext *datadog_otel_process_context_new(void);

bool datadog_otel_process_context_publish(struct ddog_PhpOtelProcessContext *storage,
ddog_CharSlice hostname,
ddog_CharSlice service,
ddog_CharSlice env,
ddog_CharSlice version,
ddog_CharSlice process_tags);

#if !defined(__linux__)
bool datadog_otel_process_context_mapping(const struct ddog_PhpOtelProcessContext *storage,
const uint8_t **base,
uintptr_t *len);
#endif

void datadog_otel_process_context_drop(struct ddog_PhpOtelProcessContext *storage);

/**
* # Safety
* Must be called from a single-threaded context, such as MINIT or first rinit.
Expand Down Expand Up @@ -59,7 +76,8 @@ void datadog_endpoint_as_crashtracker_config(const struct ddog_Endpoint *endpoin
void (*callback)(ddog_crasht_EndpointConfig, void*),
void *userdata);

ddog_Configurator *ddog_library_configurator_new_dummy(bool debug_logs, ddog_CharSlice language);
struct ddog_Configurator *ddog_library_configurator_new_dummy(bool debug_logs,
ddog_CharSlice language);

int posix_spawn_file_actions_addchdir_np(void *file_actions, const char *path);

Expand Down Expand Up @@ -110,6 +128,64 @@ void ddog_agent_info_json_free(char *ptr);
*/
void ddog_apply_agent_info_concentrator_config(struct ddog_AgentInfoReader *reader);

void ddog_init_span_func(void (*free_func)(ddog_OwnedZendString),
void (*addref_func)(struct _zend_string*),
ddog_OwnedZendString (*init_func)(ddog_CharSlice));

void ddog_set_span_service_zstr(ddog_SpanBytes *ptr, struct _zend_string *str);

void ddog_set_span_name_zstr(ddog_SpanBytes *ptr, struct _zend_string *str);

void ddog_set_span_resource_zstr(ddog_SpanBytes *ptr, struct _zend_string *str);

void ddog_set_span_type_zstr(ddog_SpanBytes *ptr, struct _zend_string *str);

void ddog_add_span_meta_zstr(ddog_SpanBytes *ptr,
struct _zend_string *key,
struct _zend_string *val);

void ddog_add_CharSlice_span_meta_zstr(ddog_SpanBytes *ptr,
ddog_CharSlice key,
struct _zend_string *val);

void ddog_add_zstr_span_meta_str(ddog_SpanBytes *ptr, struct _zend_string *key, const char *val);

void ddog_add_str_span_meta_str(ddog_SpanBytes *ptr, const char *key, const char *val);

void ddog_add_str_span_meta_zstr(ddog_SpanBytes *ptr, const char *key, struct _zend_string *val);

void ddog_add_str_span_meta_CharSlice(ddog_SpanBytes *ptr, const char *key, ddog_CharSlice val);

void ddog_del_span_meta_zstr(ddog_SpanBytes *ptr, struct _zend_string *key);

void ddog_del_span_meta_str(ddog_SpanBytes *ptr, const char *key);

bool ddog_has_span_meta_zstr(ddog_SpanBytes *ptr, struct _zend_string *key);

bool ddog_has_span_meta_str(ddog_SpanBytes *ptr, const char *key);

ddog_CharSlice ddog_get_span_meta_str(ddog_SpanBytes *span, const char *key);

void ddog_add_span_metrics_zstr(ddog_SpanBytes *ptr, struct _zend_string *key, double val);

bool ddog_has_span_metrics_zstr(ddog_SpanBytes *ptr, struct _zend_string *key);

void ddog_del_span_metrics_zstr(ddog_SpanBytes *ptr, struct _zend_string *key);

void ddog_add_span_metrics_str(ddog_SpanBytes *ptr, const char *key, double val);

bool ddog_get_span_metrics_str(ddog_SpanBytes *ptr, const char *key, double *result);

void ddog_del_span_metrics_str(ddog_SpanBytes *ptr, const char *key);

void ddog_add_span_meta_struct_zstr(ddog_SpanBytes *ptr,
struct _zend_string *key,
struct _zend_string *val);

void ddog_add_zstr_span_meta_struct_CharSlice(ddog_SpanBytes *ptr,
struct _zend_string *key,
ddog_CharSlice val);

bool ddog_ffe_load_config(ddog_CharSlice json);

bool ddog_ffe_has_config(void);
Expand Down Expand Up @@ -189,7 +265,12 @@ void ddog_rshutdown_remote_config(struct ddog_RemoteConfigState *remote_config);

void ddog_shutdown_remote_config(struct ddog_RemoteConfigState*);

void ddog_drop_probe(struct ddog_Probe probe);
/**
* Free the FFI-owned allocations in a `Probe` (the `tags` vec and the nested
* span-decoration / log allocations) by consuming it; borrowed `CharSlice`s are
* left untouched. Called from `dd_probe_dtor` when a probe is uninstalled.
*/
void ddog_drop_probe(struct ddog_Probe);

void ddog_log_debugger_data(const struct ddog_Vec_DebuggerPayload *payloads);

Expand All @@ -202,6 +283,10 @@ ddog_MaybeError ddog_send_debugger_diagnostics(const struct ddog_RemoteConfigSta
const struct ddog_Probe *probe,
uint64_t timestamp);

struct ddog_VoidResult datadog_crasht_init_without_receiver(struct ddog_crasht_Config config,
ddog_crasht_Metadata metadata,
uint32_t sidecar_master_pid);

void ddog_sidecar_enable_appsec(ddog_CharSlice shared_lib_path,
ddog_CharSlice socket_file_path,
ddog_CharSlice lock_file_path,
Expand Down Expand Up @@ -417,62 +502,4 @@ bool ddog_check_stats_trace_filter(ddog_CharSlice resource,
const void *root_span,
ddog_RootTagLookupFn lookup_fn);

void ddog_init_span_func(void (*free_func)(ddog_OwnedZendString),
void (*addref_func)(struct _zend_string*),
ddog_OwnedZendString (*init_func)(ddog_CharSlice));

void ddog_set_span_service_zstr(ddog_SpanBytes *ptr, struct _zend_string *str);

void ddog_set_span_name_zstr(ddog_SpanBytes *ptr, struct _zend_string *str);

void ddog_set_span_resource_zstr(ddog_SpanBytes *ptr, struct _zend_string *str);

void ddog_set_span_type_zstr(ddog_SpanBytes *ptr, struct _zend_string *str);

void ddog_add_span_meta_zstr(ddog_SpanBytes *ptr,
struct _zend_string *key,
struct _zend_string *val);

void ddog_add_CharSlice_span_meta_zstr(ddog_SpanBytes *ptr,
ddog_CharSlice key,
struct _zend_string *val);

void ddog_add_zstr_span_meta_str(ddog_SpanBytes *ptr, struct _zend_string *key, const char *val);

void ddog_add_str_span_meta_str(ddog_SpanBytes *ptr, const char *key, const char *val);

void ddog_add_str_span_meta_zstr(ddog_SpanBytes *ptr, const char *key, struct _zend_string *val);

void ddog_add_str_span_meta_CharSlice(ddog_SpanBytes *ptr, const char *key, ddog_CharSlice val);

void ddog_del_span_meta_zstr(ddog_SpanBytes *ptr, struct _zend_string *key);

void ddog_del_span_meta_str(ddog_SpanBytes *ptr, const char *key);

bool ddog_has_span_meta_zstr(ddog_SpanBytes *ptr, struct _zend_string *key);

bool ddog_has_span_meta_str(ddog_SpanBytes *ptr, const char *key);

ddog_CharSlice ddog_get_span_meta_str(ddog_SpanBytes *span, const char *key);

void ddog_add_span_metrics_zstr(ddog_SpanBytes *ptr, struct _zend_string *key, double val);

bool ddog_has_span_metrics_zstr(ddog_SpanBytes *ptr, struct _zend_string *key);

void ddog_del_span_metrics_zstr(ddog_SpanBytes *ptr, struct _zend_string *key);

void ddog_add_span_metrics_str(ddog_SpanBytes *ptr, const char *key, double val);

bool ddog_get_span_metrics_str(ddog_SpanBytes *ptr, const char *key, double *result);

void ddog_del_span_metrics_str(ddog_SpanBytes *ptr, const char *key);

void ddog_add_span_meta_struct_zstr(ddog_SpanBytes *ptr,
struct _zend_string *key,
struct _zend_string *val);

void ddog_add_zstr_span_meta_struct_CharSlice(ddog_SpanBytes *ptr,
struct _zend_string *key,
ddog_CharSlice val);

#endif /* DDTRACE_PHP_H */
Loading
Loading