Forward DATADOG_TRACE_ID/PARENT_ID through sudo apt-get install#422
Open
Forward DATADOG_TRACE_ID/PARENT_ID through sudo apt-get install#422
Conversation
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>
BaptisteFoy
approved these changes
Apr 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On apt-based systems the
sudo bash -c \"... apt-get install ...\"wrapper was not re-injectingDATADOG_TRACE_ID/DATADOG_PARENT_ID, so the agent's post-install hook (which invokesdatadog-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
sudodefaults toenv_reset, stripping arbitrary environment variables. The install-script explicitly re-injectsDD_API_KEY,DD_SITE,DD_OTELCOLLECTOR_ENABLED,DD_INSTALLER_REGISTRY_URL,POLICYRCDthrough thebash -c "VAR=... apt-get install ..."pattern — butDATADOG_TRACE_IDandDATADOG_PARENT_IDwere missing from that list, sodpkg/postinst/datadog-installerran with no trace context.Observed symptom
End-to-end install on Debian 12:
datadog-linux-install-script, trace_id17497704010924348704) ✓datadog-installerspans — appeared under an unrelated trace id ✗After this patch the
datadog-installerspans frompostinstjoin the install-script trace as child spans, matching the behavior the yum path has today.Scope
install_script.sh.template(line 1692)install_script_agent*.shfiles are not tracked; CI regenerates them at release.Test plan
make install_script_agent7.sh108335127), confirmeddatadog-installerpostinst spans now share the install-script trace idunit_tests/(no new tests needed — this only adds env-forwarding parity with the existing yum path)🤖 Generated with Claude Code