Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
8c942a0
feat(profiling): publish Linux OTel contexts
morrisonlevi Jul 29, 2026
f57acd4
feat(appsec): consume Linux OTel contexts
morrisonlevi Jul 30, 2026
29841a6
Revert "feat(appsec): consume Linux OTel contexts"
morrisonlevi Jul 30, 2026
e719b9a
fix(ci): preserve Linux exports in debug relinking
morrisonlevi Jul 30, 2026
8d01de4
fix(ci): package OTel thread context crate for PECL
morrisonlevi Jul 30, 2026
7023e5d
fix(otel): keep request metadata in thread context
morrisonlevi Jul 30, 2026
735982f
fix: use lossy UTF8 conversions on process ctx
morrisonlevi Jul 31, 2026
27c0cc2
feat(otel): publish thread context from tracer
morrisonlevi Jul 31, 2026
eb61795
perf(otel): resolve TLS slot when creating roots
morrisonlevi Aug 1, 2026
4a99a69
fix(profiling): pthread_self/gettid mismatch
morrisonlevi Aug 3, 2026
ec7721a
Merge remote-tracking branch 'origin/master' into feat/otel-context
morrisonlevi Aug 3, 2026
99ca0f1
build: use one .sym file
morrisonlevi Aug 3, 2026
bbe1256
Merge remote-tracking branch 'origin/master' into feat/otel-context
morrisonlevi Aug 4, 2026
facef41
fix(ci): export OTel TLS symbol from SSI library
morrisonlevi Aug 4, 2026
d2c2ddb
test(otel): account for PHP 8.5 compatibility gaps
morrisonlevi Aug 4, 2026
e6ac755
Revert "test(otel): account for PHP 8.5 compatibility gaps"
morrisonlevi Aug 4, 2026
5d4a025
Merge remote-tracking branch 'origin/master' into feat/otel-context
morrisonlevi Aug 4, 2026
e23e7ba
Merge remote-tracking branch 'origin/master' into feat/otel-context
morrisonlevi Aug 4, 2026
559b249
build: use Clang for CentOS sidecar jobs
morrisonlevi Aug 4, 2026
e86b98d
Merge remote-tracking branch 'origin/master' into feat/otel-context
morrisonlevi Aug 4, 2026
faa11dd
test(profiling): isolate process context cache
morrisonlevi Aug 4, 2026
f2a9926
test(otel): skip process context fork test under Valgrind
morrisonlevi Aug 5, 2026
59db525
refactor(otel): define thread context TLS in tracer
morrisonlevi Aug 5, 2026
532672b
refactor(otel): build process identity in Rust
morrisonlevi Aug 5, 2026
29ebb0b
refactor(profiling): borrow cached process identity
morrisonlevi Aug 5, 2026
4764b0b
refactor(profiling): carry identity on all platforms
morrisonlevi Aug 5, 2026
879c6ec
refactor(profiling): inline process context refresh
morrisonlevi Aug 5, 2026
bc6a66e
refactor(otel): simplify attribute generation update
morrisonlevi Aug 5, 2026
3d38747
refactor(otel): only detach thread context after fork
morrisonlevi Aug 5, 2026
dfac14f
refactor(tracing): release traceparent after parsing
morrisonlevi Aug 5, 2026
79ada60
fix(tracing): preserve flags when changing trace ID
morrisonlevi Aug 5, 2026
1901f6f
docs(otel): explain attribute refresh generation
morrisonlevi Aug 5, 2026
15ab88e
refactor(otel): use default target metadata helper
morrisonlevi Aug 5, 2026
f6f6670
fix(otel): preserve context across stack transitions
morrisonlevi Aug 5, 2026
76d1d6f
Merge remote-tracking branch 'origin/master' into feat/otel-context
morrisonlevi Aug 6, 2026
fd8222e
test(profiling): avoid needless option dereference
morrisonlevi Aug 6, 2026
dac4655
perf(profiling): outline process context refresh
morrisonlevi Aug 6, 2026
e542002
fix(profiling): back off process context refreshes
morrisonlevi Aug 6, 2026
5169687
style(profiling): cargo +nightly fmt
morrisonlevi Aug 6, 2026
95da8df
fix: otel_process_context_publish
morrisonlevi Aug 6, 2026
dfa28ad
refactor(otel): publish process context directly
morrisonlevi Aug 6, 2026
d151e8b
fix(otel): correct OpenTelemetry module dependency name
morrisonlevi Aug 6, 2026
e224882
fix(profiling): discover OTel context providers
morrisonlevi Aug 6, 2026
0c59714
Merge remote-tracking branch 'origin/master' into feat/otel-context
morrisonlevi Aug 6, 2026
acf8c35
Merge remote-tracking branch 'origin/master' into feat/otel-context
morrisonlevi Aug 6, 2026
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
3 changes: 2 additions & 1 deletion .gitlab/build-sidecar.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ fi

