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
10 changes: 5 additions & 5 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion crates/process_discovery/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ crate-type = ["cdylib", "rlib"]

[dependencies]
anyhow = "1"
libdd-library-config = { git = "https://github.com/DataDog/libdatadog.git", tag = "v29.0.0" }
libdd-library-config = { git = "https://github.com/DataDog/libdatadog.git", tag = "v35.0.0", features = ["otel-thread-ctx"] }

napi = { version = "2" }
napi-derive = { version = "2", default-features = false }
11 changes: 11 additions & 0 deletions crates/process_discovery/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ pub struct TracerMetadata {
pub service_version: Option<String>,
pub process_tags: Option<String>,
pub container_id: Option<String>,
/// Ordered list of attribute key names for thread-level OTEP-4947
/// context records. Key indices on the wire index into this list.
/// libdatadog's OTel process-context conversion prepends the
/// implicit `datadog.local_root_span_id` entry at wire index 0, so
/// callers should only set their additional keys here — entry 0 in
/// this list corresponds to wire key index 1.
///
/// `null`/omitted (the default) disables the thread-context-related
/// attributes in the OTel process context entirely.
pub threadlocal_attribute_keys: Option<Vec<String>>,
}

#[napi]
Expand All @@ -36,6 +46,7 @@ pub fn store_metadata(data: &TracerMetadata) -> napi::Result<NapiAnonymousFileHa
service_version: data.service_version.clone(),
process_tags: data.process_tags.clone(),
container_id: data.container_id.clone(),
threadlocal_attribute_keys: data.threadlocal_attribute_keys.clone(),
});

match res {
Expand Down
21 changes: 21 additions & 0 deletions test/process-discovery.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,27 @@ const metadata = new process_discovery.TracerMetadata(
const cfg_handle = process_discovery.storeMetadata(metadata)
assert(cfg_handle !== undefined)

// Same shape, plus a thread-local attribute key map (OTEP-4947). libdatadog
// implicitly prepends `datadog.local_root_span_id` at wire index 0; entries
// here start at wire index 1.
const metadata_with_threadlocal = new process_discovery.TracerMetadata(
'7938685c-19dd-490f-b9b3-8aae4c22f898',
'1.0.0',
'my_hostname',
'my_svc',
'my_env',
'my_version',
undefined,
undefined,
['endpoint', 'http.status'],
)
assert.deepStrictEqual(
metadata_with_threadlocal.threadlocalAttributeKeys,
['endpoint', 'http.status'],
)
const cfg_handle_threadlocal = process_discovery.storeMetadata(metadata_with_threadlocal)
assert(cfg_handle_threadlocal !== undefined)

if (process.platform === 'linux') {
const contains_datadog_memfd = (fds) => {
for (const fd in fds) {
Expand Down
Loading