Skip to content

fix: Test command line result before comparing it to Gunicorn master name #19310

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

Merged
merged 3 commits into from
Jun 23, 2025

Conversation

dax
Copy link
Contributor

@dax dax commented Dec 26, 2024

What does this PR do?

It tests the result of psutil.cmdline() before comparing its first element to the Gunicorn master process name.

Motivation

On Linux psutil.cmdline() may return an empty array (e.g. for kernel processes) making cmdline()[0] fail with an IndexError: list index out of range error.
Even if the IndexError was caught, it generates a lot of noise in logs. Moreover, as there is an attached exception to a DEBUG log, Datadog classifies it as an error which is misleading.

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

Copy link

codecov bot commented Dec 26, 2024

Codecov Report

Attention: Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.

Project coverage is 89.32%. Comparing base (e417f96) to head (2aa7778).
Report is 1 commits behind head on master.

Additional details and impacted files
Flag Coverage Δ
activemq ?
cassandra ?
confluent_platform ?
gunicorn 92.83% <91.66%> (-0.46%) ⬇️
hive ?
hivemq ?
hudi ?
ignite ?
jboss_wildfly ?
kafka ?
presto ?
solr ?
tomcat ?
weblogic ?

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.

@HadhemiDD
Copy link
Contributor

Can you add a changelog for this change?

@dax dax force-pushed the fix-gunicorn-check branch from f3228c0 to 2be1499 Compare January 8, 2025 12:46
@dax dax requested a review from a team as a code owner January 8, 2025 12:46
@dax
Copy link
Contributor Author

dax commented Jan 8, 2025

@HadhemiDD I have added a changelog line for this change.

cswatt
cswatt previously approved these changes Jan 8, 2025
Copy link
Contributor

@iliakur iliakur left a comment

Choose a reason for hiding this comment

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

@dax thanks for the contribution!

Could you add a test for this scenario please?
Also, let's add a changelog entry according to the integrations-core tab in these guidelines.

@dax dax force-pushed the fix-gunicorn-check branch from 88b99e1 to ab72542 Compare January 15, 2025 10:35
@dax
Copy link
Contributor Author

dax commented Jan 15, 2025

@iliakur I have added a test and used ddev release changelog to add a changelog entry.

iliakur
iliakur previously approved these changes Jan 22, 2025
Copy link
Contributor

@iliakur iliakur left a comment

Choose a reason for hiding this comment

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

@dax good stuff, thanks!

@temporal-github-worker-1 temporal-github-worker-1 bot dismissed iliakur’s stale review June 23, 2025 21:07

Review from iliakur is dismissed. Related teams and files:

  • agent-integrations
    • gunicorn/datadog_checks/gunicorn/gunicorn.py
@sarah-witt sarah-witt enabled auto-merge June 23, 2025 21:13
@sarah-witt sarah-witt added this pull request to the merge queue Jun 23, 2025
Merged via the queue into DataDog:master with commit df0bfdc Jun 23, 2025
29 of 31 checks passed
Kyle-Neale pushed a commit that referenced this pull request Jun 24, 2025
…name (#19310)

* fix: Test command line result before comparing it to Gunicorn master name

* Update gunicorn/datadog_checks/gunicorn/gunicorn.py

---------

Co-authored-by: Sarah Witt <sarah.witt@datadoghq.com>
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.

5 participants