SHARED=1 PROFILE=tracer-release host_os="${HOST_OS}" ./compile_rust.sh
cp -v "${CARGO_TARGET_DIR:-target}/tracer-release/libdatadog_php.a" "libdatadog_php_$(uname -m)${suffix}.a"
objcopy --compress-debug-sections "${CARGO_TARGET_DIR:-target}/tracer-release/libdatadog_php.so" "libdatadog_php_$(uname -m)${suffix}.so"
output="libdatadog_php_$(uname -m)${suffix}.so"
objcopy --compress-debug-sections "${CARGO_TARGET_DIR:-target}/tracer-release/libdatadog_php.so" "${output}"
7 changes: 6 additions & 1 deletion .gitlab/compile_extension.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,10 @@ make -j static &
wait

# Link extension
sed -i 's/-export-symbols .*\/datadog\.sym/-Wl,--retain-symbols-file=datadog.sym/g' ${EXTENSION_DIR}/ddtrace.ldflags
if [ "$(uname -s)" = "Linux" ]; then
export_symbols_file="datadog-linux.sym"
else
export_symbols_file="datadog.sym"
fi
sed -i -E "s#-export-symbols [^ ]+#-Wl,--retain-symbols-file=${export_symbols_file}#g" "${EXTENSION_DIR}/ddtrace.ldflags"
cc -shared -Wl,-whole-archive ${MODULES_DIR}/ddtrace.a -Wl,-no-whole-archive $(cat ${EXTENSION_DIR}/ddtrace.ldflags) ${CARGO_TARGET_DIR}/debug/libdatadog_php.a -Wl,-soname -Wl,ddtrace.so -o ${MODULES_DIR}/ddtrace.so
6 changes: 5 additions & 1 deletion .gitlab/link-tracing-extension.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ set -e -o pipefail

suffix="${1:-}"

