Skip to content

Conversation

@ddOfir
Copy link
Contributor

@ddOfir ddOfir commented Nov 5, 2025

Add documentation explaining that Universal Service Monitoring (USM) only detects environment variables set at process start time, not those set programmatically within application code.

This clarifies that while APM instrumentation libraries can read DD_SERVICE and similar variables set via System.setProperty() (Java) or Environment.SetEnvironmentVariable() (.NET), USM cannot detect these as it reads from /proc/PID/environ (Linux) or system APIs (Windows) which only contain the initial process environment.

Includes examples for properly setting environment variables in Docker, Kubernetes, and shell environments to ensure USM detection.

What does this PR do? What is the motivation?

Add documentation explaining that Universal Service Monitoring (USM) only detects environment variables set at process start time, not those set programmatically within application code

Merge instructions

Merge readiness:

  • Ready for merge

For Datadog employees:

Your branch name MUST follow the <name>/<description> convention and include the forward slash (/). Without this format, your pull request will not pass CI, the GitLab pipeline will not run, and you won't get a branch preview. Getting a branch preview makes it easier for us to check any issues with your PR, such as broken links.

If your branch doesn't follow this format, rename it or create a new branch and PR.

[6/5/2025] Merge queue has been disabled on the documentation repo. If you have write access to the repo, the PR has been reviewed by a Documentation team member, and all of the required checks have passed, you can use the Squash and Merge button to merge the PR. If you don't have write access, or you need help, reach out in the #documentation channel in Slack.

Additional notes

Add documentation explaining that Universal Service Monitoring (USM) only
detects environment variables set at process start time, not those set
programmatically within application code.

This clarifies that while APM instrumentation libraries can read DD_SERVICE
and similar variables set via System.setProperty() (Java) or
Environment.SetEnvironmentVariable() (.NET), USM cannot detect these as it
reads from /proc/PID/environ (Linux) or system APIs (Windows) which only
contain the initial process environment.

Includes examples for properly setting environment variables in Docker,
Kubernetes, and shell environments to ensure USM detection.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@ddOfir ddOfir requested a review from guyarb November 5, 2025 18:47
@github-actions
Copy link
Contributor

github-actions bot commented Nov 5, 2025

Preview links (active after the build_preview check completes)

Modified Files

@ddOfir ddOfir marked this pull request as ready for review November 10, 2025 14:37
@ddOfir ddOfir requested a review from a team as a code owner November 10, 2025 14:37
@maycmlee maycmlee self-assigned this Nov 10, 2025
Copy link
Contributor

@maycmlee maycmlee left a comment

Choose a reason for hiding this comment

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

Some suggestions

## How USM detects service names

<div class="alert alert-warning">
<strong>Important:</strong> Universal Service Monitoring detects service names from environment variables that exist when a process starts. USM reads these values from the operating system (from <code>/proc/PID/environ</code> on Linux or via system APIs on Windows).
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<strong>Important:</strong> Universal Service Monitoring detects service names from environment variables that exist when a process starts. USM reads these values from the operating system (from <code>/proc/PID/environ</code> on Linux or via system APIs on Windows).
<strong>Important:</strong> Universal Service Monitoring detects service names from environment variables that exist when a process starts. USM reads these values from the operating system (from <code>/proc/PID/environ</code> on Linux or using system APIs on Windows).


**Key limitation:**

Setting environment variables programmatically **inside your application code** (such as `System.setProperty("dd.service", "my-service")` in Java or `Environment.SetEnvironmentVariable("DD_SERVICE", "my-service")` in .NET) will **not** be detected by USM, even though these values work for APM tracing instrumentation.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Setting environment variables programmatically **inside your application code** (such as `System.setProperty("dd.service", "my-service")` in Java or `Environment.SetEnvironmentVariable("DD_SERVICE", "my-service")` in .NET) will **not** be detected by USM, even though these values work for APM tracing instrumentation.
Environment variables programmatically set **inside your application code** (such as `System.setProperty("dd.service", "my-service")` in Java or `Environment.SetEnvironmentVariable("DD_SERVICE", "my-service")` in .NET) are **not** detected by USM, even though these values work for APM tracing instrumentation.


Setting environment variables programmatically **inside your application code** (such as `System.setProperty("dd.service", "my-service")` in Java or `Environment.SetEnvironmentVariable("DD_SERVICE", "my-service")` in .NET) will **not** be detected by USM, even though these values work for APM tracing instrumentation.

**Why this happens:**
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
**Why this happens:**
**Why USM does not detect environment variables that are set programmatically:**

@cswatt
Copy link
Contributor

cswatt commented Nov 10, 2025

Resolving merge conflict (these changes were also in #32723 leading to some conflict)

@cswatt
Copy link
Contributor

cswatt commented Nov 10, 2025

After resolving merge conflicts, changes from #32723 are now applied, and this branch has no differences from master. Closing this PR :)

@cswatt cswatt closed this Nov 10, 2025
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.

4 participants