-
Notifications
You must be signed in to change notification settings - Fork 409
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
feat: Added New Relic Control health check #2841
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2841 +/- ##
==========================================
+ Coverage 88.69% 97.38% +8.68%
==========================================
Files 312 314 +2
Lines 47635 47979 +344
==========================================
+ Hits 42248 46722 +4474
+ Misses 5387 1257 -4130
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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.
i know this is in draft, just called out the lack of config items defined
9ad5af4
to
79b116c
Compare
77c0af9
to
c817ebf
Compare
f2b460b
to
f093ad4
Compare
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.
I haven't completely reviewed but a few comments. Also I don't see tests for every health status. At the very least we should have already have tests for STATUS_HEALTHY
, STATUS_INVALID_LICENSE_KEY
, STATUS_AGENT_DISABLED
, STATUS_CONNECT_ERROR
lib/config/default.js
Outdated
* to true health monitoring. | ||
*/ | ||
enabled: { | ||
env: 'NEW_RELIC_AGENT_CONTROL_ENABLED', |
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.
these env overrides are not necessary. it defaults to NEW_RELIC_
path to config value
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.
Are you suggesting to not provide default values? I don't understand the review 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.
Oh, you're saying that { agent_control: { enabled } }
will already be parsed from NEW_RELIC_AGENT_CONTROL_ENABLED
regardless of setting the env
key. I was unaware of that. Are you strongly against setting the env
key? It is clearer to me.
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.
this key is for overrides. it'll default to what you provided so it just confuses things. we default all env vars here
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.
I am against it because this was built to derive env vars. In fact before I built that support here we had drift and was constantly fixing one offs. The intent of the env key is to specify overrides when it doesn't fit our convention.
- an override if the env var does not follow our standard convention. We should not have
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.
maybe we can add PR separately and rename it envOverride
or something, or we could document the structure better
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.
Yeah, renaming it to envVarNameOverride
would be a lot clearer. I'll go ahead and remove them.
36069fc
to
39b0959
Compare
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.
After re-reviewing spec, there are a few codes that are missing/in the wrong spot:
code | status | notes |
---|---|---|
NR-APM-000 | Healthy | ✅ |
NR-APM-001 | Invalid license key (HTTP status code 401) | This occurs in lib/collector/api . You should be able to use this._agent.healthReporter to properly log these here |
NR-APM-002 | License key missing in configuration | ✅ |
NR-APM-003 | Forced disconnect received from New Relic (HTTP status code 410) | TThis occurs in lib/collector/api . You should be able to use this._agent.healthReporter to properly log these here |
NR-APM-004 | HTTP error response code [%s] received from New Relic while sending data type [%s] | I'm not sure on this one |
NR-APM-005 | Missing application name in agent configuration | ✅ |
NR-APM-006 | The maximum number of configured app names (3) exceeded | it does not appear we check for this |
NR-APM-007 | HTTP Proxy configuration error; response code [%s] | This occurs in lib/collector/api . You should be able to use this._agent.healthReporter to properly log these here |
NR-APM-008 | Agent is disabled via configuration | ✅ |
NR-APM-009 | Failed to connect to New Relic data collector | I'm not sure if this is getting conflated with the 410 error above |
NR-APM-010 | Agent config file is not able to be parsed | we're missing this: node-newrelic/index.js at main · newrelic/node-newrelic, however I don't get this because we cannot use the health reporter until the config is parsed. UPDATE: seems like we can ignore this because this case can never be hit for us |
NR-APM-099 | Agent has shutdown SHOULD only be reported if agent is "healthy" on shutdown | ✅ |
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.
Looking good. I finally did a thorough pass and called out some missing status codes or they are not in the correct place. there are also merge conflicts with main
dd10e72
to
d3dc7be
Compare
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.
One last test, asserting that we're setting the agent disabled status. Looks like we have or the next few subsequent tests
test('should not throw with valid config', () => {
const config = configurator.initialize({ agent_enabled: false })
const agent = new Agent(config)
assert.equal(agent.config.agent_enabled, false)
})
We can't do that. Our "agent" doesn't get created if Lines 92 to 106 in 6cde2e4
But I updated the test to cover the lines in the agent start. It's just never going to actually matter. |
5e95222
to
fa75a20
Compare
fa75a20
to
454c4c5
Compare
This PR resolves #2838.