-
Notifications
You must be signed in to change notification settings - Fork 404
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
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2841 +/- ##
==========================================
- Coverage 97.39% 97.36% -0.03%
==========================================
Files 308 310 +2
Lines 47330 47707 +377
==========================================
+ Hits 46099 46452 +353
- Misses 1231 1255 +24
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
79b116c
to
77c0af9
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
* 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.
*/ | ||
delivery_location: { | ||
env: 'NEW_RELIC_AGENT_CONTROL_HEALTH_DELIVERY_LOCATION', | ||
default: 'file:///var/lib/newrelic-agent_control/fleet' |
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.
the latest spec update has the default as file:///newrelic/apm/health
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 copied the example string, it seems.
return | ||
} | ||
|
||
if (outDir.includes('://') === true) { |
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.
looks like you're missing a test where the directory is a file url
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.
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.
ah, i was looking in the unit tests for health reporter, my bad
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.
actually when i run the unit tests it is still showing those lines as uncovered
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.
that's because in the test you're replacing file://
with ''
: https://github.com/jsumners-nr/node-newrelic/blob/6accc52abc4f63a98e7a10abf25af6c2634433d0/test/unit/agent/agent.test.js#L94. you should just remove the env var declaration as that takes precedence over config file. there's also a few others places it's specifying it as an env var. once it's cleaned up it'll be covered
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.
Yes, I have it covered locally.
static STATUS_INTERNAL_UNEXPECTED_ERROR = 'NR-APM-300' | ||
|
||
constructor({ | ||
agentConfig = { agent_control: { health: {} } }, |
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.
you don't have to default these as configuration has already done that
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.
Except in testing. This default allows for easier unit testing and fewer ?.
guards.
return | ||
} | ||
|
||
if (checkInterval === undefined) { |
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.
same with this, by setting the default in config it'll handle this
return | ||
} | ||
|
||
if (outDir === undefined) { |
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.
defaults to a path in config
const fs = require('node:fs') | ||
const os = require('node:os') | ||
const path = require('node:path') | ||
process.env.NEW_RELIC_AGENT_CONTROL_ENABLED = 'true' |
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 would just set these in agent config
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 can be considered cruft from the original implementation that was environment based only. I was just too lazy to remove them.
}) | ||
}) | ||
|
||
await t.test('loads from env', () => { |
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.
we have a separate file for env var conversion: test/unit/config/config-env.test.js
}) | ||
}) | ||
|
||
await t.test('loads from provided config', () => { |
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.
we have a file that also tests defaults test/unit/config/config-defaults.test.js
This PR resolves #2838.