Fix: Handle optional .exe suffix for process search on Windows #19982
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.
What does this PR do?
This PR addresses an inconsistency in how search_strings with exact_match: true behaves on Windows systems compared to the behavior suggested by Datadog documentation (conf.yaml.example#L76). The documentation implies equivalence to Get-Process, but this isn't always the case because the psutil library sometimes includes the .exe suffix when reporting process names on Windows.
This commit updates the search logic to correctly handle this discrepancy. Now, exact_match will reliably find Windows processes whether the search string includes the .exe suffix (e.g., "process.exe") or not (e.g., "process").
Motivation
The current behavior can lead to unexpected failures when monitoring processes on Windows using exact_match, as users might not know whether to include the .exe suffix. This was discovered after encountering difficulties getting consistent process matches.
This change improves the reliability and usability of the process integration for Windows users, making configuration simpler and less error-prone.
Review checklist (to be filled by reviewers)
qa/skip-qa
label if the PR doesn't need to be tested during QA.backport/<branch-name>
label to the PR and it will automatically open a backport PR once this one is merged