Skip to content

feat(telemetry/nodejs): add /spawn_child weblog endpoint for session ID header tests#6540

Closed
khanayan123 wants to merge 1 commit intomainfrom
claude/optimistic-tharp
Closed

feat(telemetry/nodejs): add /spawn_child weblog endpoint for session ID header tests#6540
khanayan123 wants to merge 1 commit intomainfrom
claude/optimistic-tharp

Conversation

@khanayan123
Copy link
Contributor

Summary

Adds the /spawn_child weblog endpoint and fork_child.js child script to the Node.js express4 weblog, supporting the Stable Service Instance Identifier RFC system tests.

  • GET /spawn_child?sleep=N&crash=bool&fork=bool
    • fork=true: spawns child via child_process.fork() (exec-based in Node.js despite the name)
    • fork=false: spawns child via child_process.spawn(process.execPath, ...)
    • Child inherits NODE_OPTIONS (and therefore dd-trace) from parent environment
  • fork_child.js: minimal child script that sleeps N seconds then exits (or SIGSEGVs if crash=true)

Related

Test plan

  • test_session_id_headers_across_forks — verify DD-Session-ID/DD-Root-Session-ID across fork
  • test_session_id_headers_across_spawned — verify same across exec spawn

🤖 Generated with Claude Code

Adds the /spawn_child weblog endpoint to the Node.js express4 weblog
and the fork_child.js child process script. These support
test_session_id_headers_across_forks and test_session_id_headers_across_spawned
from the Stable Service Instance Identifier RFC validation suite.

- GET /spawn_child?sleep=N&crash=bool&fork=bool
  - fork=true: uses child_process.fork() (exec-based in Node.js)
  - fork=false: uses child_process.spawn(process.execPath, ...)
  - fork_child.js: sleeps N seconds, optionally crashes with SIGSEGV

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@khanayan123 khanayan123 requested review from a team as code owners March 19, 2026 16:29
@khanayan123 khanayan123 marked this pull request as draft March 19, 2026 16:29
@github-actions
Copy link
Contributor

CODEOWNERS have been resolved as:

utils/build/docker/nodejs/express/fork_child.js                         @DataDog/dd-trace-js @DataDog/system-tests-core
utils/build/docker/nodejs/express/app.js                                @DataDog/dd-trace-js @DataDog/system-tests-core

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ac6ae93795

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +1 to +3
#!/usr/bin/env node
// Child process for spawn_child endpoint. Args: sleep (seconds), crash (true|false).
const sleepSec = parseInt(process.argv[2] || '2', 10) * 1000

Choose a reason for hiding this comment

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

P1 Badge Preload dd-trace in the spawned child process

In the express4/express5/uds-express4 images I checked (utils/build/docker/nodejs/express4.Dockerfile, utils/build/docker/nodejs/express5.Dockerfile, and utils/build/docker/nodejs/app.sh), the weblog is started as node app.js and never sets NODE_OPTIONS/--require dd-trace. Because this child script only sleeps and exits, both the new fork() and spawn() paths will launch an uninstrumented Node process, so the session-ID header tests this endpoint is meant to support will not observe any child telemetry or DD-Session-ID/DD-Root-Session-ID headers on the standard express weblogs.

Useful? React with 👍 / 👎.

@khanayan123 khanayan123 deleted the claude/optimistic-tharp branch March 19, 2026 16:37
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.

1 participant