Skip to content

Forward DATADOG_TRACE_ID/PARENT_ID through sudo apt-get install#422

Open
julesmcrt wants to merge 3 commits intomainfrom
jules.macret/forward-trace-ids-apt-install
Open

Forward DATADOG_TRACE_ID/PARENT_ID through sudo apt-get install#422
julesmcrt wants to merge 3 commits intomainfrom
jules.macret/forward-trace-ids-apt-install

Conversation

@julesmcrt
Copy link
Copy Markdown

Summary

On apt-based systems the sudo bash -c \"... apt-get install ...\" wrapper was not re-injecting DATADOG_TRACE_ID / DATADOG_PARENT_ID, so the agent's post-install hook (which invokes datadog-installer) lost the trace context and started a fresh, detached trace. The yum path at line ~1485 already forwards these two variables; this PR adds them to the apt path at line ~1692 for consistency.

Why it was broken

sudo defaults to env_reset, stripping arbitrary environment variables. The install-script explicitly re-injects DD_API_KEY, DD_SITE, DD_OTELCOLLECTOR_ENABLED, DD_INSTALLER_REGISTRY_URL, POLICYRCD through the bash -c "VAR=... apt-get install ..." pattern — but DATADOG_TRACE_ID and DATADOG_PARENT_ID were missing from that list, so dpkg/postinst/datadog-installer ran with no trace context.

Observed symptom

End-to-end install on Debian 12:

  • Install-script root span (service datadog-linux-install-script, trace_id 17497704010924348704) ✓
  • Agent post-install datadog-installer spans — appeared under an unrelated trace id ✗

After this patch the datadog-installer spans from postinst join the install-script trace as child spans, matching the behavior the yum path has today.

Scope

  • Single line in install_script.sh.template (line 1692)
  • CHANGELOG entry
  • Generated install_script_agent*.sh files are not tracked; CI regenerates them at release.

Test plan

  • Patched template rendered via make install_script_agent7.sh
  • Ran end-to-end on a fresh Debian 12 VM against a staging pipeline (108335127), confirmed datadog-installer postinst spans now share the install-script trace id
  • Unit tests in unit_tests/ (no new tests needed — this only adds env-forwarding parity with the existing yum path)

🤖 Generated with Claude Code

The yum install path already forwards DATADOG_TRACE_ID and
DATADOG_PARENT_ID through the sudo bash -c wrapper so the agent's
post-install hooks (which invoke datadog-installer) can pick them up
via env and join the install-script trace. The apt path was missing
these two variables, so on Debian/Ubuntu the datadog-installer spans
were emitted under a fresh, detached trace rather than under the
install-script root span.

sudo strips environment variables by default (env_reset), which is why
the wrapper explicitly re-injects DD_API_KEY, DD_SITE, etc. This
commit adds the two DATADOG_* trace-propagation variables to the same
list so apt-based installs get the same end-to-end trace view as yum.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@julesmcrt julesmcrt requested review from a team as code owners April 20, 2026 12:35
@julesmcrt julesmcrt requested review from tedkahwaji and removed request for a team April 20, 2026 12:35
@arbll arbll requested a review from a team as a code owner April 21, 2026 11:25
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.

3 participants