sed -i 's/-export-symbols .*\/datadog\.sym/-Wl,--retain-symbols-file=datadog.sym/g' "ddtrace_$(uname -m)${suffix}.ldflags"
export_symbols_file="datadog.sym"
if [ "$(uname -s)" = "Linux" ]; then
export_symbols_file="datadog-linux.sym"
fi
sed -i -E "s#-export-symbols [^ ]+#-Wl,--retain-symbols-file=${export_symbols_file}#g" "ddtrace_$(uname -m)${suffix}.ldflags"
pids=()
for archive in extensions_$(uname -m)/*.a; do
(
Expand Down
4 changes: 4 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 9 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,21 @@ inherits = "release"
# level, so they are mirrored here too.
[workspace.dependencies]
anyhow = { version = "1.0", default-features = false }
arc-swap = "1.7.1"
hyper = { version = "1.6", features = [
"http1",
"client",
], default-features = false }
hyper-util = { version = "0.1.10", features = [
"http1",
"client",
"client-legacy",
] }
arc-swap = { version = "1.7.1", default-features = false }
futures = { version = "0.3", default-features = false }
hyper = { version = "1.6", default-features = false }
hyper-util = { version = "0.1.10", default-features = false }
io-lifetimes = { version = "1.0", default-features = false }
libc = { version = "0.2", default-features = true }
prost-build = { version = "0.14.1", default-features = false }
protoc-bin-vendored = { version = "3.0.0", default-features = false }
rustls = { version = "0.23", default-features = false }
serde = { version = "1.0", default-features = false }
serde_json = { version = "1.0", default-features = false, features = ["alloc"] }
syn = { version = "^2", default-features = false }
tokio = { version = "1.36", default-features = false }
tracing = { version = "0.1", default-features = false }
uuid = { version = "1.7.0", default-features = false }

[workspace.lints]
# empty for compat with libdatadog
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ RUN_TESTS_CMD := DD_SERVICE= DD_ENV= REPORT_EXIT_STATUS=1 TEST_PHP_SRCDIR=$(PROJ

C_FILES = $(shell find components components-rs ext src/dogstatsd tracer zend_abstract_interface -name '*.c' -o -name '*.h' | awk '{ printf "$(BUILD_DIR)/%s\n", $$1 }' )
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 }' )
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/{build-common,datadog-ffe,datadog-ipc,datadog-ipc-macros,datadog-live-debugger,datadog-live-debugger-ffi,libdd-remote-config,datadog-sidecar,datadog-sidecar-ffi,datadog-sidecar-macros,libdd-alloc,libdd-capabilities,libdd-capabilities-impl,libdd-common,libdd-common-ffi,libdd-crashtracker,libdd-crashtracker-ffi,libdd-data-pipeline,libdd-ddsketch,libdd-dogstatsd-client,libdd-library-config,libdd-library-config-ffi,libdd-log,libdd-shared-runtime,libdd-telemetry,libdd-telemetry-ffi,libdd-tinybytes,libdd-trace-*,spawn_worker,tools/{cc_utils,sidecar_mockgen},libdd-trace-*,Cargo.toml} \( -type l -o -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")
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/{build-common,datadog-ffe,datadog-ipc,datadog-ipc-macros,datadog-live-debugger,datadog-live-debugger-ffi,libdd-remote-config,datadog-sidecar,datadog-sidecar-ffi,datadog-sidecar-macros,libdd-alloc,libdd-capabilities,libdd-capabilities-impl,libdd-common,libdd-common-ffi,libdd-crashtracker,libdd-crashtracker-ffi,libdd-data-pipeline,libdd-ddsketch,libdd-dogstatsd-client,libdd-library-config,libdd-library-config-ffi,libdd-log,libdd-otel-thread-ctx,libdd-shared-runtime,libdd-telemetry,libdd-telemetry-ffi,libdd-tinybytes,libdd-trace-*,spawn_worker,tools/{cc_utils,sidecar_mockgen},libdd-trace-*,Cargo.toml} \( -type l -o -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")
ALL_OBJECT_FILES = $(C_FILES) $(RUST_FILES) $(BUILD_DIR)/Makefile
TEST_OPCACHE_FILES = $(shell find tests/opcache -name '*.php*' -o -name '.gitkeep' | awk '{ printf "$(BUILD_DIR)/%s\n", $$1 }' )
TEST_STUB_FILES = $(shell find tests/ext -type d -name 'stubs' -exec find '{}' -type f \; | awk '{ printf "$(BUILD_DIR)/%s\n", $$1 }' )
Expand Down 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
4 changes: 2 additions & 2 deletions appsec/cmake/ddtrace.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ add_custom_target(libdatadog_stamp
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
set(EXPORTS_FILE "${CMAKE_BINARY_DIR}/ddtrace_exports.version")
add_custom_target(ddtrace_exports
COMMAND bash -c "{ echo -e '{\\nglobal:'; sed 's/$/;/' '${CMAKE_SOURCE_DIR}'/../datadog.sym; echo -e 'local:\\n*;\\n};'; } > '${EXPORTS_FILE}'"
COMMAND bash -c "{ echo -e '{\\nglobal:'; sed 's/$/;/' '${CMAKE_SOURCE_DIR}'/../datadog-linux.sym; echo -e 'local:\\n*;\\n};'; } > '${EXPORTS_FILE}'"
BYPRODUCTS ${EXPORTS_FILE}
DEPENDS ${CMAKE_SOURCE_DIR}/../datadog.sym
DEPENDS ${CMAKE_SOURCE_DIR}/../datadog-linux.sym
VERBATIM
)
elseif(APPLE)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this will build on mac os as is, as it appears to include linux only sources.

And the linux part doesn't add -mtls-dialect=gnu2.

But not critical as I promised the cmake ddtrace build would not be a maintenance burden :p

Expand Down
3 changes: 3 additions & 0 deletions components-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ libc = "0.2"
bincode = { version = "1.3.3" }
hashbrown = "0.15"

[target.'cfg(target_os = "linux")'.dependencies]
libdd-library-config = { path = "../libdatadog/libdd-library-config", default-features = false, features = ["otel-thread-ctx"] }

[build-dependencies]
cbindgen = "0.27"

Expand Down
2 changes: 1 addition & 1 deletion components-rs/build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
fn main() {
// On Linux, set ddog_spawn_direct_entry as the ELF entry point for the
// cdylib build (libdatadog_php.so in SSI deployments). This allows ld.so
// cdylib build (libdatadog_php.so in SSI deployments). This allows ld.so
// to exec the library directly without a trampoline binary.
if std::env::var("CARGO_CFG_TARGET_OS").as_deref() == Ok("linux") {
println!("cargo:rustc-cdylib-link-arg=-Wl,-e,ddog_spawn_direct_entry");
Expand Down
5 changes: 5 additions & 0 deletions components-rs/datadog.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ void datadog_generate_session_id(void);

void datadog_format_runtime_id(uint8_t (*buf)[36]);

#ifdef __linux__
bool datadog_publish_otel_process_context(ddog_CharSlice process_tags);

#endif

ddog_CharSlice ddtrace_get_container_id(void);

void ddtrace_set_container_cgroup_path(ddog_CharSlice path);
Expand Down
66 changes: 66 additions & 0 deletions components-rs/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,72 @@ pub extern "C" fn datadog_format_runtime_id(buf: &mut [u8; 36]) {
unsafe { datadog_runtime_id.as_hyphenated().encode_lower(buf) };
}

#[cfg(target_os = "linux")]
fn char_slice_string(value: CharSlice<'_>) -> String {
value.to_utf8_lossy().into_owned()
}

#[cfg(target_os = "linux")]
fn hostname() -> String {
let max_len = unsafe { libc::sysconf(libc::_SC_HOST_NAME_MAX) };
let max_len = usize::try_from(max_len).unwrap_or(255);
let mut buffer = vec![0; max_len.saturating_add(1)];

if unsafe { libc::gethostname(buffer.as_mut_ptr().cast(), buffer.len()) } != 0 {
return String::new();
}

let len = buffer
.iter()
.position(|&byte| byte == 0)
.unwrap_or(buffer.len());
String::from_utf8_lossy(&buffer[..len]).into_owned()
}

/// Publish or update dd-trace-php's standard Linux OTel Process Context.
#[cfg(target_os = "linux")]
#[no_mangle]
pub extern "C" fn datadog_publish_otel_process_context(process_tags: CharSlice<'_>) -> bool {
use libdd_library_config::otel_process_ctx;
use libdd_library_config::tracer_metadata::{ThreadLocalMetadata, TracerMetadata};

let metadata = TracerMetadata {
// Safety: the runtime ID is only mutated from single-threaded contexts.
runtime_id: Some(unsafe { datadog_runtime_id.as_hyphenated().to_string() }),
tracer_language: "php".to_owned(),
tracer_version: include_str!("../VERSION").trim().to_owned(),
hostname: hostname(),
process_tags: Some(char_slice_string(process_tags)),
container_id: get_container_id().map(str::to_owned),
threadlocal_metadata: Some(ThreadLocalMetadata {
attribute_keys: vec![
"service.name".to_owned(),
"deployment.environment.name".to_owned(),
"service.version".to_owned(),
"thread.id".to_owned(),
],
..Default::default()
}),
..Default::default()
};

let mut context = metadata.to_otel_process_ctx();
// TracerMetadata emits empty resource attributes for absent optional fields to advertise
// support. These values can vary independently on every PHP request, so their values and
// resource keys must be omitted from the process-wide context. The keys remain discoverable
// through threadlocal.attribute_key_map.
if let Some(resource) = context.resource.as_mut() {
resource.attributes.retain(|attribute| {
!matches!(
attribute.key.as_str(),
"service.name" | "service.version" | "deployment.environment.name"
)
});
}
Comment on lines +143 to +154

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be better to change libdatadog not to add these when it's not provided


otel_process_ctx::publish(&context).is_ok()
}

#[must_use]
#[no_mangle]
pub extern "C" fn ddtrace_get_container_id() -> CharSlice<'static> {
Expand Down
27 changes: 25 additions & 2 deletions config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,19 @@ if test "$PHP_DDTRACE" != "no"; then
EXTRA_CFLAGS="$EXTRA_CFLAGS -Wno-microsoft-anon-tag"
])

case "$host_os:$host_cpu" in
linux*:x86_64)
AC_LIBTOOL_COMPILER_OPTION([whether -mtls-dialect=gnu2 is a valid compiler argument],
lt_cv_ddtrace_tls_dialect_gnu2,
[-mtls-dialect=gnu2], [],
[
CFLAGS="$CFLAGS -mtls-dialect=gnu2"
EXTRA_CFLAGS="$EXTRA_CFLAGS -mtls-dialect=gnu2"
],
[AC_MSG_ERROR([x86-64 Linux OTel context sharing requires compiler support for -mtls-dialect=gnu2])])
;;
esac

DD_TRACE_VENDOR_SOURCES="\
tracer/vendor/mpack/mpack.c \
tracer/vendor/mt19937/mt19937-64.c \
Expand Down Expand Up @@ -168,6 +181,12 @@ if test "$PHP_DDTRACE" != "no"; then
"
fi

case "$host_os" in
linux*)
EXTRA_TRACER_SOURCES="$EXTRA_TRACER_SOURCES tracer/otel_context.c"
;;
esac

dnl datadog.c/ddtrace.c comes first, then everything else alphabetically
DATADOG_PHP_SOURCES="$EXTRA_DATADOG_SOURCES \
ext/datadog.c
Expand Down Expand Up @@ -307,10 +326,14 @@ if test "$PHP_DDTRACE" != "no"; then
AC_CHECK_HEADER(time.h, [], [AC_MSG_ERROR([Cannot find or include time.h])])

if test "$ext_shared" = "yes"; then
dnl Only export symbols defined in datadog.sym, which should all be marked as
dnl Only export the platform's listed symbols, which should all be marked as
dnl DATADOG_PUBLIC in their source files as well.
EXTRA_CFLAGS="$EXTRA_CFLAGS -fvisibility=hidden"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -export-symbols $ext_srcdir/datadog.sym -flto -fuse-linker-plugin"
case $host_os in
linux*) DDTRACE_EXPORT_SYMBOLS="$ext_srcdir/datadog-linux.sym" ;;
*) DDTRACE_EXPORT_SYMBOLS="$ext_srcdir/datadog.sym" ;;
esac
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -export-symbols $DDTRACE_EXPORT_SYMBOLS -flto -fuse-linker-plugin"

dnl On Linux: set the ELF entry point so ddtrace.so can be exec'd directly by ld.so
dnl for sidecar spawning (no trampoline binary, no memfd, no temp files).
Expand Down
46 changes: 46 additions & 0 deletions datadog-linux.sym
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
ddtrace_close_all_spans_and_flush
datadog_get_formatted_session_id
ddtrace_get_profiling_context
ddtrace_get_root_span
datadog_process_tags_get_serialized
datadog_get_sidecar_queue_id
ddtrace_get_priority_sampling_on_span_zobj
ddtrace_set_priority_sampling_on_span_zobj
ddtrace_add_propagated_tag_on_span_zobj
datadog_runtime_id
ddtrace_user_req_add_listeners
ddtrace_ip_extraction_find
datadog_set_all_thread_vm_interrupt
datadog_get_telemetry_rc_info
datadog_metric_register_buffer
datadog_metric_add_point
ddtrace_emit_asm_event
datadog_loaded_by_ssi
datadog_ssi_forced_injection_enabled
ddtrace_guess_endpoint_from_url
ddog_remote_config_reader_for_path
ddog_remote_config_read
ddog_remote_config_reader_drop
get_module
ddog_crashtracker_entry_point
ddog_daemon_entry_point
ddog_set_rc_notify_fn
ddog_remote_config_path
ddog_remote_config_path_free
ddog_library_configurator_new
ddog_library_configurator_with_local_path
ddog_library_configurator_with_fleet_path
ddog_library_configurator_with_detect_process_info
ddog_library_configurator_get
ddog_library_config_source_to_string
ddog_library_config_drop
ddog_Error_message
ddog_Error_drop
ddog_library_configurator_drop
ddog_sidecar_enqueue_telemetry_log
ddog_sidecar_enqueue_telemetry_point
ddog_sidecar_enqueue_telemetry_metric
ddog_sidecar_connect
ddog_sidecar_ping
ddog_sidecar_transport_drop
otel_thread_ctx_v1
10 changes: 10 additions & 0 deletions ext/datadog.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "excluded_modules.h"
#include "agent_info.h"
#include "logging.h"
#include "ffi_utils.h"
#include "phpinfo.h"
#include "process_tags.h"
#include "remote_config.h"
Expand Down Expand Up @@ -547,6 +548,10 @@ static void dd_rinit_once(void) {
datadog_process_tags_first_rinit();
datadog_sidecar_update_process_tags();
}
#ifdef __linux__
zend_string *process_tags = datadog_process_tags_get_serialized();
datadog_publish_otel_process_context(dd_zend_string_to_CharSlice(process_tags));
#endif

// Uses config, cannot run earlier
#ifndef _WIN32
Expand Down Expand Up @@ -704,7 +709,12 @@ static PHP_MINFO_FUNCTION(datadog) {

void datadog_internal_handle_fork(void) {
// CHILD PROCESS
datadog_generate_runtime_id();
datadog_sidecar_handle_fork();
#ifdef __linux__
zend_string *process_tags = datadog_process_tags_get_serialized();
datadog_publish_otel_process_context(dd_zend_string_to_CharSlice(process_tags));
#endif

#ifdef DDTRACE
ddtrace_internal_handle_fork();
Expand Down
6 changes: 5 additions & 1 deletion ext/sidecar.c
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,11 @@ void datadog_sidecar_handle_fork(void) {
return;
}

datadog_force_new_instance_id();
if (datadog_sidecar_instance_id) {
ddog_sidecar_instanceId_drop(datadog_sidecar_instance_id);
datadog_sidecar_instance_id = NULL;
}
dd_set_resettable_sidecar_globals();
Comment on lines +472 to +476

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After this, datadog_force_new_instance_id becomes dead code (only called from a test function). Why not just make datadog_force_new_instance_id unconditional and call it in the beginning of datadog_internal_handle_fork ?


// After fork only one thread (the one that called fork) survives, so we only
// need to drop and reconnect the current thread's transport.
Expand Down
2 changes: 1 addition & 1 deletion libdatadog
Submodule libdatadog updated 79 files
+36 −34 Cargo.lock
+14 −4 Cargo.toml
+1 −1 bin_tests/Cargo.toml
+3 −0 builder/Cargo.toml
+2 −0 builder/src/bin/release.rs
+1 −1 datadog-ipc-macros/Cargo.toml
+3 −3 datadog-ipc/Cargo.toml
+5 −3 datadog-ipc/src/shm_stats.rs
+1 −1 datadog-live-debugger-ffi/Cargo.toml
+2 −2 datadog-live-debugger/Cargo.toml
+1 −1 datadog-sidecar-ffi/Cargo.toml
+5 −3 datadog-sidecar-ffi/src/lib.rs
+1 −1 datadog-sidecar-macros/Cargo.toml
+3 −3 datadog-sidecar/Cargo.toml
+6 −1 datadog-sidecar/src/crashtracker.rs
+4 −0 datadog-sidecar/src/service/ffe_exposures_flusher.rs
+4 −0 datadog-sidecar/src/service/ffe_metrics_flusher.rs
+27 −18 datadog-sidecar/src/service/serialized_tracer_header_tags.rs
+1 −1 libdd-agent-client/Cargo.toml
+4 −0 libdd-capabilities-impl/src/http.rs
+9 −0 libdd-capabilities-impl/src/lib.rs
+3 −0 libdd-capabilities/src/http.rs
+3 −3 libdd-common/Cargo.toml
+1 −1 libdd-crashtracker-ffi/Cargo.toml
+2 −2 libdd-crashtracker/Cargo.toml
+2 −0 libdd-data-pipeline-ffi/Cargo.toml
+1 −1 libdd-data-pipeline-ffi/cbindgen.toml
+35 −9 libdd-data-pipeline-ffi/src/trace_exporter.rs
+6 −3 libdd-data-pipeline/Cargo.toml
+12 −1 libdd-data-pipeline/src/agent_info/schema.rs
+16 −2 libdd-data-pipeline/src/agentless/exporter.rs
+11 −2 libdd-data-pipeline/src/otlp/exporter.rs
+10 −6 libdd-data-pipeline/src/trace_exporter/builder.rs
+38 −16 libdd-data-pipeline/src/trace_exporter/mod.rs
+18 −7 libdd-data-pipeline/src/trace_exporter/stats.rs
+11 −5 libdd-data-pipeline/src/trace_exporter/trace_serializer.rs
+3 −4 libdd-http-client/Cargo.toml
+1 −1 libdd-library-config/Cargo.toml
+7 −4 libdd-otel-thread-ctx-ffi/src/lib.rs
+55 −22 libdd-otel-thread-ctx/src/lib.rs
+4 −2 libdd-profiling-ffi/Cargo.toml
+58 −70 libdd-profiling-heap-allocator/benches/sampler_overhead.rs
+5 −10 libdd-profiling-heap-allocator/src/allocator.rs
+14 −1 libdd-profiling-heap-allocator/src/lib.rs
+1 −1 libdd-profiling-heap-gotter-ffi/Cargo.toml
+2 −2 libdd-profiling-heap-gotter/Cargo.toml
+33 −1 libdd-profiling-heap-gotter/tests/install.rs
+5 −0 libdd-profiling-heap-sampler/include/datadog/heap/allocation_freed.h
+4 −0 libdd-profiling-heap-sampler/include/datadog/heap/allocation_requested.h
+28 −0 libdd-profiling-heap-sampler/include/datadog/heap/probes.h
+12 −6 libdd-profiling-heap-sampler/src/generated/bindings.rs
+25 −9 libdd-profiling-heap-sampler/src/lib.rs
+17 −2 libdd-profiling-heap-sampler/src/probes.c
+2 −2 libdd-profiling/Cargo.toml
+2 −2 libdd-remote-config/Cargo.toml
+115 −1 libdd-remote-config/src/fetch/fetcher.rs
+13 −3 libdd-remote-config/src/fetch/test_server.rs
+2 −2 libdd-shared-runtime/Cargo.toml
+52 −2 libdd-shared-runtime/src/shared_runtime/fork_safe.rs
+1 −1 libdd-telemetry-ffi/Cargo.toml
+4 −4 libdd-telemetry/Cargo.toml
+0 −5 libdd-telemetry/src/worker/http_client.rs
+1 −1 libdd-telemetry/src/worker/mod.rs
+1 −1 libdd-trace-stats/Cargo.toml
+132 −14 libdd-trace-stats/src/span_concentrator/aggregation.rs
+136 −0 libdd-trace-stats/src/span_concentrator/cardinality_limit_telemetry.rs
+131 −53 libdd-trace-stats/src/span_concentrator/mod.rs
+745 −9 libdd-trace-stats/src/span_concentrator/tests.rs
+128 −22 libdd-trace-stats/src/stats_exporter.rs
+6 −4 libdd-trace-utils/Cargo.toml
+29 −62 libdd-trace-utils/src/send_data/mod.rs
+50 −0 libdd-trace-utils/src/send_with_retry/compression.rs
+24 −2 libdd-trace-utils/src/send_with_retry/mod.rs
+3 −3 libdd-trace-utils/src/trace_utils.rs
+50 −37 libdd-trace-utils/src/tracer_header_tags.rs
+6 −4 libdd-trace-utils/src/tracer_metadata.rs
+1 −2 libdd-tracer-flare/Cargo.toml
+2 −2 spawn_worker/Cargo.toml
+2 −2 tests/spawn_from_lib/Cargo.toml
1 change: 1 addition & 0 deletions loader/dd_library_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ injected_ext ddloader_injected_ext_config[EXT_COUNT] = {
ZEND_MOD_OPTIONAL("ddtrace")
ZEND_MOD_OPTIONAL("ddtrace_injected")
ZEND_MOD_OPTIONAL("datadog-profiling")
ZEND_MOD_OPTIONAL("opentelemetry")
ZEND_MOD_OPTIONAL("ev")
ZEND_MOD_OPTIONAL("event")
ZEND_MOD_OPTIONAL("libevent")
Expand Down
1 change: 1 addition & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ ${changelog}
<!-- code, PHP and test files -->${codefiles}
<file name="config.m4" role="src" />
<file name="config.w32" role="src" />
<file name="datadog-linux.sym" role="src" />
<file name="datadog.sym" role="src" />
<file name="compile_rust.sh" role="src" />
<file name="VERSION" role="src" />
Expand Down
4 changes: 4 additions & 0 deletions profiling/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ uuid = { version = "1.0", features = ["v4"] }
[target.'cfg(target_vendor = "apple")'.dependencies]
mach2 = "0.6.0"

[target.'cfg(target_os = "linux")'.dependencies]
libdd-library-config = { path = "../libdatadog/libdd-library-config", default-features = false, features = ["process-context-reader"] }
libdd-trace-protobuf = { path = "../libdatadog/libdd-trace-protobuf" }

[dependencies.tracing-subscriber]
version = "0.3"
optional = true
Expand Down
Loading
Loading