-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Clarify USM environment variable detection limitations #32626
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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>
Preview links (active after the
|
maycmlee
left a comment
There was a problem hiding this 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). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| <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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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:** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| **Why this happens:** | |
| **Why USM does not detect environment variables that are set programmatically:** |
|
Resolving merge conflict (these changes were also in #32723 leading to some conflict) |
|
After resolving merge conflicts, changes from #32723 are now applied, and this branch has no differences from master. Closing this PR :) |
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:
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