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

NR Control Health Checks #1250

Merged
merged 16 commits into from
Dec 18, 2024
Merged

NR Control Health Checks #1250

merged 16 commits into from
Dec 18, 2024

Conversation

umaannamalai
Copy link
Contributor

Before contributing, please read our contributing guidelines and code of conduct.

Overview

Describe the changes present in the pull request

Related Github Issue

Include a link to the related GitHub issue, if applicable

Testing

The agent includes a suite of tests which should be used to
verify your changes don't break existing functionality. These tests will run with
Github Actions when a pull request is made. More details on running the tests locally can be found
here,
For most contributions it is strongly recommended to add additional tests which
exercise your changes.

Copy link

github-actions bot commented Nov 8, 2024

🦙 MegaLinter status: ❌ ERROR

Descriptor Linter Files Fixed Errors Elapsed time
✅ PYTHON bandit 6 0 6.72s
✅ PYTHON black 9 6 0 3.22s
❌ PYTHON flake8 9 5 1.41s
✅ PYTHON isort 9 9 0 0.27s
✅ PYTHON pylint 9 0 10.3s

See detailed report in MegaLinter reports
Set VALIDATE_ALL_CODEBASE: true in mega-linter.yml to validate all sources, not only the diff

MegaLinter is graciously provided by OX Security

@mergify mergify bot added the tests-failing label Nov 8, 2024
@codecov-commenter
Copy link

codecov-commenter commented Nov 8, 2024

Codecov Report

Attention: Patch coverage is 87.36842% with 24 lines in your changes missing coverage. Please review.

Please upload report for BASE (super-agent@5e48f62). Learn more about missing BASE report.

Files with missing lines Patch % Lines
newrelic/core/super_agent_health.py 91.05% 8 Missing and 3 partials ⚠️
newrelic/config.py 85.29% 4 Missing and 1 partial ⚠️
newrelic/core/application.py 69.23% 3 Missing and 1 partial ⚠️
newrelic/core/agent.py 60.00% 1 Missing and 1 partial ⚠️
newrelic/core/agent_protocol.py 86.66% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@              Coverage Diff               @@
##             super-agent    #1250   +/-   ##
==============================================
  Coverage               ?   81.22%           
==============================================
  Files                  ?      202           
  Lines                  ?    22352           
  Branches               ?     3545           
==============================================
  Hits                   ?    18155           
  Misses                 ?     3020           
  Partials               ?     1177           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

newrelic/config.py Outdated Show resolved Hide resolved
newrelic/config.py Outdated Show resolved Hide resolved
newrelic/core/super_agent_health.py Outdated Show resolved Hide resolved
newrelic/core/super_agent_health.py Outdated Show resolved Hide resolved
newrelic/core/super_agent_health.py Outdated Show resolved Hide resolved
tests/agent_features/test_super_agent_health_check.py Outdated Show resolved Hide resolved
tests/agent_features/test_super_agent_health_check.py Outdated Show resolved Hide resolved
tests/agent_features/test_super_agent_health_check.py Outdated Show resolved Hide resolved
tests/agent_unittests/test_agent_protocol.py Outdated Show resolved Hide resolved
@TimPansino TimPansino force-pushed the super-agent-health-status branch from aad0176 to 4b95e2f Compare December 13, 2024 20:04
@TimPansino
Copy link
Contributor

There were way too many string comparisons and hard coded strings going on in the super agent health file, so I've refactored it somewhat.

I'm looking for it to use integers in every conceivable spot to minimize string comparisons and copies, as well as reduce the risk of a future change introducing bugs because we're comparing status messages that are hard coded in 2 places, rather than using integer codes.

To that end, I've redone the file to use the original integer codes as the enum values, eliminated all cases where we have a string like NR-APM-003, and instead construct those when writing out to the file. I removed all hard coded references and replaced them with integers referenced via enum.

I also removed the large block of logic to construct different status messages and modeled it somewhat after the logic used in newrelic/core/agent_protocol.py to always attempt to format the string with the passed in values, and rely on string formatting to throw away unused values.

@TimPansino TimPansino force-pushed the super-agent-health-status branch from 4b95e2f to 3ac48d5 Compare December 13, 2024 20:12
Co-authored-by: Timothy Pansino <[email protected]>
@umaannamalai umaannamalai marked this pull request as ready for review December 13, 2024 21:30
@umaannamalai umaannamalai requested a review from a team as a code owner December 13, 2024 21:30
Copy link
Contributor

@hmstepanek hmstepanek left a comment

Choose a reason for hiding this comment

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

Looks good!

@umaannamalai umaannamalai merged commit 1279a52 into super-agent Dec 18, 2024
49 of 51 checks passed
@umaannamalai umaannamalai deleted the super-agent-health-status branch December 18, 2024 22:53
@mergify mergify bot removed the tests-failing label Dec 18, 2024
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