Skip to content
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

Fix: Handle optional .exe suffix for process search on Windows #19982

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

clmoreno
Copy link

@clmoreno clmoreno commented Apr 1, 2025

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)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Add the qa/skip-qa label if the PR doesn't need to be tested during QA.
  • If you need to backport this PR to another branch, you can add the backport/<branch-name> label to the PR and it will automatically open a backport PR once this one is merged

clmoreno added 2 commits April 1, 2025 15:46
The `psutil` library sometimes includes the `.exe` suffix when reporting process names on Windows systems. This commit updates the search logic to correctly handle this discrepancy. Now, `exact_match` will work reliably for Windows users whether they search for "process" or "process.exe".
The `psutil` library sometimes includes the `.exe` suffix when reporting process names on Windows systems. This commit updates the search logic to correctly handle this discrepancy. Now, `exact_match` will work reliably for Windows users whether they search for "process" or "process.exe".
Copy link

codecov bot commented Apr 1, 2025

Codecov Report

Attention: Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.

Project coverage is 88.68%. Comparing base (93d9582) to head (5630d0b).

Additional details and impacted files
Flag Coverage Δ
activemq ?
cassandra ?
hive ?
hivemq ?
hudi ?
ignite ?
jboss_wildfly ?
kafka ?
presto ?
process 85.75% <0.00%> (-0.25%) ⬇️
solr ?

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@julien-lebot
Copy link
Contributor

Thanks for the PR! Could you add a test in https://github.com/DataDog/integrations-core/blob/master/process/tests/test_process.py?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants