Skip to content

Commit 485de96

Browse files
committed
Initial commit
1 parent 4c8bf13 commit 485de96

23 files changed

+1958
-1108
lines changed

THIRD_PARTY_NOTICES.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ This product includes source derived from [@grpc/proto-loader](https://github.co
511511

512512
### @newrelic/security-agent
513513

514-
This product includes source derived from [@newrelic/security-agent](https://github.com/newrelic/csec-node-agent) ([v2.3.0](https://github.com/newrelic/csec-node-agent/tree/v2.3.0)), distributed under the [UNKNOWN License](https://github.com/newrelic/csec-node-agent/blob/v2.3.0/LICENSE):
514+
This product includes source derived from [@newrelic/security-agent](https://github.com/newrelic/csec-node-agent) ([v2.2.0](https://github.com/newrelic/csec-node-agent/tree/v2.2.0)), distributed under the [UNKNOWN License](https://github.com/newrelic/csec-node-agent/blob/v2.2.0/LICENSE):
515515

516516
```
517517
## New Relic Software License v1.0
@@ -2035,7 +2035,7 @@ IN THE SOFTWARE.
20352035

20362036
### require-in-the-middle
20372037

2038-
This product includes source derived from [require-in-the-middle](https://github.com/elastic/require-in-the-middle) ([v7.5.0](https://github.com/elastic/require-in-the-middle/tree/v7.5.0)), distributed under the [MIT License](https://github.com/elastic/require-in-the-middle/blob/v7.5.0/LICENSE):
2038+
This product includes source derived from [require-in-the-middle](https://github.com/elastic/require-in-the-middle) ([v7.4.0](https://github.com/elastic/require-in-the-middle/tree/v7.4.0)), distributed under the [MIT License](https://github.com/elastic/require-in-the-middle/blob/v7.4.0/LICENSE):
20392039

20402040
```
20412041
The MIT License (MIT)
@@ -2065,7 +2065,7 @@ SOFTWARE.
20652065

20662066
### semver
20672067

2068-
This product includes source derived from [semver](https://github.com/npm/node-semver) ([v7.7.0](https://github.com/npm/node-semver/tree/v7.7.0)), distributed under the [ISC License](https://github.com/npm/node-semver/blob/v7.7.0/LICENSE):
2068+
This product includes source derived from [semver](https://github.com/npm/node-semver) ([v7.6.3](https://github.com/npm/node-semver/tree/v7.6.3)), distributed under the [ISC License](https://github.com/npm/node-semver/blob/v7.6.3/LICENSE):
20692069

20702070
```
20712071
The ISC License
@@ -2121,7 +2121,7 @@ SOFTWARE.
21212121

21222122
### @aws-sdk/client-s3
21232123

2124-
This product includes source derived from [@aws-sdk/client-s3](https://github.com/aws/aws-sdk-js-v3) ([v3.740.0](https://github.com/aws/aws-sdk-js-v3/tree/v3.740.0)), distributed under the [Apache-2.0 License](https://github.com/aws/aws-sdk-js-v3/blob/v3.740.0/LICENSE):
2124+
This product includes source derived from [@aws-sdk/client-s3](https://github.com/aws/aws-sdk-js-v3) ([v3.726.1](https://github.com/aws/aws-sdk-js-v3/tree/v3.726.1)), distributed under the [Apache-2.0 License](https://github.com/aws/aws-sdk-js-v3/blob/v3.726.1/LICENSE):
21252125

21262126
```
21272127
Apache License
@@ -2330,7 +2330,7 @@ This product includes source derived from [@aws-sdk/client-s3](https://github.co
23302330

23312331
### @aws-sdk/s3-request-presigner
23322332

2333-
This product includes source derived from [@aws-sdk/s3-request-presigner](https://github.com/aws/aws-sdk-js-v3) ([v3.740.0](https://github.com/aws/aws-sdk-js-v3/tree/v3.740.0)), distributed under the [Apache-2.0 License](https://github.com/aws/aws-sdk-js-v3/blob/v3.740.0/LICENSE):
2333+
This product includes source derived from [@aws-sdk/s3-request-presigner](https://github.com/aws/aws-sdk-js-v3) ([v3.726.1](https://github.com/aws/aws-sdk-js-v3/tree/v3.726.1)), distributed under the [Apache-2.0 License](https://github.com/aws/aws-sdk-js-v3/blob/v3.726.1/LICENSE):
23342334

23352335
```
23362336
Apache License
@@ -4158,7 +4158,7 @@ SOFTWARE.
41584158

41594159
### eslint-plugin-jsdoc
41604160

4161-
This product includes source derived from [eslint-plugin-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc) ([v50.6.3](https://github.com/gajus/eslint-plugin-jsdoc/tree/v50.6.3)), distributed under the [BSD-3-Clause License](https://github.com/gajus/eslint-plugin-jsdoc/blob/v50.6.3/LICENSE):
4161+
This product includes source derived from [eslint-plugin-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc) ([v50.6.1](https://github.com/gajus/eslint-plugin-jsdoc/tree/v50.6.1)), distributed under the [BSD-3-Clause License](https://github.com/gajus/eslint-plugin-jsdoc/blob/v50.6.1/LICENSE):
41624162

41634163
```
41644164
Copyright (c) 2018, Gajus Kuizinas (http://gajus.com/)
@@ -4190,7 +4190,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41904190

41914191
### eslint
41924192

4193-
This product includes source derived from [eslint](https://github.com/eslint/eslint) ([v9.19.0](https://github.com/eslint/eslint/tree/v9.19.0)), distributed under the [MIT License](https://github.com/eslint/eslint/blob/v9.19.0/LICENSE):
4193+
This product includes source derived from [eslint](https://github.com/eslint/eslint) ([v9.18.0](https://github.com/eslint/eslint/tree/v9.18.0)), distributed under the [MIT License](https://github.com/eslint/eslint/blob/v9.18.0/LICENSE):
41944194

41954195
```
41964196
Copyright OpenJS Foundation and other contributors, <www.openjsf.org>

index.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55

66
'use strict'
77

8-
const HealthReporter = require('./lib/health-reporter')
9-
108
// Record opening times before loading any other files.
119
const preAgentTime = process.uptime()
1210
const agentStart = Date.now()
@@ -156,7 +154,6 @@ function createAgent(config) {
156154
'New Relic requires that you name this application!\n' +
157155
'Set app_name in your newrelic.js or newrelic.cjs file or set environment variable\n' +
158156
'NEW_RELIC_APP_NAME. Not starting!'
159-
agent.healthReporter.setStatus(HealthReporter.STATUS_MISSING_APP_NAME)
160157
throw new Error(message)
161158
}
162159

@@ -170,7 +167,6 @@ function createAgent(config) {
170167

171168
agent.start(function afterStart(error) {
172169
if (error) {
173-
agent.healthReporter.setStatus(HealthReporter.STATUS_INTERNAL_UNEXPECTED_ERROR)
174170
const errorMessage = 'New Relic for Node.js halted startup due to an error:'
175171
logger.error(error, errorMessage)
176172

lib/agent.js

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ const {
4040
const synthetics = require('./synthetics')
4141
const Harvester = require('./harvester')
4242
const { createFeatureUsageMetrics } = require('./util/application-logging')
43-
const HealthReporter = require('./health-reporter')
4443

4544
// Map of valid states to whether or not data collection is valid
4645
const STATES = {
@@ -163,8 +162,6 @@ function Agent(config) {
163162
throw new Error('Agent must be created with a configuration!')
164163
}
165164

166-
this.healthReporter = new HealthReporter({ agentConfig: config })
167-
168165
// The agent base attributes which last throughout its lifetime.
169166
this._state = 'stopped'
170167
this.config = config
@@ -329,7 +326,6 @@ Agent.prototype.start = function start(callback) {
329326
if (this.config.agent_enabled !== true) {
330327
logger.warn('The New Relic Node.js agent is disabled by its configuration. ' + 'Not starting!')
331328

332-
this.healthReporter.setStatus(HealthReporter.STATUS_AGENT_DISABLED)
333329
this.setState('stopped')
334330
return process.nextTick(callback)
335331
}
@@ -346,21 +342,17 @@ Agent.prototype.start = function start(callback) {
346342
'Has a license key been specified in the agent configuration ' +
347343
'file or via the NEW_RELIC_LICENSE_KEY environment variable?'
348344
)
349-
this.healthReporter.setStatus(HealthReporter.STATUS_LICENSE_KEY_MISSING)
350345

351346
this.setState('errored')
352347
sampler.stop()
353348
return process.nextTick(function onNextTick() {
354-
agent.healthReporter.stop(() => {
355-
callback(new Error('Not starting without license key!'))
356-
})
349+
callback(new Error('Not starting without license key!'))
357350
})
358351
}
359352
logger.info('Starting New Relic for Node.js connection process.')
360353

361354
this.collector.connect(function onStartConnect(error, response) {
362355
if (error || response.shouldShutdownRun()) {
363-
agent.healthReporter.setStatus(HealthReporter.STATUS_CONNECT_ERROR)
364356
agent.setState('errored')
365357
sampler.stop()
366358
callback(error || new Error('Failed to connect to collector'), response && response.payload)
@@ -484,26 +476,23 @@ Agent.prototype.stop = function stop(callback) {
484476

485477
sampler.stop()
486478

487-
this.healthReporter.setStatus(HealthReporter.STATUS_AGENT_SHUTDOWN)
488-
this.healthReporter.stop(() => {
489-
if (agent.collector.isConnected()) {
490-
agent.collector.shutdown(function onShutdown(error) {
491-
if (error) {
492-
agent.setState('errored')
493-
logger.warn(error, 'Got error shutting down connection to New Relic:')
494-
} else {
495-
agent.setState('stopped')
496-
logger.info('Stopped New Relic for Node.js.')
497-
}
498-
499-
callback(error)
500-
})
501-
} else {
502-
logger.trace('Collector was not connected, invoking callback.')
479+
if (this.collector.isConnected()) {
480+
this.collector.shutdown(function onShutdown(error) {
481+
if (error) {
482+
agent.setState('errored')
483+
logger.warn(error, 'Got error shutting down connection to New Relic:')
484+
} else {
485+
agent.setState('stopped')
486+
logger.info('Stopped New Relic for Node.js.')
487+
}
488+
489+
callback(error)
490+
})
491+
} else {
492+
logger.trace('Collector was not connected, invoking callback.')
503493

504-
process.nextTick(callback)
505-
}
506-
})
494+
process.nextTick(callback)
495+
}
507496
}
508497

509498
/**

lib/collector/api.js

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ const CollectorResponse = require('./response')
99
const facts = require('./facts')
1010
const logger = require('../logger').child({ component: 'collector_api' })
1111
const RemoteMethod = require('./remote-method')
12-
const HealthReporter = require('../health-reporter')
1312

1413
const NAMES = require('../metrics/names')
1514

@@ -222,7 +221,6 @@ CollectorAPI.prototype._retry = function _retry(ctx, error, response) {
222221
ctx.errors.push(error)
223222
} else if (response && SUCCESS.has(response.status)) {
224223
dumpErrors(ctx.errors, 'connect')
225-
this._agent.healthReporter.setStatus(HealthReporter.STATUS_HEALTHY)
226224
ctx.callback(null, CollectorResponse.success(response.payload))
227225
return
228226
}
@@ -233,7 +231,6 @@ CollectorAPI.prototype._retry = function _retry(ctx, error, response) {
233231
// Retry everything except for an explicit Disconnect response code.
234232
if (response.status === 410 || response.agentRun === AGENT_RUN_BEHAVIOR.SHUTDOWN) {
235233
logger.error('The New Relic collector rejected this agent.')
236-
this._agent.healthReporter.setStatus(HealthReporter.STATUS_FORCED_DISCONNECT)
237234
return ctx.callback(null, CollectorResponse.fatal(response.payload))
238235
} else if (response.status === 401) {
239236
logger.warn(
@@ -243,7 +240,6 @@ CollectorAPI.prototype._retry = function _retry(ctx, error, response) {
243240
' (status code %s)',
244241
response.status
245242
)
246-
this._agent.healthReporter.setStatus(HealthReporter.STATUS_INVALID_LICENSE_KEY)
247243
} else if (this._isProxyMisconfigured(error)) {
248244
logger.warn(
249245
error,
@@ -252,17 +248,6 @@ CollectorAPI.prototype._retry = function _retry(ctx, error, response) {
252248
'SSL(https). If your proxy is configured to accept connections over http, try ' +
253249
'setting `proxy` to a fully qualified URL(e.g http://proxy-host:8080).'
254250
)
255-
this._agent.healthReporter.setStatus(HealthReporter.STATUS_HTTP_PROXY_MISCONFIGURED)
256-
} else {
257-
// Sometimes we get a `CollectorResponse` instance instead of an
258-
// `http.ServerResponse`. In such cases, we do not have access to the
259-
// status code.
260-
let msg = 'Unexpected error communicating with New Relic backend.'
261-
if (response.status) {
262-
msg = `Received error status code from New Relic backend: ${response.status}.`
263-
}
264-
logger.warn(error, msg)
265-
this._agent.healthReporter.setStatus(HealthReporter.STATUS_BACKEND_ERROR)
266251
}
267252

268253
const backoff = BACKOFFS[Math.min(ctx.attempts, ctx.max) - 1]

lib/config/default.js

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -147,45 +147,6 @@ defaultConfig.definition = () => ({
147147
formatter: boolean,
148148
default: true
149149
},
150-
151-
/**
152-
* Collects configuration related to New Relic Agent Control, i.e. centralized
153-
* agent management in container based environments.
154-
*/
155-
agent_control: {
156-
/**
157-
* Indicates that the agent is being managed by Agent Control. Must be set
158-
* to true health monitoring.
159-
*/
160-
enabled: {
161-
formatter: boolean,
162-
default: false
163-
},
164-
165-
/**
166-
* Settings specific to the health monitoring aspect of Agent Control.
167-
*/
168-
health: {
169-
/**
170-
* A string file path to a directory that the agent is expected to write
171-
* health status files to. Must be set for health monitoring to be
172-
* enabled.
173-
*/
174-
delivery_location: {
175-
default: 'file:///newrelic/apm/health'
176-
},
177-
178-
/**
179-
* The time, in seconds, that the agent should wait between writing
180-
* updates to its health status. The default interval is 5 seconds.
181-
*/
182-
frequency: {
183-
formatter: int,
184-
default: 5
185-
}
186-
}
187-
},
188-
189150
/**
190151
* The default Apdex tolerating / threshold value for applications, in
191152
* seconds. The default for Node is apdexT to 100 milliseconds, which is

lib/config/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1042,7 +1042,7 @@ Config.prototype._fromPassed = function _fromPassed(external, internal, arbitrar
10421042

10431043
Object.keys(external).forEach(function overwrite(key) {
10441044
// if it's not in the defaults, it doesn't exist
1045-
if (!arbitrary && !(key in internal)) {
1045+
if (!arbitrary && internal[key] === undefined) {
10461046
return
10471047
}
10481048

0 commit comments

Comments
 (0)