Skip to content
Merged
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
12 changes: 12 additions & 0 deletions datadog-sidecar-ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,8 @@ pub unsafe extern "C" fn ddog_sidecar_session_set_config(
process_tags: &libdd_common_ffi::Vec<Tag>,
hostname: ffi::CharSlice,
root_service: ffi::CharSlice,
root_session_id: ffi::CharSlice,
parent_session_id: ffi::CharSlice,
Comment on lines +635 to +636
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep ddog_sidecar_session_set_config ABI-compatible

Adding root_session_id and parent_session_id to this exported extern "C" symbol changes its call signature in place, which breaks binary compatibility for tracers/extensions built against the previous header but loaded with this newer shared library. In that version-skew scenario the callee reads missing arguments as garbage CharSlices and may dereference invalid memory while evaluating is_empty(), causing undefined behavior or crashes. Preserve the old symbol and add a versioned entrypoint for the extended arguments.

Useful? React with 👍 / 👎.

) -> MaybeError {
let session_id_str: String = session_id.to_utf8_lossy().into();
let session_config = SessionConfig {
Expand Down Expand Up @@ -676,6 +678,16 @@ pub unsafe extern "C" fn ddog_sidecar_session_set_config(
span_kinds_stats_computed: vec![],
hostname: hostname.to_utf8_lossy().into(),
root_service: root_service.to_utf8_lossy().into(),
root_session_id: if root_session_id.is_empty() {
None
} else {
Some(root_session_id.to_utf8_lossy().into())
},
parent_session_id: if parent_session_id.is_empty() {
None
} else {
Some(parent_session_id.to_utf8_lossy().into())
},
};
#[cfg(unix)]
try_c!(blocking::set_session_config(
Expand Down
4 changes: 4 additions & 0 deletions datadog-sidecar-ffi/tests/sidecar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ fn test_ddog_sidecar_register_app() {
&process_tags,
"".into(),
"".into(),
"".into(),
"".into(),
)
.unwrap_none();

Expand Down Expand Up @@ -167,6 +169,8 @@ fn test_ddog_sidecar_register_app() {
&process_tags,
"".into(),
"".into(),
"".into(),
"".into(),
)
.unwrap_none();

Expand Down
2 changes: 2 additions & 0 deletions datadog-sidecar/src/service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ pub struct SessionConfig {
pub hostname: String,
/// Process-level service name (from `DD_SERVICE`), used as the stats concentrator key.
pub root_service: String,
pub root_session_id: Option<String>,
pub parent_session_id: Option<String>,
}

#[derive(Debug, Deserialize, Serialize)]
Expand Down
3 changes: 3 additions & 0 deletions datadog-sidecar/src/service/sidecar_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,9 @@ impl SidecarInterface for ConnectionSidecarHandler {
cfg.telemetry_heartbeat_interval = config.telemetry_heartbeat_interval;
cfg.telemetry_extended_heartbeat_interval =
config.telemetry_extended_heartbeat_interval;
cfg.session_id = Some(session_id.clone());
cfg.parent_session_id = config.parent_session_id;
cfg.root_session_id = config.root_session_id;
});
session.modify_trace_config(|cfg| {
let endpoint = get_product_endpoint(
Expand Down
1 change: 1 addition & 0 deletions datadog-sidecar/src/service/telemetry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ impl TelemetryCachedClient {
);

builder.runtime_id = Some(instance_id.runtime_id.clone());

builder.application.env = Some(env.to_string());
builder.application.process_tags = (!process_tags.is_empty()).then(|| {
process_tags
Expand Down
Loading