Skip to content

process_discovery: expose threadlocal_attribute_keys#135

Merged
szegedi merged 1 commit into
mainfrom
otel-thread-ctx-attribute-keys
Jun 22, 2026
Merged

process_discovery: expose threadlocal_attribute_keys#135
szegedi merged 1 commit into
mainfrom
otel-thread-ctx-attribute-keys

Conversation

@szegedi

@szegedi szegedi commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds an optional threadlocal_attribute_keys: Option<Vec<String>> field to the NAPI TracerMetadata and forwards it to libdatadog's tracer_metadata::TracerMetadata. When set, libdatadog's to_otel_process_ctx injects into the OTel process context:

threadlocal.schema_version    = "tlsdesc_v1_dev"
threadlocal.attribute_key_map = ["datadog.local_root_span_id",
                                  ...threadlocal_attribute_keys]

— giving an out-of-process reader the name table for the uint8 key indices that OTEP-4947 thread-context records carry on the wire. The implicit datadog.local_root_span_id key is prepended by libdatadog itself; callers only supply their additional keys (entry 0 in this list = wire key index 1).

Motivation

A Node.js OTEP-4947 thread-context writer (currently in development in DataDog/pprof-nodejs#347, to be integrated into dd-trace-js) needs to publish its attribute key list as part of the OTel process context so that an out-of-process eBPF reader can decode the on-wire key_index bytes back to attribute names. This change is the dd-trace-js-facing piece of that plumbing.

Implementation notes

  • The field is gated behind libdatadog's otel-thread-ctx Cargo feature, which arrived after v29.0.0. The libdd-library-config dep is bumped from v29.0.0 → v35.0.0 (matching the version already pinned by the crashtracker crate in this workspace) and the feature is enabled.
  • Existing 8-arg constructor calls keep working because the new field is optional.
  • The test exercises both the absent and present forms.

Test plan

  • yarn build-debug succeeds with the bumped dependency
  • node test/process-discovery.js passes (both the existing positional call and the new threadlocal-keys variant)
  • yarn lint test/process-discovery.js clean
  • CI verifies the same on all supported Node versions / platforms

🤖 Generated with Claude Code

Add the optional `threadlocal_attribute_keys: Option<Vec<String>>`
field to the NAPI `TracerMetadata` and forward it to libdatadog's
`tracer_metadata::TracerMetadata`. When set, libdatadog's
`to_otel_process_ctx` injects:

  threadlocal.schema_version      = "tlsdesc_v1_dev"
  threadlocal.attribute_key_map   = ["datadog.local_root_span_id",
                                      ...threadlocal_attribute_keys]

into the OTel process context, giving an out-of-process reader the
name table for the uint8 key indices that OTEP-4947 thread-context
records carry on the wire. The implicit `datadog.local_root_span_id`
key is prepended by libdatadog itself; callers only supply their
*additional* keys (entry 0 in this list = wire key index 1).

The field is gated behind libdatadog's `otel-thread-ctx` Cargo
feature, which arrived after v29.0.0. Bump the
`libdd-library-config` dependency to v35.0.0 (matches the version
already pinned by the crashtracker crate in this workspace) and
enable the feature.

Existing 8-arg constructor calls keep working because the new
field is optional. The test exercises both the absent and present
forms.
@szegedi szegedi requested review from a team as code owners June 22, 2026 14:38
@github-actions

Copy link
Copy Markdown

Overall package size

Self size: 28.01 MB
Deduped: 28.01 MB
No deduping: 28.01 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------|

🤖 This report was automatically generated by heaviest-objects-in-the-universe

@szegedi szegedi merged commit 2453a51 into main Jun 22, 2026
46 checks passed
@szegedi szegedi deleted the otel-thread-ctx-attribute-keys branch June 22, 2026 14:59
@szegedi szegedi mentioned this pull request Jun 22, 2026
szegedi added a commit that referenced this pull request Jun 22, 2026
Add the optional `threadlocal_attribute_keys: Option<Vec<String>>`
field to the NAPI `TracerMetadata` and forward it to libdatadog's
`tracer_metadata::TracerMetadata`. When set, libdatadog's
`to_otel_process_ctx` injects:

  threadlocal.schema_version      = "tlsdesc_v1_dev"
  threadlocal.attribute_key_map   = ["datadog.local_root_span_id",
                                      ...threadlocal_attribute_keys]

into the OTel process context, giving an out-of-process reader the
name table for the uint8 key indices that OTEP-4947 thread-context
records carry on the wire. The implicit `datadog.local_root_span_id`
key is prepended by libdatadog itself; callers only supply their
*additional* keys (entry 0 in this list = wire key index 1).

The field is gated behind libdatadog's `otel-thread-ctx` Cargo
feature, which arrived after v29.0.0. Bump the
`libdd-library-config` dependency to v35.0.0 (matches the version
already pinned by the crashtracker crate in this workspace) and
enable the feature.

Existing 8-arg constructor calls keep working because the new
field is optional. The test exercises both the absent and present
forms.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants