newrelic 7.5.2 → 8.3.0
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 +4989 -4886
- package/THIRD_PARTY_NOTICES.md +625 -216
- package/api.js +105 -174
- package/bin/test-naming-rules.js +38 -32
- package/bin/tracetractor +0 -1
- package/index.js +12 -18
- package/lib/agent.js +108 -111
- package/lib/aggregators/base-aggregator.js +1 -1
- package/lib/aggregators/event-aggregator.js +6 -6
- package/lib/attributes.js +12 -13
- package/lib/collector/api.js +32 -42
- package/lib/collector/facts.js +67 -65
- package/lib/collector/http-agents.js +30 -27
- package/lib/collector/parse-response.js +1 -2
- package/lib/collector/remote-method.js +43 -36
- package/lib/collector/serverless.js +13 -18
- package/lib/collector/ssl/certificates.js +1056 -1056
- package/lib/config/attribute-filter.js +90 -82
- package/lib/config/default.js +30 -18
- package/lib/config/env.js +17 -12
- package/lib/config/harvest-config-validator.js +1 -1
- package/lib/config/index.js +160 -177
- package/lib/config/merge-server-config.js +7 -5
- package/lib/custom-events/custom-event-aggregator.js +1 -1
- package/lib/db/parse-sql.js +6 -9
- package/lib/db/parsed-statement.js +6 -13
- package/lib/db/query-parsers/sql.js +6 -9
- package/lib/db/query-sample.js +7 -3
- package/lib/db/query-trace-aggregator.js +12 -12
- package/lib/db/utils.js +1 -1
- package/lib/environment.js +173 -138
- package/lib/errors/error-collector.js +18 -31
- package/lib/errors/error-event-aggregator.js +1 -1
- package/lib/errors/error-trace-aggregator.js +2 -3
- package/lib/errors/helper.js +21 -30
- package/lib/errors/index.js +16 -28
- package/lib/feature_flags.js +5 -8
- package/lib/grpc/connection/states.js +6 -6
- package/lib/grpc/connection.js +35 -46
- package/lib/header-attributes.js +49 -53
- package/lib/instrumentation/amqplib.js +8 -17
- package/lib/instrumentation/bluebird.js +61 -20
- package/lib/instrumentation/cassandra-driver.js +2 -2
- package/lib/instrumentation/connect.js +4 -3
- package/lib/instrumentation/core/async_hooks.js +11 -4
- package/lib/instrumentation/core/child_process.js +20 -28
- package/lib/instrumentation/core/crypto.js +1 -7
- package/lib/instrumentation/core/dns.js +3 -7
- package/lib/instrumentation/core/domain.js +2 -8
- package/lib/instrumentation/core/fs.js +22 -37
- package/lib/instrumentation/core/globals.js +3 -7
- package/lib/instrumentation/core/http-outbound.js +15 -40
- package/lib/instrumentation/core/http.js +29 -63
- package/lib/instrumentation/core/inspector.js +6 -10
- package/lib/instrumentation/core/net.js +3 -1
- package/lib/instrumentation/core/timers.js +17 -24
- package/lib/instrumentation/core/zlib.js +2 -10
- package/lib/instrumentation/express.js +4 -2
- package/lib/instrumentation/fastify/spec-builders.js +5 -0
- package/lib/instrumentation/fastify.js +37 -10
- package/lib/instrumentation/hapi/hapi-17.js +9 -10
- package/lib/instrumentation/hapi.js +15 -15
- package/lib/instrumentation/ioredis.js +1 -2
- package/lib/instrumentation/memcached.js +39 -43
- package/lib/instrumentation/mongodb/common.js +218 -0
- package/lib/instrumentation/mongodb/constants.js +87 -0
- package/lib/instrumentation/mongodb/v2-mongo.js +110 -0
- package/lib/instrumentation/mongodb/v3-mongo.js +80 -0
- package/lib/instrumentation/mongodb/v4-mongo.js +90 -0
- package/lib/instrumentation/mongodb.js +20 -312
- package/lib/instrumentation/mysql.js +33 -26
- package/lib/instrumentation/oracle.js +10 -14
- package/lib/instrumentation/pg.js +30 -21
- package/lib/instrumentation/promise.js +20 -17
- package/lib/instrumentation/redis.js +30 -30
- package/lib/instrumentation/when.js +9 -1
- package/lib/instrumentations.js +24 -24
- package/lib/logger.js +1 -1
- package/lib/metrics/index.js +37 -17
- package/lib/metrics/mapper.js +9 -9
- package/lib/metrics/metric-aggregator.js +5 -10
- package/lib/metrics/names.js +8 -7
- package/lib/metrics/normalizer/rule.js +6 -7
- package/lib/metrics/normalizer/tx_segment.js +17 -13
- package/lib/metrics/normalizer.js +30 -33
- package/lib/metrics/recorders/custom.js +3 -1
- package/lib/metrics/recorders/distributed-trace.js +3 -18
- package/lib/metrics/recorders/generic.js +3 -2
- package/lib/metrics/recorders/http.js +4 -6
- package/lib/metrics/recorders/http_external.js +1 -3
- package/lib/metrics/recorders/message-transaction.js +2 -12
- package/lib/metrics/recorders/other.js +2 -12
- package/lib/parse-proc-cpuinfo.js +11 -16
- package/lib/parse-proc-meminfo.js +5 -3
- package/lib/prioritized-attributes.js +12 -17
- package/lib/priority-queue.js +1 -1
- package/lib/proxy/grpc.js +1 -1
- package/lib/reservoir.js +9 -3
- package/lib/sampler.js +12 -13
- package/lib/serverless/api-gateway.js +3 -3
- package/lib/serverless/aws-lambda.js +28 -37
- package/lib/shim/conglomerate-shim.js +4 -4
- package/lib/shim/datastore-shim.js +29 -38
- package/lib/shim/index.js +8 -9
- package/lib/shim/message-shim.js +111 -113
- package/lib/shim/promise-shim.js +18 -13
- package/lib/shim/shim.js +72 -66
- package/lib/shim/specs/index.js +18 -19
- package/lib/shim/transaction-shim.js +26 -36
- package/lib/shim/webframework-shim.js +25 -35
- package/lib/shimmer.js +184 -166
- package/lib/spans/create-span-event-aggregator.js +24 -44
- package/lib/spans/span-context.js +4 -10
- package/lib/spans/span-event-aggregator.js +68 -13
- package/lib/spans/span-event.js +5 -7
- package/lib/spans/span-streamer.js +10 -18
- package/lib/spans/streaming-span-event-aggregator.js +1 -1
- package/lib/spans/streaming-span-event.js +4 -4
- package/lib/stats/apdex.js +5 -11
- package/lib/stats/index.js +12 -17
- package/lib/system-info.js +7 -3
- package/lib/timer.js +30 -16
- package/lib/transaction/dt-payload.js +1 -1
- package/lib/transaction/handle.js +19 -19
- package/lib/transaction/index.js +94 -112
- package/lib/transaction/name-state.js +5 -6
- package/lib/transaction/trace/aggregator.js +78 -73
- package/lib/transaction/trace/exclusive-time-calculator.js +5 -9
- package/lib/transaction/trace/index.js +26 -24
- package/lib/transaction/trace/segment.js +39 -56
- package/lib/transaction/tracecontext.js +37 -45
- package/lib/transaction/tracer/index.js +79 -44
- package/lib/transaction/transaction-event-aggregator.js +29 -31
- package/lib/uninstrumented.js +4 -5
- package/lib/util/attribute-types.js +1 -5
- package/lib/util/byte-limit.js +0 -1
- package/lib/util/cat.js +5 -13
- package/lib/util/codec.js +8 -4
- package/lib/util/deep-equal.js +48 -18
- package/lib/util/flatten.js +5 -2
- package/lib/util/hashes.js +2 -2
- package/lib/util/label-parser.js +7 -13
- package/lib/util/logger.js +31 -13
- package/lib/util/process-version.js +1 -1
- package/lib/util/properties.js +1 -1
- package/lib/util/sql/obfuscate.js +7 -17
- package/lib/util/stream-sink.js +2 -3
- package/lib/util/urltils.js +9 -13
- package/lib/utilization/aws-info.js +2 -3
- package/lib/utilization/azure-info.js +32 -30
- package/lib/utilization/common.js +5 -4
- package/lib/utilization/docker-info.js +4 -6
- package/lib/utilization/gcp-info.js +36 -35
- package/lib/utilization/index.js +1 -1
- package/lib/utilization/kubernetes-info.js +2 -2
- package/lib/utilization/pcf-info.js +4 -4
- package/package.json +32 -18
- package/stub_api.js +8 -6
|
@@ -7,14 +7,15 @@
|
|
|
7
7
|
|
|
8
8
|
var EventEmitter = require('events').EventEmitter
|
|
9
9
|
var util = require('util')
|
|
10
|
-
var logger = require('../logger').child({component: 'metric_normalizer'})
|
|
10
|
+
var logger = require('../logger').child({ component: 'metric_normalizer' })
|
|
11
11
|
var deepEqual = require('../util/deep-equal')
|
|
12
12
|
var NormalizerRule = require('./normalizer/rule')
|
|
13
13
|
var NAMES = require('../metrics/names.js')
|
|
14
14
|
|
|
15
|
-
|
|
16
15
|
function url(normalized, path, config) {
|
|
17
|
-
if (normalized)
|
|
16
|
+
if (normalized) {
|
|
17
|
+
return NAMES.NORMALIZED + normalized
|
|
18
|
+
}
|
|
18
19
|
|
|
19
20
|
if (config.enforce_backstop) {
|
|
20
21
|
return NAMES.NORMALIZED + '/*'
|
|
@@ -42,8 +43,12 @@ function plain(normalized, path) {
|
|
|
42
43
|
* backstop.
|
|
43
44
|
*/
|
|
44
45
|
function MetricNormalizer(config, type) {
|
|
45
|
-
if (!config)
|
|
46
|
-
|
|
46
|
+
if (!config) {
|
|
47
|
+
throw new Error('normalizer must be created with configuration.')
|
|
48
|
+
}
|
|
49
|
+
if (!type) {
|
|
50
|
+
throw new Error('normalizer must be created with a type.')
|
|
51
|
+
}
|
|
47
52
|
|
|
48
53
|
EventEmitter.call(this)
|
|
49
54
|
|
|
@@ -82,26 +87,25 @@ util.inherits(MetricNormalizer, EventEmitter)
|
|
|
82
87
|
MetricNormalizer.prototype.load = function load(json) {
|
|
83
88
|
if (json) {
|
|
84
89
|
this.rules = []
|
|
85
|
-
logger.debug(
|
|
86
|
-
json.length, this.type)
|
|
90
|
+
logger.debug('Received %s %s normalization rule(s) from the server', json.length, this.type)
|
|
87
91
|
|
|
88
|
-
json.forEach(
|
|
92
|
+
json.forEach((ruleJSON) => {
|
|
89
93
|
// no need to add the same rule twice
|
|
90
94
|
var rule = new NormalizerRule(ruleJSON)
|
|
91
95
|
if (!this.rules.find(deepEqual.bind(null, rule))) {
|
|
92
96
|
this.rules.push(rule)
|
|
93
|
-
logger.trace(
|
|
97
|
+
logger.trace('Loaded %s normalization rule: %s', this.type, rule)
|
|
94
98
|
}
|
|
95
|
-
}
|
|
99
|
+
})
|
|
96
100
|
|
|
97
101
|
/* I (FLN) always forget this, so making a note: JS sort is always
|
|
98
102
|
* IN-PLACE, even though it returns the sorted array.
|
|
99
103
|
*/
|
|
100
|
-
this.rules.sort(
|
|
104
|
+
this.rules.sort((a, b) => {
|
|
101
105
|
return a.precedence - b.precedence
|
|
102
106
|
})
|
|
103
107
|
|
|
104
|
-
logger.debug(
|
|
108
|
+
logger.debug('Loaded %s %s normalization rule(s).', this.rules.length, this.type)
|
|
105
109
|
}
|
|
106
110
|
}
|
|
107
111
|
|
|
@@ -114,26 +118,20 @@ MetricNormalizer.prototype.loadFromConfig = function loadFromConfig() {
|
|
|
114
118
|
var rules = this.config.rules
|
|
115
119
|
|
|
116
120
|
if (rules && rules.name && rules.name.length > 0) {
|
|
117
|
-
rules.name.forEach(
|
|
121
|
+
rules.name.forEach((rule) => {
|
|
118
122
|
if (!rule.pattern) {
|
|
119
|
-
return logger.error(
|
|
120
|
-
{rule: rule},
|
|
121
|
-
"Simple naming rules require a pattern."
|
|
122
|
-
)
|
|
123
|
+
return logger.error({ rule: rule }, 'Simple naming rules require a pattern.')
|
|
123
124
|
}
|
|
124
125
|
if (!rule.name) {
|
|
125
|
-
return logger.error(
|
|
126
|
-
{rule: rule},
|
|
127
|
-
"Simple naming rules require a replacement name."
|
|
128
|
-
)
|
|
126
|
+
return logger.error({ rule: rule }, 'Simple naming rules require a replacement name.')
|
|
129
127
|
}
|
|
130
128
|
|
|
131
129
|
var precedence = rule.precedence
|
|
132
130
|
var terminal = rule.terminate_chain
|
|
133
131
|
var json = {
|
|
134
132
|
match_expression: rule.pattern,
|
|
135
|
-
eval_order:
|
|
136
|
-
terminate_chain:
|
|
133
|
+
eval_order: typeof precedence === 'number' ? precedence : 500,
|
|
134
|
+
terminate_chain: typeof terminal === 'boolean' ? terminal : true,
|
|
137
135
|
replace_all: rule.replace_all,
|
|
138
136
|
replacement: rule.name,
|
|
139
137
|
ignore: false
|
|
@@ -142,22 +140,20 @@ MetricNormalizer.prototype.loadFromConfig = function loadFromConfig() {
|
|
|
142
140
|
// Find where the rule should be inserted and do so.
|
|
143
141
|
var reverse = this.config.feature_flag.reverse_naming_rules
|
|
144
142
|
var insert = this.rules.findIndex(function findRule(r) {
|
|
145
|
-
return reverse
|
|
146
|
-
? r.precedence >= json.eval_order
|
|
147
|
-
: r.precedence > json.eval_order
|
|
143
|
+
return reverse ? r.precedence >= json.eval_order : r.precedence > json.eval_order
|
|
148
144
|
})
|
|
149
145
|
if (insert === -1) {
|
|
150
146
|
this.rules.push(new NormalizerRule(json))
|
|
151
147
|
} else {
|
|
152
148
|
this.rules.splice(insert, 0, new NormalizerRule(json))
|
|
153
149
|
}
|
|
154
|
-
}
|
|
150
|
+
})
|
|
155
151
|
}
|
|
156
152
|
|
|
157
153
|
if (rules && rules.ignore && rules.ignore.length > 0) {
|
|
158
|
-
rules.ignore.forEach(
|
|
154
|
+
rules.ignore.forEach((pattern) => {
|
|
159
155
|
this.addSimple(pattern)
|
|
160
|
-
}
|
|
156
|
+
})
|
|
161
157
|
}
|
|
162
158
|
}
|
|
163
159
|
|
|
@@ -174,7 +170,9 @@ MetricNormalizer.prototype.loadFromConfig = function loadFromConfig() {
|
|
|
174
170
|
* @param {string} [name] The name to use for the transaction.
|
|
175
171
|
*/
|
|
176
172
|
MetricNormalizer.prototype.addSimple = function addSimple(pattern, name) {
|
|
177
|
-
if (!pattern)
|
|
173
|
+
if (!pattern) {
|
|
174
|
+
return logger.error('Simple naming rules require a pattern.')
|
|
175
|
+
}
|
|
178
176
|
|
|
179
177
|
var json = {
|
|
180
178
|
match_expression: pattern,
|
|
@@ -227,13 +225,12 @@ MetricNormalizer.prototype.normalize = function normalize(path) {
|
|
|
227
225
|
// that would increase memory overhead by creating additional array
|
|
228
226
|
this.emit('appliedRule', rule, normalized, last)
|
|
229
227
|
|
|
230
|
-
logger.trace({rule: rule, type: this.type},
|
|
231
|
-
"Normalized %s to %s.", last, normalized)
|
|
228
|
+
logger.trace({ rule: rule, type: this.type }, 'Normalized %s to %s.', last, normalized)
|
|
232
229
|
last = normalized
|
|
233
230
|
}
|
|
234
231
|
|
|
235
232
|
if (rule.isTerminal) {
|
|
236
|
-
logger.trace({rule: rule},
|
|
233
|
+
logger.trace({ rule: rule }, 'Terminating normalization.')
|
|
237
234
|
break
|
|
238
235
|
}
|
|
239
236
|
}
|
|
@@ -13,7 +13,9 @@ function record(segment, scope) {
|
|
|
13
13
|
var transaction = segment.transaction
|
|
14
14
|
var name = NAMES.CUSTOM + NAMES.ACTION_DELIMITER + segment.name
|
|
15
15
|
|
|
16
|
-
if (scope)
|
|
16
|
+
if (scope) {
|
|
17
|
+
transaction.measure(name, scope, duration, exclusive)
|
|
18
|
+
}
|
|
17
19
|
|
|
18
20
|
transaction.measure(name, null, duration, exclusive)
|
|
19
21
|
}
|
|
@@ -20,29 +20,14 @@ function recordDistributedTrace(tx, suffix, duration, exclusive) {
|
|
|
20
20
|
const suffixes = ['', suffix]
|
|
21
21
|
|
|
22
22
|
suffixes.forEach(function record(suf) {
|
|
23
|
-
tx.measure(
|
|
24
|
-
`${NAMES.DISTRIBUTED_TRACE.DURATION}/${tag}${suf}`,
|
|
25
|
-
null,
|
|
26
|
-
duration,
|
|
27
|
-
exclusive
|
|
28
|
-
)
|
|
23
|
+
tx.measure(`${NAMES.DISTRIBUTED_TRACE.DURATION}/${tag}${suf}`, null, duration, exclusive)
|
|
29
24
|
|
|
30
25
|
if (tx.hasErrors()) {
|
|
31
|
-
tx.measure(
|
|
32
|
-
`${NAMES.DISTRIBUTED_TRACE.ERRORS}/${tag}${suf}`,
|
|
33
|
-
null,
|
|
34
|
-
duration,
|
|
35
|
-
exclusive
|
|
36
|
-
)
|
|
26
|
+
tx.measure(`${NAMES.DISTRIBUTED_TRACE.ERRORS}/${tag}${suf}`, null, duration, exclusive)
|
|
37
27
|
}
|
|
38
28
|
|
|
39
29
|
if (distTraceReceived) {
|
|
40
|
-
tx.measure(
|
|
41
|
-
`${NAMES.DISTRIBUTED_TRACE.TRANSPORT}/${tag}${suf}`,
|
|
42
|
-
null,
|
|
43
|
-
duration,
|
|
44
|
-
exclusive
|
|
45
|
-
)
|
|
30
|
+
tx.measure(`${NAMES.DISTRIBUTED_TRACE.TRANSPORT}/${tag}${suf}`, null, duration, exclusive)
|
|
46
31
|
}
|
|
47
32
|
})
|
|
48
33
|
}
|
|
@@ -10,8 +10,9 @@ function record(segment, scope) {
|
|
|
10
10
|
var exclusive = segment.getExclusiveDurationInMillis()
|
|
11
11
|
var transaction = segment.transaction
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
if (scope) {
|
|
14
|
+
transaction.measure(segment.name, scope, duration, exclusive)
|
|
15
|
+
}
|
|
15
16
|
|
|
16
17
|
transaction.measure(segment.name, null, duration, exclusive)
|
|
17
18
|
}
|
|
@@ -12,7 +12,9 @@ const TO_MILLIS = 1e3
|
|
|
12
12
|
|
|
13
13
|
function recordWeb(segment, scope) {
|
|
14
14
|
// in web metrics, scope is required
|
|
15
|
-
if (!scope)
|
|
15
|
+
if (!scope) {
|
|
16
|
+
return
|
|
17
|
+
}
|
|
16
18
|
|
|
17
19
|
var tx = segment.transaction
|
|
18
20
|
// if there was a nested webTransaction use its recorder instead
|
|
@@ -41,11 +43,7 @@ function recordWeb(segment, scope) {
|
|
|
41
43
|
if (config.distributed_tracing.enabled) {
|
|
42
44
|
recordDistributedTrace(tx, 'Web', duration, exclusive)
|
|
43
45
|
} else if (tx.incomingCatId) {
|
|
44
|
-
tx.measure(
|
|
45
|
-
NAMES.CLIENT_APPLICATION + '/' + tx.incomingCatId + "/all",
|
|
46
|
-
null,
|
|
47
|
-
tx.catResponseTime
|
|
48
|
-
)
|
|
46
|
+
tx.measure(NAMES.CLIENT_APPLICATION + '/' + tx.incomingCatId + '/all', null, tx.catResponseTime)
|
|
49
47
|
}
|
|
50
48
|
|
|
51
49
|
tx._setApdex(NAMES.APDEX + '/' + partial, duration, keyApdexInMillis)
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
|
|
8
8
|
var EXTERNAL = require('../../metrics/names').EXTERNAL
|
|
9
9
|
|
|
10
|
-
|
|
11
10
|
function recordExternal(host, library) {
|
|
12
11
|
return function externalRecorder(segment, scope) {
|
|
13
12
|
var duration = segment.getDurationInMillis()
|
|
@@ -35,8 +34,7 @@ function recordExternal(host, library) {
|
|
|
35
34
|
// This CAT metric replaces scoped External/{host}/{method}
|
|
36
35
|
if (scope) {
|
|
37
36
|
transaction.measure(
|
|
38
|
-
EXTERNAL.TRANSACTION + host + '/' + segment.catId +
|
|
39
|
-
'/' + segment.catTransaction,
|
|
37
|
+
EXTERNAL.TRANSACTION + host + '/' + segment.catId + '/' + segment.catTransaction,
|
|
40
38
|
scope,
|
|
41
39
|
duration,
|
|
42
40
|
exclusive
|
|
@@ -28,18 +28,8 @@ function recordMessageTransaction(segment, scope) {
|
|
|
28
28
|
)
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
tx.measure(
|
|
32
|
-
|
|
33
|
-
null,
|
|
34
|
-
duration,
|
|
35
|
-
exclusive
|
|
36
|
-
)
|
|
37
|
-
tx.measure(
|
|
38
|
-
NAMES.OTHER_TRANSACTION.RESPONSE_TIME + '/all',
|
|
39
|
-
null,
|
|
40
|
-
duration,
|
|
41
|
-
exclusive
|
|
42
|
-
)
|
|
31
|
+
tx.measure(NAMES.MESSAGE_TRANSACTION.RESPONSE_TIME + '/all', null, duration, exclusive)
|
|
32
|
+
tx.measure(NAMES.OTHER_TRANSACTION.RESPONSE_TIME + '/all', null, duration, exclusive)
|
|
43
33
|
tx.measure(NAMES.OTHER_TRANSACTION.TOTAL_TIME, null, totalTime, exclusive)
|
|
44
34
|
}
|
|
45
35
|
|
|
@@ -22,21 +22,11 @@ function recordBackground(segment, scope) {
|
|
|
22
22
|
|
|
23
23
|
if (scope) {
|
|
24
24
|
tx.measure(scope, null, duration, exclusive)
|
|
25
|
-
tx.measure(
|
|
26
|
-
NAMES.OTHER_TRANSACTION.TOTAL_TIME + '/' + name,
|
|
27
|
-
null,
|
|
28
|
-
totalTime,
|
|
29
|
-
exclusive
|
|
30
|
-
)
|
|
25
|
+
tx.measure(NAMES.OTHER_TRANSACTION.TOTAL_TIME + '/' + name, null, totalTime, exclusive)
|
|
31
26
|
}
|
|
32
27
|
// rollup for background total time doesn't have `/all` where the response
|
|
33
28
|
// time version does.
|
|
34
|
-
tx.measure(
|
|
35
|
-
NAMES.OTHER_TRANSACTION.RESPONSE_TIME + '/all',
|
|
36
|
-
null,
|
|
37
|
-
duration,
|
|
38
|
-
exclusive
|
|
39
|
-
)
|
|
29
|
+
tx.measure(NAMES.OTHER_TRANSACTION.RESPONSE_TIME + '/all', null, duration, exclusive)
|
|
40
30
|
tx.measure(NAMES.OTHER_TRANSACTION.TOTAL_TIME, null, totalTime, exclusive)
|
|
41
31
|
|
|
42
32
|
if (tx.agent.config.distributed_tracing.enabled) {
|
|
@@ -5,16 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
'use strict'
|
|
7
7
|
|
|
8
|
-
var logger = require('./logger.js').child({component: 'proc-cpuinfo'})
|
|
8
|
+
var logger = require('./logger.js').child({ component: 'proc-cpuinfo' })
|
|
9
9
|
module.exports = parseProcCPUInfo
|
|
10
10
|
|
|
11
11
|
function parseProcCPUInfo(data) {
|
|
12
|
-
var relevantAttributes = [
|
|
13
|
-
'processor',
|
|
14
|
-
'physical id',
|
|
15
|
-
'cpu cores',
|
|
16
|
-
'core id'
|
|
17
|
-
]
|
|
12
|
+
var relevantAttributes = ['processor', 'physical id', 'cpu cores', 'core id']
|
|
18
13
|
|
|
19
14
|
var processorStats = {
|
|
20
15
|
logical: null,
|
|
@@ -23,13 +18,11 @@ function parseProcCPUInfo(data) {
|
|
|
23
18
|
}
|
|
24
19
|
|
|
25
20
|
// separate the processors
|
|
26
|
-
var splitData = data.split('\n')
|
|
27
|
-
.map(function
|
|
28
|
-
return
|
|
29
|
-
.map(function eliminateExtraWhitespace(s) {
|
|
30
|
-
return s.replace(/\\r|\\t| {2,}/g, '').trim()
|
|
31
|
-
})
|
|
21
|
+
var splitData = data.split('\n').map(function formatAttribute(attr) {
|
|
22
|
+
return attr.split(':').map(function eliminateExtraWhitespace(s) {
|
|
23
|
+
return s.replace(/\\r|\\t| {2,}/g, '').trim()
|
|
32
24
|
})
|
|
25
|
+
})
|
|
33
26
|
|
|
34
27
|
var validData = splitData.filter(function checkForValidAttrs(a) {
|
|
35
28
|
return a.length === 2 && relevantAttributes.indexOf(a[0]) !== -1
|
|
@@ -102,9 +95,11 @@ function countProcessorStats(processors) {
|
|
|
102
95
|
|
|
103
96
|
for (var i = 0; i < processors.length; i++) {
|
|
104
97
|
var processor = processors[i]
|
|
105
|
-
if (
|
|
106
|
-
|
|
107
|
-
|
|
98
|
+
if (
|
|
99
|
+
processor['physical id'] &&
|
|
100
|
+
processor['cpu cores'] &&
|
|
101
|
+
phys.indexOf(processor['physical id']) === -1
|
|
102
|
+
) {
|
|
108
103
|
phys.push(processor['physical id'])
|
|
109
104
|
cores.push(processor['cpu cores'])
|
|
110
105
|
}
|
|
@@ -5,14 +5,16 @@
|
|
|
5
5
|
|
|
6
6
|
'use strict'
|
|
7
7
|
|
|
8
|
-
var logger = require('./logger.js').child({component: 'proc-meminfo'})
|
|
8
|
+
var logger = require('./logger.js').child({ component: 'proc-meminfo' })
|
|
9
9
|
|
|
10
10
|
module.exports = parseProcMeminfo
|
|
11
11
|
|
|
12
12
|
function parseProcMeminfo(data) {
|
|
13
|
-
var
|
|
13
|
+
var memTotal = parseInt(data.replace(/MemTotal:\s*(\d*)\skB/, '$1'), 10)
|
|
14
14
|
|
|
15
|
-
if (
|
|
15
|
+
if (memTotal) {
|
|
16
|
+
return memTotal / 1024
|
|
17
|
+
}
|
|
16
18
|
|
|
17
19
|
logger.debug('Unable to parse memory string:', data)
|
|
18
20
|
return null
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
'use strict'
|
|
7
7
|
|
|
8
8
|
const Config = require('./config')
|
|
9
|
-
const logger = require('./logger').child({component: 'attributes'})
|
|
9
|
+
const logger = require('./logger').child({ component: 'attributes' })
|
|
10
10
|
const isValidType = require('./util/attribute-types')
|
|
11
11
|
const byteUtils = require('./util/byte-limit')
|
|
12
12
|
const properties = require('./util/properties')
|
|
@@ -24,13 +24,12 @@ class PrioritizedAttributes {
|
|
|
24
24
|
this.attributes = new Map()
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
|
|
28
27
|
isValidLength(str) {
|
|
29
28
|
return typeof str === 'number' || byteUtils.isValidLength(str, 255)
|
|
30
29
|
}
|
|
31
30
|
|
|
32
31
|
_set(destinations, key, value, truncateExempt, priority) {
|
|
33
|
-
this.attributes.set(key, {value, destinations, truncateExempt, priority})
|
|
32
|
+
this.attributes.set(key, { value, destinations, truncateExempt, priority })
|
|
34
33
|
}
|
|
35
34
|
|
|
36
35
|
get(dest) {
|
|
@@ -41,9 +40,10 @@ class PrioritizedAttributes {
|
|
|
41
40
|
continue
|
|
42
41
|
}
|
|
43
42
|
|
|
44
|
-
attrs[key] =
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
attrs[key] =
|
|
44
|
+
typeof attr.value === 'string' && !attr.truncateExempt
|
|
45
|
+
? byteUtils.truncate(attr.value, 255)
|
|
46
|
+
: attr.value
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
return attrs
|
|
@@ -81,7 +81,7 @@ class PrioritizedAttributes {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
if (existingAttribute && priority < existingAttribute.priority) {
|
|
84
|
-
logger.debug(
|
|
84
|
+
logger.debug("incoming priority for '%s' is lower than existing, not updating.", key)
|
|
85
85
|
logger.trace(
|
|
86
86
|
'%s attribute retained value: %s, ignored value: %s',
|
|
87
87
|
key,
|
|
@@ -94,8 +94,8 @@ class PrioritizedAttributes {
|
|
|
94
94
|
if (!isValidType(value)) {
|
|
95
95
|
logger.debug(
|
|
96
96
|
'Not adding attribute %s with %s value type. This is expected for undefined' +
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
'attributes and only an issue if an attribute is not expected to be undefined' +
|
|
98
|
+
'or not of the type expected.',
|
|
99
99
|
key,
|
|
100
100
|
typeof value
|
|
101
101
|
)
|
|
@@ -103,14 +103,10 @@ class PrioritizedAttributes {
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
if (!this.isValidLength(key)) {
|
|
106
|
-
logger.warn(
|
|
107
|
-
'Length limit exceeded for attribute name, not adding: %s',
|
|
108
|
-
key
|
|
109
|
-
)
|
|
106
|
+
logger.warn('Length limit exceeded for attribute name, not adding: %s', key)
|
|
110
107
|
return
|
|
111
108
|
}
|
|
112
109
|
|
|
113
|
-
|
|
114
110
|
// Only set the attribute if at least one destination passed
|
|
115
111
|
const validDestinations = this.filter(destinations, key)
|
|
116
112
|
if (!validDestinations) {
|
|
@@ -119,8 +115,7 @@ class PrioritizedAttributes {
|
|
|
119
115
|
|
|
120
116
|
if (droppableAttributeKey) {
|
|
121
117
|
logger.trace(
|
|
122
|
-
'dropping existing lower priority attribute %s ' +
|
|
123
|
-
'to add higher priority attribute %s',
|
|
118
|
+
'dropping existing lower priority attribute %s ' + 'to add higher priority attribute %s',
|
|
124
119
|
droppableAttributeKey,
|
|
125
120
|
key
|
|
126
121
|
)
|
|
@@ -199,7 +194,7 @@ class PrioritizedAttributes {
|
|
|
199
194
|
}
|
|
200
195
|
|
|
201
196
|
function makeFilter(scope) {
|
|
202
|
-
const {attributeFilter} = Config.getInstance()
|
|
197
|
+
const { attributeFilter } = Config.getInstance()
|
|
203
198
|
if (scope === 'transaction') {
|
|
204
199
|
return (d, k) => attributeFilter.filterTransaction(d, k)
|
|
205
200
|
} else if (scope === 'segment') {
|
package/lib/priority-queue.js
CHANGED
|
@@ -64,7 +64,7 @@ PriorityQueue.prototype.getRawEvents = function getRawEvents() {
|
|
|
64
64
|
var current = head
|
|
65
65
|
|
|
66
66
|
do {
|
|
67
|
-
evts.push({value: current.value, priority: current.key})
|
|
67
|
+
evts.push({ value: current.value, priority: current.key })
|
|
68
68
|
if (current.child) {
|
|
69
69
|
_getRawEvents(current.child, evts)
|
|
70
70
|
}
|
package/lib/proxy/grpc.js
CHANGED
package/lib/reservoir.js
CHANGED
|
@@ -30,7 +30,9 @@ Reservoir.prototype.add = function add(item) {
|
|
|
30
30
|
// end, swapping the last element (the new one) with a random element in the list,
|
|
31
31
|
// then dropping the last element (the potentially swapped one) in the list.
|
|
32
32
|
var toReplace = Math.floor(Math.random() * (this.seen + 2))
|
|
33
|
-
if (toReplace < this.limit)
|
|
33
|
+
if (toReplace < this.limit) {
|
|
34
|
+
this._data[toReplace] = item
|
|
35
|
+
}
|
|
34
36
|
}
|
|
35
37
|
this.seen++
|
|
36
38
|
}
|
|
@@ -40,8 +42,12 @@ Reservoir.prototype.toArray = function toArray() {
|
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
Reservoir.prototype.merge = function merge(items) {
|
|
43
|
-
if (!items || !items.length)
|
|
44
|
-
|
|
45
|
+
if (!items || !items.length) {
|
|
46
|
+
return
|
|
47
|
+
}
|
|
48
|
+
if (items === this._data) {
|
|
49
|
+
return
|
|
50
|
+
}
|
|
45
51
|
for (var i = 0; i < items.length; i++) {
|
|
46
52
|
this.add(items[i])
|
|
47
53
|
}
|
package/lib/sampler.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
'use strict'
|
|
7
7
|
|
|
8
8
|
var NAMES = require('./metrics/names')
|
|
9
|
-
var logger = require('./logger').child({component: 'sampler'})
|
|
9
|
+
var logger = require('./logger').child({ component: 'sampler' })
|
|
10
10
|
var Timer = require('./timer')
|
|
11
11
|
var os = require('os')
|
|
12
12
|
|
|
@@ -85,7 +85,7 @@ function generateCPUMetricRecorder(agent) {
|
|
|
85
85
|
lastSampleTime = Date.now()
|
|
86
86
|
|
|
87
87
|
var userUtil = userTime / totalCpuTime
|
|
88
|
-
var sysUtil
|
|
88
|
+
var sysUtil = sysTime / totalCpuTime
|
|
89
89
|
|
|
90
90
|
recordValue(agent, NAMES.CPU.USER_TIME, userTime)
|
|
91
91
|
recordValue(agent, NAMES.CPU.SYSTEM_TIME, sysTime)
|
|
@@ -149,7 +149,7 @@ function sampleGc(agent, nativeMetrics) {
|
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
-
var sampler = module.exports = {
|
|
152
|
+
var sampler = (module.exports = {
|
|
153
153
|
state: 'stopped',
|
|
154
154
|
sampleMemory: sampleMemory,
|
|
155
155
|
checkEvents: checkEvents,
|
|
@@ -170,12 +170,12 @@ var sampler = module.exports = {
|
|
|
170
170
|
})
|
|
171
171
|
} catch (err) {
|
|
172
172
|
logger.info(
|
|
173
|
-
{error: {message: err.message, stack: err.stack}},
|
|
173
|
+
{ error: { message: err.message, stack: err.stack } },
|
|
174
174
|
'Not adding native metric sampler.'
|
|
175
175
|
)
|
|
176
|
-
agent.metrics
|
|
177
|
-
NAMES.SUPPORTABILITY.DEPENDENCIES + '/NoNativeMetricsModule'
|
|
178
|
-
|
|
176
|
+
agent.metrics
|
|
177
|
+
.getOrCreateMetric(NAMES.SUPPORTABILITY.DEPENDENCIES + '/NoNativeMetricsModule')
|
|
178
|
+
.incrementCallCount()
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
181
|
|
|
@@ -197,12 +197,11 @@ var sampler = module.exports = {
|
|
|
197
197
|
|
|
198
198
|
// Add CPU sampling using the built-in data if available, otherwise pulling
|
|
199
199
|
// from the native module.
|
|
200
|
-
if (process.cpuUsage) {
|
|
200
|
+
if (process.cpuUsage) {
|
|
201
|
+
// introduced in 6.1.0
|
|
201
202
|
samplers.push(new Sampler(sampleCpu(agent), SAMPLE_INTERVAL))
|
|
202
203
|
} else if (this.nativeMetrics && this.nativeMetrics.usageEnabled) {
|
|
203
|
-
samplers.push(
|
|
204
|
-
new Sampler(sampleCpuNative(agent, this.nativeMetrics), SAMPLE_INTERVAL)
|
|
205
|
-
)
|
|
204
|
+
samplers.push(new Sampler(sampleCpuNative(agent, this.nativeMetrics), SAMPLE_INTERVAL))
|
|
206
205
|
} else {
|
|
207
206
|
logger.debug('Not adding CPU metric sampler.')
|
|
208
207
|
}
|
|
@@ -225,7 +224,7 @@ var sampler = module.exports = {
|
|
|
225
224
|
this.nativeMetrics = null
|
|
226
225
|
}
|
|
227
226
|
}
|
|
228
|
-
}
|
|
227
|
+
})
|
|
229
228
|
|
|
230
229
|
function recordValue(agent, metric, value) {
|
|
231
230
|
var stats = agent.metrics.getOrCreateMetric(metric)
|
|
@@ -243,5 +242,5 @@ function divideMetric(metric, divisor) {
|
|
|
243
242
|
metric.min /= divisor
|
|
244
243
|
metric.max /= divisor
|
|
245
244
|
metric.total /= divisor
|
|
246
|
-
metric.sumOfSquares /=
|
|
245
|
+
metric.sumOfSquares /= divisor * divisor
|
|
247
246
|
}
|
|
@@ -14,9 +14,9 @@ class LambdaProxyWebRequest {
|
|
|
14
14
|
constructor(event) {
|
|
15
15
|
this.headers = event.headers
|
|
16
16
|
this.url = {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
path: event.path,
|
|
18
|
+
port: event.headers['X-Forwarded-Port'],
|
|
19
|
+
requestParameters: event.queryStringParameters
|
|
20
20
|
}
|
|
21
21
|
this.method = event.httpMethod
|
|
22
22
|
this.transportType = event.headers['X-Forwarded-Proto']
|