newrelic 8.3.0 → 8.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NEWS.md +76 -0
- package/README.md +7 -6
- package/THIRD_PARTY_NOTICES.md +95 -35
- package/api.js +74 -68
- package/bin/test-naming-rules.js +22 -22
- package/lib/agent.js +4 -4
- package/lib/attributes.js +2 -2
- package/lib/collector/api.js +12 -12
- package/lib/collector/facts.js +1 -1
- package/lib/collector/http-agents.js +12 -11
- package/lib/collector/key-parser.js +1 -1
- package/lib/collector/remote-method.js +27 -26
- package/lib/config/attribute-filter.js +23 -23
- package/lib/config/default.js +12 -10
- package/lib/config/hsm.js +1 -1
- package/lib/config/index.js +82 -66
- package/lib/config/lasp.js +3 -3
- package/lib/config/merge-server-config.js +1 -1
- package/lib/db/parse-sql.js +8 -8
- package/lib/db/parsed-statement.js +9 -8
- package/lib/db/query-parsers/sql.js +7 -7
- package/lib/db/query-sample.js +9 -9
- package/lib/db/query-trace-aggregator.js +4 -4
- package/lib/db/statement-matcher.js +5 -5
- package/lib/db/utils.js +1 -1
- package/lib/environment.js +43 -43
- package/lib/errors/error-collector.js +2 -2
- package/lib/errors/error-trace-aggregator.js +1 -1
- package/lib/errors/helper.js +3 -3
- package/lib/errors/index.js +17 -17
- package/lib/feature_flags.js +7 -5
- package/lib/header-attributes.js +6 -6
- package/lib/header-processing.js +1 -1
- package/lib/instrumentation/amqplib.js +26 -26
- package/lib/instrumentation/bluebird.js +3 -3
- package/lib/instrumentation/cassandra-driver.js +7 -3
- package/lib/instrumentation/connect.js +4 -4
- package/lib/instrumentation/core/async_hooks.js +6 -6
- package/lib/instrumentation/core/domain.js +2 -2
- package/lib/instrumentation/core/globals.js +1 -1
- package/lib/instrumentation/core/http-outbound.js +15 -84
- package/lib/instrumentation/core/http.js +34 -67
- package/lib/instrumentation/core/inspector.js +2 -2
- package/lib/instrumentation/core/timers.js +7 -7
- package/lib/instrumentation/core/zlib.js +2 -2
- package/lib/instrumentation/director.js +4 -4
- package/lib/instrumentation/express.js +8 -8
- package/lib/instrumentation/fastify/spec-builders.js +57 -47
- package/lib/instrumentation/fastify.js +85 -24
- package/lib/instrumentation/generic-pool.js +1 -1
- package/lib/instrumentation/hapi/hapi-17.js +11 -11
- package/lib/instrumentation/hapi/shared.js +1 -1
- package/lib/instrumentation/hapi.js +22 -22
- package/lib/instrumentation/ioredis.js +7 -7
- package/lib/instrumentation/memcached.js +7 -7
- package/lib/instrumentation/mongodb/common.js +16 -5
- package/lib/instrumentation/mysql.js +19 -19
- package/lib/instrumentation/oracle.js +15 -15
- package/lib/instrumentation/pg.js +4 -4
- package/lib/instrumentation/promise.js +46 -46
- package/lib/instrumentation/q.js +2 -2
- package/lib/instrumentation/redis.js +11 -11
- package/lib/instrumentation/restify.js +1 -1
- package/lib/instrumentation/undici.js +242 -0
- package/lib/instrumentation/vision.js +4 -4
- package/lib/instrumentation/when.js +3 -3
- package/lib/instrumentations.js +2 -1
- package/lib/logger.js +5 -5
- package/lib/metrics/index.js +15 -15
- package/lib/metrics/mapper.js +7 -7
- package/lib/metrics/normalizer/rule.js +9 -9
- package/lib/metrics/normalizer/tx_segment.js +17 -17
- package/lib/metrics/normalizer.js +22 -22
- package/lib/metrics/recorders/custom.js +5 -5
- package/lib/metrics/recorders/generic.js +3 -3
- package/lib/metrics/recorders/http.js +7 -7
- package/lib/metrics/recorders/http_external.js +7 -7
- package/lib/metrics/recorders/message-transaction.js +5 -6
- package/lib/metrics/recorders/other.js +5 -5
- package/lib/parse-proc-cpuinfo.js +25 -19
- package/lib/parse-proc-meminfo.js +8 -2
- package/lib/prioritized-attributes.js +2 -2
- package/lib/priority-queue.js +10 -10
- package/lib/reservoir.js +3 -3
- package/lib/sampler.js +26 -26
- package/lib/serverless/aws-lambda.js +8 -2
- package/lib/shim/datastore-shim.js +35 -32
- package/lib/shim/index.js +2 -2
- package/lib/shim/message-shim.js +47 -47
- package/lib/shim/promise-shim.js +1 -1
- package/lib/shim/shim.js +61 -61
- package/lib/shim/specs/index.js +3 -3
- package/lib/shim/transaction-shim.js +44 -192
- package/lib/shim/webframework-shim.js +52 -52
- package/lib/spans/span-event.js +1 -1
- package/lib/spans/streaming-span-attributes.js +1 -1
- package/lib/stats/apdex.js +2 -2
- package/lib/stats/index.js +2 -2
- package/lib/system-info.js +23 -23
- package/lib/timer.js +5 -5
- package/lib/transaction/dt-payload.js +1 -1
- package/lib/transaction/index.js +40 -40
- package/lib/transaction/name-state.js +14 -14
- package/lib/transaction/trace/exclusive-time-calculator.js +6 -6
- package/lib/transaction/trace/index.js +14 -14
- package/lib/transaction/trace/segment.js +18 -18
- package/lib/transaction/tracecontext.js +1 -1
- package/lib/transaction/tracer/index.js +53 -49
- package/lib/uninstrumented.js +7 -7
- package/lib/util/arity.js +2 -2
- package/lib/util/byte-limit.js +4 -4
- package/lib/util/cat.js +269 -24
- package/lib/util/codec.js +2 -2
- package/lib/util/copy.js +2 -2
- package/lib/util/deep-equal.js +10 -10
- package/lib/util/flatten.js +4 -4
- package/lib/util/hashes.js +14 -14
- package/lib/util/label-parser.js +17 -17
- package/lib/util/logger.js +24 -24
- package/lib/util/process-version.js +2 -2
- package/lib/util/properties.js +4 -4
- package/lib/util/sql/obfuscate.js +15 -15
- package/lib/util/stream-sink.js +3 -3
- package/lib/util/unwrapped-core.js +2 -2
- package/lib/util/urltils.js +16 -16
- package/lib/utilization/aws-info.js +7 -7
- package/lib/utilization/azure-info.js +6 -6
- package/lib/utilization/common.js +13 -13
- package/lib/utilization/docker-info.js +11 -11
- package/lib/utilization/gcp-info.js +4 -4
- package/lib/utilization/index.js +5 -5
- package/lib/utilization/pcf-info.js +9 -9
- package/package.json +13 -6
- package/stub_api.js +8 -8
package/lib/util/logger.js
CHANGED
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
|
|
6
6
|
'use strict'
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
const stringify = require('json-stringify-safe')
|
|
9
|
+
const util = require('util')
|
|
10
|
+
const Readable = require('readable-stream')
|
|
11
|
+
const os = require('os')
|
|
12
12
|
|
|
13
13
|
module.exports = Logger
|
|
14
14
|
|
|
@@ -36,7 +36,7 @@ function Logger(options, extra) {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
Readable.call(this)
|
|
39
|
-
|
|
39
|
+
const passedInLevel = this.coerce(options.level)
|
|
40
40
|
this.options = {
|
|
41
41
|
_level: passedInLevel,
|
|
42
42
|
enabled: options.enabled === undefined ? true : options.enabled
|
|
@@ -68,10 +68,10 @@ Logger.prototype.coerce = function coerce(value) {
|
|
|
68
68
|
return LEVELS[value] || 50
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
const loggingFunctions = Object.create(null)
|
|
72
72
|
|
|
73
73
|
Object.keys(LEVELS).forEach(function buildLevel(_level) {
|
|
74
|
-
|
|
74
|
+
const level = Logger.prototype.coerce(LEVELS[_level])
|
|
75
75
|
|
|
76
76
|
function log(extra) {
|
|
77
77
|
if (!this.options.enabled) {
|
|
@@ -81,8 +81,8 @@ Object.keys(LEVELS).forEach(function buildLevel(_level) {
|
|
|
81
81
|
return false
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
const hasExtra = typeof extra === 'object'
|
|
85
|
+
const args = Array.prototype.slice.call(arguments, hasExtra ? 1 : 0)
|
|
86
86
|
return this.write(level, args, hasExtra ? extra : null)
|
|
87
87
|
}
|
|
88
88
|
|
|
@@ -90,7 +90,7 @@ Object.keys(LEVELS).forEach(function buildLevel(_level) {
|
|
|
90
90
|
log.apply(this, arguments)
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
|
|
93
|
+
const seenMessages = Object.create(null)
|
|
94
94
|
loggingFunctions[_level + 'Once'] = function logOnce(key) {
|
|
95
95
|
if (typeof key !== 'string') {
|
|
96
96
|
this.debug('Attempted to key on a non-string in ' + _level + 'Once: ' + key)
|
|
@@ -105,8 +105,8 @@ Object.keys(LEVELS).forEach(function buildLevel(_level) {
|
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
if (seenMessages[key] !== true) {
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
const args = Array.prototype.slice.call(arguments, 1)
|
|
109
|
+
const writeSuccessful = log.apply(this, args)
|
|
110
110
|
|
|
111
111
|
if (writeSuccessful) {
|
|
112
112
|
seenMessages[key] = true
|
|
@@ -114,7 +114,7 @@ Object.keys(LEVELS).forEach(function buildLevel(_level) {
|
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
|
|
117
|
+
const seenPerInterval = Object.create(null)
|
|
118
118
|
loggingFunctions[_level + 'OncePer'] = function logOncePer(key, interval) {
|
|
119
119
|
if (typeof key !== 'string') {
|
|
120
120
|
this.debug('Attempted to key on a non-string in ' + _level + 'Once: ' + key)
|
|
@@ -129,13 +129,13 @@ Object.keys(LEVELS).forEach(function buildLevel(_level) {
|
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
if (seenPerInterval[key] !== true) {
|
|
132
|
-
|
|
133
|
-
|
|
132
|
+
const args = Array.prototype.slice.call(arguments, 2)
|
|
133
|
+
const writeSuccessful = log.apply(this, args)
|
|
134
134
|
|
|
135
135
|
if (writeSuccessful) {
|
|
136
136
|
seenPerInterval[key] = true
|
|
137
137
|
|
|
138
|
-
|
|
138
|
+
const clearSeen = setTimeout(function clearKey() {
|
|
139
139
|
delete seenPerInterval[key]
|
|
140
140
|
}, interval)
|
|
141
141
|
|
|
@@ -152,11 +152,11 @@ Object.keys(LEVELS).forEach(function buildLevel(_level) {
|
|
|
152
152
|
Object.assign(Logger.prototype, loggingFunctions)
|
|
153
153
|
|
|
154
154
|
Logger.prototype.child = function child(extra) {
|
|
155
|
-
|
|
155
|
+
const childLogger = Object.create(loggingFunctions)
|
|
156
156
|
|
|
157
157
|
childLogger.extra = Object.assign(Object.create(null), this.extra, extra)
|
|
158
158
|
|
|
159
|
-
|
|
159
|
+
const parent = this
|
|
160
160
|
childLogger.options = parent.options
|
|
161
161
|
|
|
162
162
|
childLogger.write = function write(level, args, _extra) {
|
|
@@ -203,7 +203,7 @@ Logger.prototype.write = function write(level, args, extra) {
|
|
|
203
203
|
return
|
|
204
204
|
}
|
|
205
205
|
this._nestedLog = true
|
|
206
|
-
for (
|
|
206
|
+
for (let i = 0, l = args.length; i < l; ++i) {
|
|
207
207
|
if (typeof args[i] === 'function') {
|
|
208
208
|
args[i] = args[i].valueOf()
|
|
209
209
|
} else if (typeof args[i] === 'object') {
|
|
@@ -217,11 +217,11 @@ Logger.prototype.write = function write(level, args, extra) {
|
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
219
|
|
|
220
|
-
|
|
220
|
+
const entry = new Entry(this, level, util.format.apply(util, args))
|
|
221
221
|
|
|
222
222
|
Object.assign(entry, this.extra, getPropertiesToLog(extra))
|
|
223
223
|
|
|
224
|
-
|
|
224
|
+
let data = ''
|
|
225
225
|
try {
|
|
226
226
|
data = stringify(entry) + '\n'
|
|
227
227
|
} catch (err) {
|
|
@@ -255,12 +255,12 @@ function Entry(logger, level, msg) {
|
|
|
255
255
|
}
|
|
256
256
|
|
|
257
257
|
function getPropertiesToLog(extra) {
|
|
258
|
-
|
|
258
|
+
const obj = Object.assign(Object.create(null), extra)
|
|
259
259
|
// Error properties (message, stack) are not enumerable, so getting them directly
|
|
260
260
|
if (extra instanceof Error) {
|
|
261
|
-
|
|
261
|
+
const names = Object.getOwnPropertyNames(extra)
|
|
262
262
|
if (names) {
|
|
263
|
-
for (
|
|
263
|
+
for (let i = 0; i < names.length; i++) {
|
|
264
264
|
obj[names[i]] = extra[names[i]]
|
|
265
265
|
}
|
|
266
266
|
}
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
|
|
6
6
|
'use strict'
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
const semver = require('semver')
|
|
9
9
|
|
|
10
10
|
// The logger needs to be lazy-loaded to get around ordering issues with config.
|
|
11
|
-
|
|
11
|
+
let logger = null
|
|
12
12
|
|
|
13
13
|
exports.satisfies = satisfies
|
|
14
14
|
exports.prerelease = prerelease
|
package/lib/util/properties.js
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
'use strict'
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
const hasOwnProperty = Object.hasOwnProperty
|
|
9
9
|
|
|
10
10
|
// The logger needs to be lazy-loaded to get around ordering issues with config.
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
let _logger = null
|
|
12
|
+
let getLogger = function makeLogger() {
|
|
13
13
|
_logger = require('../logger').child({ component: 'util-properties' })
|
|
14
14
|
getLogger = function reallyGetLogger() {
|
|
15
15
|
return _logger
|
|
@@ -46,7 +46,7 @@ exports.hasOwn = function hasOwn(obj, key) {
|
|
|
46
46
|
*/
|
|
47
47
|
exports.isEmpty = function isEmpty(obj) {
|
|
48
48
|
// Use this case for null prototyped objects.
|
|
49
|
-
for (
|
|
49
|
+
for (const key in obj) {
|
|
50
50
|
if (exports.hasOwn(obj, key)) {
|
|
51
51
|
return false
|
|
52
52
|
}
|
|
@@ -7,18 +7,18 @@
|
|
|
7
7
|
|
|
8
8
|
module.exports = obfuscate
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
10
|
+
const singleQuote = /'(?:''|[^'])*?(?:\\'.*|'(?!'))/
|
|
11
|
+
const doubleQuote = /"(?:[^"]|"")*?(?:\\".*|"(?!"))/
|
|
12
|
+
const dollarQuote = /(\$(?!\d)[^$]*?\$).*?(?:\1|$)/
|
|
13
|
+
const oracleQuote = /q'\[.*?(?:\]'|$)|q'\{.*?(?:\}'|$)|q'\<.*?(?:\>'|$)|q'\(.*?(?:\)'|$)/
|
|
14
|
+
const comment = /(?:#|--).*?(?=\r|\n|$)/
|
|
15
|
+
const multilineComment = /\/\*(?:[^/]|\/[^*])*?(?:\*\/|\/\*.*)/
|
|
16
|
+
const uuid = /\{?(?:[0-9a-f]\-*){32}\}?/
|
|
17
|
+
const hex = /0x[0-9a-f]+/
|
|
18
|
+
const boolean = /true|false|null/
|
|
19
|
+
const number = /\b-?(?:[0-9]+\.)?[0-9]+([eE][+-]?[0-9]+)?/
|
|
20
|
+
|
|
21
|
+
const dialects = (obfuscate.dialects = Object.create(null))
|
|
22
22
|
|
|
23
23
|
dialects.mysql = [
|
|
24
24
|
replacer(join([doubleQuote, singleQuote, comment, multilineComment, hex, boolean, number], 'gi')),
|
|
@@ -45,13 +45,13 @@ dialects.oracle = [
|
|
|
45
45
|
dialects.default = dialects.mysql
|
|
46
46
|
|
|
47
47
|
function obfuscate(raw, dialect) {
|
|
48
|
-
|
|
48
|
+
let replacers = dialects[dialect]
|
|
49
49
|
if (!replacers) {
|
|
50
50
|
replacers = dialects.default
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
for (
|
|
53
|
+
let obfuscated = raw
|
|
54
|
+
for (let i = 0, l = replacers.length; i < l; ++i) {
|
|
55
55
|
obfuscated = replacers[i](obfuscated)
|
|
56
56
|
}
|
|
57
57
|
|
package/lib/util/stream-sink.js
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
|
|
6
6
|
'use strict'
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
const EventEmitter = require('events').EventEmitter
|
|
9
|
+
const util = require('util')
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Pipe a readable stream into this sink that fulfills the Writable Stream
|
|
@@ -20,7 +20,7 @@ function StreamSink(callback) {
|
|
|
20
20
|
this.sink = ''
|
|
21
21
|
this.writable = true
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
const sink = this
|
|
24
24
|
this.on('error', function handleError(error) {
|
|
25
25
|
sink.writable = false
|
|
26
26
|
callback(error)
|
package/lib/util/urltils.js
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
|
|
6
6
|
'use strict'
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
const url = require('url')
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
const LOCALHOST_NAMES = {
|
|
11
11
|
'localhost': true,
|
|
12
12
|
'127.0.0.1': true,
|
|
13
13
|
'0.0.0.0': true,
|
|
@@ -95,7 +95,7 @@ module.exports = {
|
|
|
95
95
|
requestURL = url.parse(requestURL)
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
|
|
98
|
+
let path = requestURL.pathname
|
|
99
99
|
|
|
100
100
|
if (path) {
|
|
101
101
|
path = path.split(';')[0]
|
|
@@ -124,19 +124,19 @@ module.exports = {
|
|
|
124
124
|
* @returns {object} The parameters parsed from the request
|
|
125
125
|
*/
|
|
126
126
|
parseParameters: function parseParameters(requestURL) {
|
|
127
|
-
|
|
127
|
+
let parsed = requestURL
|
|
128
128
|
|
|
129
129
|
if (typeof requestURL === 'string') {
|
|
130
130
|
parsed = url.parse(requestURL, true)
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
|
|
133
|
+
const parameters = Object.create(null)
|
|
134
134
|
|
|
135
135
|
if (parsed.query) {
|
|
136
|
-
|
|
136
|
+
const keys = Object.keys(parsed.query)
|
|
137
137
|
|
|
138
|
-
for (
|
|
139
|
-
|
|
138
|
+
for (let i = 0, l = keys.length; i < l; ++i) {
|
|
139
|
+
const key = keys[i]
|
|
140
140
|
if (parsed.query[key] === '' && parsed.path.indexOf(key + '=') === -1) {
|
|
141
141
|
parameters[key] = true
|
|
142
142
|
} else {
|
|
@@ -179,9 +179,9 @@ module.exports = {
|
|
|
179
179
|
*/
|
|
180
180
|
copyParameters: function copyParameters(source, destination) {
|
|
181
181
|
if (source && destination) {
|
|
182
|
-
|
|
183
|
-
for (
|
|
184
|
-
|
|
182
|
+
const keys = Object.keys(source)
|
|
183
|
+
for (let i = 0; i < keys.length; i++) {
|
|
184
|
+
const key = keys[i]
|
|
185
185
|
if (!(key in destination)) {
|
|
186
186
|
destination[key] = source[key]
|
|
187
187
|
}
|
|
@@ -198,16 +198,16 @@ module.exports = {
|
|
|
198
198
|
* (mutated in place).
|
|
199
199
|
*/
|
|
200
200
|
overwriteParameters: function overwriteParameters(source, destination) {
|
|
201
|
-
|
|
202
|
-
for (
|
|
203
|
-
|
|
201
|
+
const keys = Object.keys(source)
|
|
202
|
+
for (let i = 0; i < keys.length; i++) {
|
|
203
|
+
const key = keys[i]
|
|
204
204
|
destination[key] = source[key]
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
208
|
|
|
209
209
|
function isIgnoredStatusCodeForErrors(config, code) {
|
|
210
|
-
|
|
210
|
+
let codes = []
|
|
211
211
|
if (config && config.error_collector && config.error_collector.ignore_status_codes) {
|
|
212
212
|
codes = config.error_collector.ignore_status_codes
|
|
213
213
|
}
|
|
@@ -215,7 +215,7 @@ function isIgnoredStatusCodeForErrors(config, code) {
|
|
|
215
215
|
}
|
|
216
216
|
|
|
217
217
|
function isExpectedStatusCodeForErrors(config, code) {
|
|
218
|
-
|
|
218
|
+
let codes = []
|
|
219
219
|
if (config && config.error_collector && config.error_collector.expected_status_codes) {
|
|
220
220
|
codes = config.error_collector.expected_status_codes
|
|
221
221
|
}
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
|
|
6
6
|
'use strict'
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
const logger = require('../logger.js').child({ component: 'aws-info' })
|
|
9
|
+
const common = require('./common')
|
|
10
|
+
const NAMES = require('../metrics/names.js')
|
|
11
11
|
let results = null
|
|
12
12
|
|
|
13
13
|
module.exports = fetchAWSInfo
|
|
@@ -24,10 +24,10 @@ function fetchAWSInfo(agent, callback) {
|
|
|
24
24
|
return setImmediate(callback, null, results)
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
const instanceHost = '169.254.169.254'
|
|
28
|
+
const apiVersion = '2016-09-02'
|
|
29
|
+
const endpoint = 'dynamic/instance-identity/document'
|
|
30
|
+
const url = 'http://' + instanceHost + '/' + apiVersion + '/' + endpoint
|
|
31
31
|
common.request(url, agent, function getMetadata(err, data) {
|
|
32
32
|
if (err) {
|
|
33
33
|
return callback(err)
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
|
|
6
6
|
'use strict'
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
const common = require('./common')
|
|
9
|
+
const logger = require('../logger.js').child({ component: 'azure-info' })
|
|
10
|
+
const NAMES = require('../metrics/names.js')
|
|
11
11
|
let results = null
|
|
12
12
|
|
|
13
13
|
module.exports = fetchAzureInfo
|
|
@@ -24,9 +24,9 @@ function fetchAzureInfo(agent, callback) {
|
|
|
24
24
|
return setImmediate(callback, null, results)
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
const instanceHost = '169.254.169.254'
|
|
28
|
+
const apiVersion = '2017-03-01'
|
|
29
|
+
const endpoint = '/metadata/instance/compute'
|
|
30
30
|
common.request(
|
|
31
31
|
{
|
|
32
32
|
host: instanceHost,
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
'use strict'
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
const concat = require('concat-stream')
|
|
9
|
+
const http = require('http')
|
|
10
|
+
const logger = require('../logger').child({ component: 'utilization-request' })
|
|
11
|
+
const fs = require('../util/unwrapped-core').fs
|
|
12
|
+
const properties = require('../util/properties')
|
|
13
13
|
const url = require('url')
|
|
14
14
|
|
|
15
15
|
exports.checkValueString = checkValueString
|
|
@@ -18,9 +18,9 @@ function checkValueString(str) {
|
|
|
18
18
|
return false
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
for (
|
|
21
|
+
const len = str.length
|
|
22
|
+
const validCharacters = /[0-9a-zA-Z_ ./-]/
|
|
23
|
+
for (let i = 0; i < len; ++i) {
|
|
24
24
|
if (str.charCodeAt(i) < 128 && !validCharacters.test(str[i])) {
|
|
25
25
|
return false
|
|
26
26
|
}
|
|
@@ -33,14 +33,14 @@ exports.getKeys = function getKeys(data, keys) {
|
|
|
33
33
|
return null
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
for (
|
|
38
|
-
|
|
36
|
+
const results = Object.create(null)
|
|
37
|
+
for (let i = 0; i < keys.length; ++i) {
|
|
38
|
+
const key = keys[i]
|
|
39
39
|
if (!properties.hasOwn(data, key) || !data[key]) {
|
|
40
40
|
logger.debug('Key %s missing from metadata', key)
|
|
41
41
|
return null
|
|
42
42
|
}
|
|
43
|
-
|
|
43
|
+
let value = data[key]
|
|
44
44
|
if (typeof value === 'number') {
|
|
45
45
|
value = value.toString()
|
|
46
46
|
}
|
|
@@ -65,7 +65,7 @@ exports.request = function request(opts, agent, cb) {
|
|
|
65
65
|
|
|
66
66
|
opts.timeout = opts.timeout || 1000
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
const req = http.get(opts, function awsRequest(res) {
|
|
69
69
|
res.pipe(concat(respond))
|
|
70
70
|
function respond(data) {
|
|
71
71
|
agent.removeListener('errored', abortRequest)
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
|
|
6
6
|
'use strict'
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
const logger = require('../logger').child({ component: 'docker-info' })
|
|
9
|
+
const common = require('./common')
|
|
10
|
+
const NAMES = require('../metrics/names')
|
|
11
|
+
const os = require('os')
|
|
12
12
|
let vendorInfo = null
|
|
13
13
|
|
|
14
14
|
module.exports.getVendorInfo = fetchDockerVendorInfo
|
|
@@ -29,7 +29,7 @@ module.exports.getBootId = function getBootId(agent, callback) {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
data = data.trim()
|
|
32
|
-
|
|
32
|
+
const asciiData = Buffer.from(data, 'ascii').toString()
|
|
33
33
|
|
|
34
34
|
if (data !== asciiData) {
|
|
35
35
|
bootIdError()
|
|
@@ -70,9 +70,9 @@ function fetchDockerVendorInfo(agent, callback) {
|
|
|
70
70
|
return callback(null)
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
let id = null
|
|
74
74
|
findCGroups(data, 'cpu', function forEachCpuGroup(cpuGroup) {
|
|
75
|
-
|
|
75
|
+
const match = /(?:^|[^0-9a-f])([0-9a-f]{64})(?:[^0-9a-f]|$)/.exec(cpuGroup)
|
|
76
76
|
if (match) {
|
|
77
77
|
id = match[1]
|
|
78
78
|
return false
|
|
@@ -92,10 +92,10 @@ function fetchDockerVendorInfo(agent, callback) {
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
function findCGroups(info, cgroup, eachCb) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
for (
|
|
98
|
-
|
|
95
|
+
const target = new RegExp('^\\d+:[^:]*?\\b' + cgroup + '\\b[^:]*:')
|
|
96
|
+
const lines = info.split('\n')
|
|
97
|
+
for (let i = 0; i < lines.length; ++i) {
|
|
98
|
+
const line = lines[i]
|
|
99
99
|
if (target.test(line) && !eachCb(line.split(':')[2])) {
|
|
100
100
|
break
|
|
101
101
|
}
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
|
|
6
6
|
'use strict'
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
const logger = require('../logger.js').child({ component: 'gcp-info' })
|
|
9
|
+
const common = require('./common')
|
|
10
|
+
const NAMES = require('../metrics/names.js')
|
|
11
11
|
let resultDict = null
|
|
12
12
|
|
|
13
13
|
module.exports = fetchGCPInfo
|
|
@@ -45,7 +45,7 @@ function fetchGCPInfo(agent, callback) {
|
|
|
45
45
|
data = null
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
const results = common.getKeys(data, ['id', 'machineType', 'name', 'zone'])
|
|
49
49
|
if (results == null) {
|
|
50
50
|
logger.debug('GCP metadata was invalid.')
|
|
51
51
|
agent.metrics.getOrCreateMetric(NAMES.UTILIZATION.GCP_ERROR).incrementCallCount()
|
package/lib/utilization/index.js
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
|
|
6
6
|
'use strict'
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
const logger = require('../logger').child({ component: 'utilization' })
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
const VENDOR_METHODS = {
|
|
11
11
|
aws: require('./aws-info'),
|
|
12
12
|
pcf: require('./pcf-info'),
|
|
13
13
|
azure: require('./azure-info'),
|
|
@@ -15,12 +15,12 @@ var VENDOR_METHODS = {
|
|
|
15
15
|
docker: require('./docker-info').getVendorInfo,
|
|
16
16
|
kubernetes: require('./kubernetes-info')
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
const VENDOR_NAMES = Object.keys(VENDOR_METHODS)
|
|
19
19
|
|
|
20
20
|
module.exports.getVendors = getVendors
|
|
21
21
|
function getVendors(agent, callback) {
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
let done = 0
|
|
23
|
+
let vendors = null
|
|
24
24
|
VENDOR_NAMES.forEach(function getVendorInfo(vendor) {
|
|
25
25
|
VENDOR_METHODS[vendor](agent, function getInfo(err, result) {
|
|
26
26
|
logger.trace('Vendor %s finished.', vendor)
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
|
|
6
6
|
'use strict'
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
const logger = require('../logger.js').child({ component: 'pcf-info' })
|
|
9
|
+
const NAMES = require('../metrics/names.js')
|
|
10
|
+
const common = require('./common')
|
|
11
11
|
|
|
12
12
|
module.exports = fetchPCFInfo
|
|
13
13
|
|
|
@@ -16,17 +16,17 @@ function fetchPCFInfo(agent, callback) {
|
|
|
16
16
|
return setImmediate(callback, null, null)
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
const metadataMap = {
|
|
20
20
|
CF_INSTANCE_GUID: 'cf_instance_guid',
|
|
21
21
|
CF_INSTANCE_IP: 'cf_instance_ip',
|
|
22
22
|
MEMORY_LIMIT: 'memory_limit'
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
for (
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
const results = Object.create(null)
|
|
26
|
+
const keys = Object.keys(metadataMap)
|
|
27
|
+
for (let i = 0; i < keys.length; i++) {
|
|
28
|
+
const key = keys[i]
|
|
29
|
+
const value = process.env[key]
|
|
30
30
|
if (value == null) {
|
|
31
31
|
logger.trace('Could not find environment value for %s', key)
|
|
32
32
|
return setImmediate(callback, null, null)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "newrelic",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.5.2",
|
|
4
4
|
"author": "New Relic Node.js agent team <nodejs@newrelic.com>",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"contributors": [
|
|
@@ -103,6 +103,11 @@
|
|
|
103
103
|
"name": "Bob Evans",
|
|
104
104
|
"email": "revans@newrelic.com",
|
|
105
105
|
"web": "https://newrelic.com"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"name": "Diana Thayer",
|
|
109
|
+
"email": "dthayer@newrelic.com",
|
|
110
|
+
"web": "https://newrelic.com"
|
|
106
111
|
}
|
|
107
112
|
],
|
|
108
113
|
"description": "New Relic agent",
|
|
@@ -129,8 +134,8 @@
|
|
|
129
134
|
"docs": "npm ci && jsdoc -c ./jsdoc-conf.json --private -r .",
|
|
130
135
|
"integration": "npm run prepare-test && npm run sub-install && time tap test/integration/**/**/*.tap.js --timeout=180 --no-coverage --reporter classic",
|
|
131
136
|
"prepare-test": "npm run ca-gen && npm run ssl && npm run docker-env",
|
|
132
|
-
"lint": "eslint ./*.js lib test bin",
|
|
133
|
-
"lint:fix": "eslint --fix, ./*.js lib test bin",
|
|
137
|
+
"lint": "eslint ./*.js lib test bin examples",
|
|
138
|
+
"lint:fix": "eslint --fix, ./*.js lib test bin examples",
|
|
134
139
|
"public-docs": "npm ci && jsdoc -c ./jsdoc-conf.json --tutorials examples/shim api.js lib/shim/ lib/transaction/handle.js && cp examples/shim/*.png out/",
|
|
135
140
|
"publish-docs": "./bin/publish-docs.sh",
|
|
136
141
|
"services": "./bin/docker-services.sh",
|
|
@@ -169,11 +174,12 @@
|
|
|
169
174
|
"@newrelic/native-metrics": "^7.0.1"
|
|
170
175
|
},
|
|
171
176
|
"devDependencies": {
|
|
172
|
-
"@newrelic/eslint-config": "^0.0.
|
|
177
|
+
"@newrelic/eslint-config": "^0.0.3",
|
|
173
178
|
"@newrelic/newrelic-oss-cli": "^0.1.2",
|
|
174
179
|
"@newrelic/proxy": "^2.0.0",
|
|
175
|
-
"@newrelic/test-utilities": "^6.
|
|
180
|
+
"@newrelic/test-utilities": "^6.1.1",
|
|
176
181
|
"@octokit/rest": "^18.0.15",
|
|
182
|
+
"@slack/bolt": "^3.7.0",
|
|
177
183
|
"ajv": "^6.12.6",
|
|
178
184
|
"architect": "*",
|
|
179
185
|
"benchmark": "^2.1.4",
|
|
@@ -182,14 +188,15 @@
|
|
|
182
188
|
"commander": "^7.0.0",
|
|
183
189
|
"eslint": "^7.32.0",
|
|
184
190
|
"eslint-config-prettier": "^8.3.0",
|
|
191
|
+
"eslint-plugin-disable": "^2.0.1",
|
|
185
192
|
"eslint-plugin-header": "^3.1.1",
|
|
193
|
+
"eslint-plugin-jsdoc": "^36.1.0",
|
|
186
194
|
"eslint-plugin-node": "^11.1.0",
|
|
187
195
|
"eslint-plugin-prettier": "^3.4.0",
|
|
188
196
|
"express": "*",
|
|
189
197
|
"generic-pool": "^3.6.1",
|
|
190
198
|
"glob": "^7.1.2",
|
|
191
199
|
"got": "^8.0.1",
|
|
192
|
-
"http-errors": "^1.7.3",
|
|
193
200
|
"husky": "^6.0.0",
|
|
194
201
|
"jsdoc": "^3.6.3",
|
|
195
202
|
"lint-staged": "^11.0.0",
|