Skip to content

Commit 20174dc

Browse files
committed
Add crashtracker support for the sidecar
Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com>
1 parent 9298487 commit 20174dc

File tree

8 files changed

+141
-55
lines changed

8 files changed

+141
-55
lines changed

Cargo.lock

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

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ RUN_TESTS_CMD := DD_SERVICE= DD_ENV= REPORT_EXIT_STATUS=1 TEST_PHP_SRCDIR=$(PROJ
4848

4949
C_FILES = $(shell find components components-rs ext src/dogstatsd zend_abstract_interface -name '*.c' -o -name '*.h' | awk '{ printf "$(BUILD_DIR)/%s\n", $$1 }' )
5050
TEST_FILES = $(shell find tests/ext -name '*.php*' -o -name '*.inc' -o -name '*.json' -o -name '*.yaml' -o -name 'CONFLICTS' | awk '{ printf "$(BUILD_DIR)/%s\n", $$1 }' )
51-
RUST_FILES = $(BUILD_DIR)/Cargo.toml $(BUILD_DIR)/Cargo.lock $(shell find components-rs -name '*.c' -o -name '*.rs' -o -name 'Cargo.toml' | awk '{ printf "$(BUILD_DIR)/%s\n", $$1 }' ) $(shell find libdatadog/{datadog-alloc,build-common,datadog-crashtracker,datadog-crashtracker-ffi,data-pipeline,ddcommon,ddcommon-ffi,ddsketch,ddtelemetry,ddtelemetry-ffi,dogstatsd-client,datadog-ipc,datadog-ipc-macros,datadog-library-config,datadog-library-config-ffi,datadog-live-debugger,datadog-live-debugger-ffi,datadog-remote-config,datadog-sidecar,datadog-sidecar-ffi,datadog-sidecar-macros,spawn_worker,tinybytes,tools/{cc_utils,sidecar_mockgen},datadog-trace-*,Cargo.toml} -type f \( -path "*/src*" -o -path "*/examples*" -o -path "*Cargo.toml" -o -path "*/build.rs" -o -path "*/tests/dataservice.rs" -o -path "*/tests/service_functional.rs" \) -not -path "*/datadog-ipc/build.rs" -not -path "*/datadog-sidecar-ffi/build.rs")
51+
RUST_FILES = $(BUILD_DIR)/Cargo.toml $(BUILD_DIR)/Cargo.lock $(shell find components-rs -name '*.c' -o -name '*.rs' -o -name 'Cargo.toml' | awk '{ printf "$(BUILD_DIR)/%s\n", $$1 }' ) $(shell find libdatadog/{datadog-alloc,build-common,datadog-crashtracker,datadog-crashtracker-ffi,data-pipeline,ddcommon,ddcommon-ffi,ddsketch,ddtelemetry,ddtelemetry-ffi,dogstatsd-client,datadog-ipc,datadog-ipc-macros,datadog-library-config,datadog-library-config-ffi,datadog-live-debugger,datadog-live-debugger-ffi,datadog-log,datadog-remote-config,datadog-sidecar,datadog-sidecar-ffi,datadog-sidecar-macros,spawn_worker,tinybytes,tools/{cc_utils,sidecar_mockgen},datadog-trace-*,Cargo.toml} -type f \( -path "*/src*" -o -path "*/examples*" -o -path "*Cargo.toml" -o -path "*/build.rs" -o -path "*/tests/dataservice.rs" -o -path "*/tests/service_functional.rs" \) -not -path "*/datadog-ipc/build.rs" -not -path "*/datadog-sidecar-ffi/build.rs")
5252
ALL_OBJECT_FILES = $(C_FILES) $(RUST_FILES) $(BUILD_DIR)/Makefile
5353
TEST_OPCACHE_FILES = $(shell find tests/opcache -name '*.php*' -o -name '.gitkeep' | awk '{ printf "$(BUILD_DIR)/%s\n", $$1 }' )
5454
TEST_STUB_FILES = $(shell find tests/ext -type d -name 'stubs' -exec find '{}' -type f \; | awk '{ printf "$(BUILD_DIR)/%s\n", $$1 }' )

components-rs/crashtracker.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,16 @@ DDOG_CHECK_RETURN
410410
struct ddog_VoidResult ddog_crasht_CrashInfo_resolve_names(struct ddog_crasht_Handle_CrashInfo *crash_info,
411411
uint32_t pid);
412412

413+
/**
414+
* # Safety
415+
* The `crash_info` can be null, but if non-null it must point to a Builder made by this module,
416+
* which has not previously been dropped.
417+
* This function will:
418+
*/
419+
DDOG_CHECK_RETURN
420+
struct ddog_VoidResult ddog_crasht_CrashInfo_enrich_callstacks(struct ddog_crasht_Handle_CrashInfo *crash_info,
421+
uint32_t pid);
422+
413423
/**
414424
* # Safety
415425
* The `crash_info` can be null, but if non-null it must point to a Builder made by this module,

components-rs/ddtrace.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ ddog_MaybeError ddog_sidecar_connect_php(struct ddog_SidecarTransport **connecti
112112
const char *error_path,
113113
ddog_CharSlice log_level,
114114
bool enable_telemetry,
115-
void (*on_reconnect)(struct ddog_SidecarTransport*));
115+
void (*on_reconnect)(struct ddog_SidecarTransport*),
116+
const struct ddog_Endpoint *crashtracker_endpoint);
116117

117118
void ddtrace_sidecar_reconnect(struct ddog_SidecarTransport **transport,
118119
struct ddog_SidecarTransport *(*factory)(void));

components-rs/sidecar.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use ddcommon::rate_limiter::{Limiter, LocalLimiter};
1414
use datadog_ipc::rate_limiter::{AnyLimiter, ShmLimiterMemory};
1515
use datadog_sidecar::service::exception_hash_rate_limiter::ExceptionHashRateLimiter;
1616
use datadog_sidecar::tracer::shm_limiter_path;
17+
use ddcommon::Endpoint;
1718
use ddcommon_ffi::slice::AsBytes;
1819
use ddcommon_ffi::{CharSlice, self as ffi, MaybeError};
1920
use ddtelemetry_ffi::try_c;
@@ -117,11 +118,13 @@ pub extern "C" fn ddog_sidecar_connect_php(
117118
log_level: CharSlice,
118119
enable_telemetry: bool,
119120
on_reconnect: Option<extern "C" fn(*mut SidecarTransport)>,
121+
crashtracker_endpoint: Option<&Endpoint>,
120122
) -> MaybeError {
121123
let mut cfg = config::FromEnv::config();
122124
cfg.self_telemetry = enable_telemetry;
123125
let appsec_cfg_guard = APPSEC_CONFIG.lock().unwrap();
124126
cfg.appsec_config = appsec_cfg_guard.clone();
127+
cfg.crashtracker_endpoint = crashtracker_endpoint.map(Clone::clone);
125128
unsafe {
126129
if *error_path != 0 {
127130
let error_path = CStr::from_ptr(error_path).to_bytes();

ddtrace.sym

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ ddog_remote_config_reader_for_path
2020
ddog_remote_config_read
2121
ddog_remote_config_reader_drop
2222
get_module
23+
ddog_crashtracker_entry_point
2324
ddog_daemon_entry_point
2425
ddog_set_rc_notify_fn
2526
ddog_remote_config_path

ext/sidecar.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ static ddog_SidecarTransport *dd_sidecar_connection_factory_ex(bool is_fork) {
164164
}
165165

166166
ddog_SidecarTransport *sidecar_transport;
167-
if (!ddtrace_ffi_try("Failed connecting to the sidecar", ddog_sidecar_connect_php(&sidecar_transport, logpath, dd_zend_string_to_CharSlice(get_global_DD_TRACE_LOG_LEVEL()), get_global_DD_INSTRUMENTATION_TELEMETRY_ENABLED(), dd_sidecar_on_reconnect))) {
167+
if (!ddtrace_ffi_try("Failed connecting to the sidecar", ddog_sidecar_connect_php(&sidecar_transport, logpath, dd_zend_string_to_CharSlice(get_global_DD_TRACE_LOG_LEVEL()), get_global_DD_INSTRUMENTATION_TELEMETRY_ENABLED(), dd_sidecar_on_reconnect, ddtrace_endpoint))) {
168168
if (dogstatsd_endpoint) {
169169
ddog_endpoint_drop(dogstatsd_endpoint);
170170
dogstatsd_endpoint = NULL;

libdatadog

Submodule libdatadog updated 68 files

0 commit comments

Comments
 (0)