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/spans/span-event.js
CHANGED
package/lib/stats/apdex.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* CONSTANTS
|
|
11
11
|
*
|
|
12
12
|
*/
|
|
13
|
-
|
|
13
|
+
const FROM_MILLIS = 1e-3
|
|
14
14
|
|
|
15
15
|
function ApdexStats(apdexT) {
|
|
16
16
|
if (!apdexT && apdexT !== 0) {
|
|
@@ -24,7 +24,7 @@ function ApdexStats(apdexT) {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
ApdexStats.prototype.recordValue = function recordValue(time, overrideApdex) {
|
|
27
|
-
|
|
27
|
+
const apdexT = overrideApdex || this.apdexT
|
|
28
28
|
if (time <= apdexT) {
|
|
29
29
|
++this.satisfying
|
|
30
30
|
} else if (time <= 4 * apdexT) {
|
package/lib/stats/index.js
CHANGED
package/lib/system-info.js
CHANGED
|
@@ -5,15 +5,15 @@
|
|
|
5
5
|
|
|
6
6
|
'use strict'
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
const exec = require('child_process').exec
|
|
9
|
+
const readProc = require('./utilization/common').readProc
|
|
10
|
+
const getBootId = require('./utilization/docker-info').getBootId
|
|
11
|
+
const utilization = require('./utilization')
|
|
12
|
+
const logger = require('./logger.js').child({ component: 'system-info' })
|
|
13
|
+
const os = require('os')
|
|
14
|
+
const parseCpuInfo = require('./parse-proc-cpuinfo')
|
|
15
|
+
const parseMemInfo = require('./parse-proc-meminfo')
|
|
16
|
+
const platform = os.platform()
|
|
17
17
|
|
|
18
18
|
module.exports = fetchSystemInfo
|
|
19
19
|
|
|
@@ -22,19 +22,19 @@ function isInteger(i) {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
function fetchSystemInfo(agent, callback) {
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
const config = agent.config
|
|
26
|
+
const systemInfo = {
|
|
27
27
|
processorArch: os.arch()
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
const utilizationConfig = Object.create(null)
|
|
31
31
|
if (config.utilization) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
const configProcessors = config.utilization.logical_processors
|
|
33
|
+
const configRam = config.utilization.total_ram_mib
|
|
34
|
+
const configHostname = config.utilization.billing_hostname
|
|
35
35
|
|
|
36
36
|
if (configProcessors) {
|
|
37
|
-
|
|
37
|
+
const parsedConfigProcessors = parseFloat(configProcessors, 10)
|
|
38
38
|
if (!isNaN(parsedConfigProcessors) && isInteger(parsedConfigProcessors)) {
|
|
39
39
|
utilizationConfig.logical_processors = parsedConfigProcessors
|
|
40
40
|
} else {
|
|
@@ -46,7 +46,7 @@ function fetchSystemInfo(agent, callback) {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
if (configRam) {
|
|
49
|
-
|
|
49
|
+
const parsedConfigRam = parseFloat(configRam, 10)
|
|
50
50
|
if (!isNaN(parsedConfigRam) && isInteger(parsedConfigRam)) {
|
|
51
51
|
utilizationConfig.total_ram_mib = parsedConfigRam
|
|
52
52
|
} else {
|
|
@@ -73,8 +73,8 @@ function fetchSystemInfo(agent, callback) {
|
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
let tasksDone = 0
|
|
77
|
+
const numTasks = 5
|
|
78
78
|
function finishedResponse() {
|
|
79
79
|
if (++tasksDone === numTasks) {
|
|
80
80
|
callback(null, systemInfo)
|
|
@@ -111,7 +111,7 @@ function fetchSystemInfo(agent, callback) {
|
|
|
111
111
|
|
|
112
112
|
// placed on module for mocking purposes in tests
|
|
113
113
|
module.exports._getProcessorStats = function getProcessorStats(callback) {
|
|
114
|
-
|
|
114
|
+
const processorStats = {
|
|
115
115
|
logical: null,
|
|
116
116
|
cores: null,
|
|
117
117
|
packages: null
|
|
@@ -127,7 +127,7 @@ module.exports._getProcessorStats = function getProcessorStats(callback) {
|
|
|
127
127
|
processorStats.cores = parseFloat(cores, 10)
|
|
128
128
|
processorStats.packages = parseFloat(packages, 10)
|
|
129
129
|
|
|
130
|
-
for (
|
|
130
|
+
for (const key in processorStats) {
|
|
131
131
|
if (!processorStats[key] || !isInteger(processorStats[key])) {
|
|
132
132
|
processorStats[key] = null
|
|
133
133
|
}
|
|
@@ -196,8 +196,8 @@ function getSysctlValue(names, callback) {
|
|
|
196
196
|
if (!names) {
|
|
197
197
|
return callback(null)
|
|
198
198
|
}
|
|
199
|
-
|
|
200
|
-
|
|
199
|
+
let returned = false
|
|
200
|
+
let ran = 0
|
|
201
201
|
names.forEach(function sysctlName(name) {
|
|
202
202
|
exec('sysctl -n ' + name, respond)
|
|
203
203
|
|
package/lib/timer.js
CHANGED
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
* are set, but the timer has not yet been harvested).
|
|
17
17
|
* DEAD timer has been harvested and can only have its duration read.
|
|
18
18
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
const PENDING = 1
|
|
20
|
+
const RUNNING = 2
|
|
21
|
+
const STOPPED = 3
|
|
22
22
|
|
|
23
23
|
function hrToMillis(hr) {
|
|
24
24
|
// process.hrTime gives you [second, nanosecond] duration pairs
|
|
@@ -209,8 +209,8 @@ Timer.prototype.toRange = function toRange() {
|
|
|
209
209
|
*/
|
|
210
210
|
Timer.prototype.startedRelativeTo = function startedRelativeTo(other) {
|
|
211
211
|
if (this.hrstart && other.hrstart) {
|
|
212
|
-
|
|
213
|
-
|
|
212
|
+
const s = this.hrstart[0] - other.hrstart[0]
|
|
213
|
+
const ns = this.hrstart[1] - other.hrstart[1]
|
|
214
214
|
|
|
215
215
|
return hrToMillis([s, ns])
|
|
216
216
|
}
|
package/lib/transaction/index.js
CHANGED
|
@@ -6,16 +6,16 @@
|
|
|
6
6
|
'use strict'
|
|
7
7
|
|
|
8
8
|
const errorHelper = require('../errors/helper')
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
const hashes = require('../util/hashes')
|
|
10
|
+
const logger = require('../logger').child({ component: 'transaction' })
|
|
11
|
+
const Metrics = require('../metrics')
|
|
12
|
+
const NAMES = require('../metrics/names')
|
|
13
|
+
const NameState = require('./name-state')
|
|
14
|
+
const props = require('../util/properties')
|
|
15
|
+
const Timer = require('../timer')
|
|
16
|
+
const Trace = require('./trace')
|
|
17
|
+
const url = require('url')
|
|
18
|
+
const urltils = require('../util/urltils')
|
|
19
19
|
const TraceContext = require('./tracecontext').TraceContext
|
|
20
20
|
|
|
21
21
|
/*
|
|
@@ -270,11 +270,11 @@ Transaction.prototype.getResponseTimeInMillis = function getResponseTimeInMillis
|
|
|
270
270
|
*/
|
|
271
271
|
Transaction.prototype._runUserNamingRules = function _runUserNamingRules(requestUrl) {
|
|
272
272
|
// 1. user normalization rules (set in configuration)
|
|
273
|
-
|
|
273
|
+
const normalized = this.agent.userNormalizer.normalize(requestUrl)
|
|
274
274
|
if (normalized.matched) {
|
|
275
275
|
// After applying user naming rule, apply server-side sent rules to
|
|
276
276
|
// further squash possible MGIs
|
|
277
|
-
|
|
277
|
+
const serverNormalized = this.agent.urlNormalizer.normalize(normalized.value)
|
|
278
278
|
if (serverNormalized.ignore) {
|
|
279
279
|
normalized.ignore = true
|
|
280
280
|
}
|
|
@@ -294,7 +294,7 @@ Transaction.prototype._runUserNamingRules = function _runUserNamingRules(request
|
|
|
294
294
|
* @param {string} requestUrl - The URL to normalize and apply to this transaction.
|
|
295
295
|
*/
|
|
296
296
|
Transaction.prototype.applyUserNamingRules = function applyUserNamingRules(requestUrl) {
|
|
297
|
-
|
|
297
|
+
const normalized = this._runUserNamingRules(requestUrl)
|
|
298
298
|
if (normalized.ignore) {
|
|
299
299
|
this.ignore = normalized.ignore
|
|
300
300
|
}
|
|
@@ -327,11 +327,11 @@ Transaction.prototype.setPartialName = function setPartialName(name) {
|
|
|
327
327
|
*/
|
|
328
328
|
Transaction.prototype._partialNameFromUri = _partialNameFromUri
|
|
329
329
|
function _partialNameFromUri(requestUrl, status) {
|
|
330
|
-
|
|
330
|
+
const scrubbedUrl = urltils.scrub(requestUrl)
|
|
331
331
|
|
|
332
332
|
// 0. If there is a name in the name-state stack, use it.
|
|
333
|
-
|
|
334
|
-
|
|
333
|
+
let partialName = this._partialName
|
|
334
|
+
let ignore = false
|
|
335
335
|
if (!this.nameState.isEmpty()) {
|
|
336
336
|
partialName = this.nameState.getFullName()
|
|
337
337
|
}
|
|
@@ -343,7 +343,7 @@ function _partialNameFromUri(requestUrl, status) {
|
|
|
343
343
|
|
|
344
344
|
// 2. user normalization rules (set in configuration) can override transaction
|
|
345
345
|
// naming from API
|
|
346
|
-
|
|
346
|
+
const userNormalized = this._runUserNamingRules(scrubbedUrl)
|
|
347
347
|
ignore = ignore || userNormalized.ignore
|
|
348
348
|
if (userNormalized.matched) {
|
|
349
349
|
partialName = userNormalized.value
|
|
@@ -358,7 +358,7 @@ function _partialNameFromUri(requestUrl, status) {
|
|
|
358
358
|
if (statusName) {
|
|
359
359
|
partialName = statusName
|
|
360
360
|
} else {
|
|
361
|
-
|
|
361
|
+
const normalized = this.agent.urlNormalizer.normalize(scrubbedUrl)
|
|
362
362
|
ignore = ignore || normalized.ignore
|
|
363
363
|
partialName = normalized.value
|
|
364
364
|
}
|
|
@@ -421,7 +421,7 @@ function finalizeNameFromUri(requestURL, statusCode) {
|
|
|
421
421
|
this.statusCode = statusCode
|
|
422
422
|
|
|
423
423
|
// Derive the name from the request URL.
|
|
424
|
-
|
|
424
|
+
const partialName = this._partialNameFromUri(requestURL, statusCode)
|
|
425
425
|
this._partialName = partialName.value
|
|
426
426
|
if (partialName.ignore) {
|
|
427
427
|
this.ignore = true
|
|
@@ -430,7 +430,7 @@ function finalizeNameFromUri(requestURL, statusCode) {
|
|
|
430
430
|
// If a namestate stack exists, copy route parameters over to the trace.
|
|
431
431
|
if (!this.nameState.isEmpty() && this.baseSegment) {
|
|
432
432
|
this.nameState.forEachParams(function forEachRouteParams(params) {
|
|
433
|
-
for (
|
|
433
|
+
for (const key in params) {
|
|
434
434
|
if (props.hasOwn(params, key)) {
|
|
435
435
|
this.trace.attributes.addAttribute(DESTS.NONE, 'request.parameters.' + key, params[key])
|
|
436
436
|
|
|
@@ -450,8 +450,8 @@ function finalizeNameFromUri(requestURL, statusCode) {
|
|
|
450
450
|
}
|
|
451
451
|
|
|
452
452
|
// Apply transaction name normalization rules (sent by server) to full name.
|
|
453
|
-
|
|
454
|
-
|
|
453
|
+
const fullName = TYPE_METRICS[this.type] + '/' + this._partialName
|
|
454
|
+
const normalized = this.agent.transactionNameNormalizer.normalize(fullName)
|
|
455
455
|
if (normalized.ignore) {
|
|
456
456
|
this.ignore = true
|
|
457
457
|
}
|
|
@@ -499,8 +499,8 @@ Transaction.prototype._copyNameToActiveSpan = function _copyNameToActiveSpan(nam
|
|
|
499
499
|
*/
|
|
500
500
|
Transaction.prototype._markAsWeb = function _markAsWeb(rawURL) {
|
|
501
501
|
// Because we are assured we have the URL here, lets grab query params.
|
|
502
|
-
|
|
503
|
-
for (
|
|
502
|
+
const params = urltils.parseParameters(rawURL)
|
|
503
|
+
for (const key in params) {
|
|
504
504
|
if (props.hasOwn(params, key)) {
|
|
505
505
|
this.trace.attributes.addAttribute(DESTS.NONE, 'request.parameters.' + key, params[key])
|
|
506
506
|
|
|
@@ -539,11 +539,11 @@ Transaction.prototype.finalizeName = function finalizeName(name) {
|
|
|
539
539
|
return
|
|
540
540
|
}
|
|
541
541
|
|
|
542
|
-
|
|
542
|
+
const fullName = TYPE_METRICS[this.type] + '/' + this._partialName
|
|
543
543
|
|
|
544
544
|
// Transaction normalizers run on the full metric name, not the user facing
|
|
545
545
|
// transaction name.
|
|
546
|
-
|
|
546
|
+
const normalized = this.agent.transactionNameNormalizer.normalize(fullName)
|
|
547
547
|
if (normalized.ignore) {
|
|
548
548
|
this.ignore = true
|
|
549
549
|
}
|
|
@@ -589,7 +589,7 @@ Transaction.prototype.getName = function getName() {
|
|
|
589
589
|
}
|
|
590
590
|
|
|
591
591
|
Transaction.prototype.getFullName = function getFullName() {
|
|
592
|
-
|
|
592
|
+
let name = null
|
|
593
593
|
if (this.forceName) {
|
|
594
594
|
name = this.forceName
|
|
595
595
|
} else if (this.name) {
|
|
@@ -601,7 +601,7 @@ Transaction.prototype.getFullName = function getFullName() {
|
|
|
601
601
|
if (!name) {
|
|
602
602
|
return null
|
|
603
603
|
}
|
|
604
|
-
|
|
604
|
+
const fullName = TYPE_METRICS[this.type] + '/' + name
|
|
605
605
|
return this.agent.transactionNameNormalizer.normalize(fullName).value
|
|
606
606
|
}
|
|
607
607
|
|
|
@@ -635,7 +635,7 @@ Transaction.prototype.getScrubbedUrl = function getScrubbedUrl() {
|
|
|
635
635
|
this.parsedUrl = url.parse(this.url)
|
|
636
636
|
}
|
|
637
637
|
|
|
638
|
-
|
|
638
|
+
const scrubbedParsedUrl = Object.assign(Object.create(null), this.parsedUrl)
|
|
639
639
|
scrubbedParsedUrl.search = null
|
|
640
640
|
scrubbedParsedUrl.query = null
|
|
641
641
|
scrubbedParsedUrl.href = null
|
|
@@ -670,8 +670,8 @@ Transaction.prototype.addRecorder = function addRecorder(recorder) {
|
|
|
670
670
|
* and should be written to handle this.
|
|
671
671
|
*/
|
|
672
672
|
Transaction.prototype.record = function record() {
|
|
673
|
-
|
|
674
|
-
for (
|
|
673
|
+
const name = this.name
|
|
674
|
+
for (let i = 0, l = this._recorders.length; i < l; ++i) {
|
|
675
675
|
this._recorders[i](name)
|
|
676
676
|
}
|
|
677
677
|
}
|
|
@@ -700,7 +700,7 @@ Transaction.prototype.measure = function measure(name, scope, duration, exclusiv
|
|
|
700
700
|
* (optional).
|
|
701
701
|
*/
|
|
702
702
|
Transaction.prototype._setApdex = function _setApdex(name, duration, keyApdexInMillis) {
|
|
703
|
-
|
|
703
|
+
const apdexStats = this.metrics.getOrCreateApdexMetric(name, null, keyApdexInMillis)
|
|
704
704
|
|
|
705
705
|
// if we have an error-like status code, and all the errors are
|
|
706
706
|
// expected, we know the status code was caused by an expected
|
|
@@ -744,13 +744,13 @@ Transaction.prototype.includesOutboundRequests = function includesOutboundReques
|
|
|
744
744
|
* current path hash.
|
|
745
745
|
*/
|
|
746
746
|
Transaction.prototype.alternatePathHashes = function alternatePathHashes() {
|
|
747
|
-
|
|
747
|
+
const curHash = hashes.calculatePathHash(
|
|
748
748
|
this.agent.config.applications()[0],
|
|
749
749
|
this.getFullName(),
|
|
750
750
|
this.referringPathHash
|
|
751
751
|
)
|
|
752
|
-
|
|
753
|
-
|
|
752
|
+
const altHashes = this.pathHashes.slice()
|
|
753
|
+
const curIndex = altHashes.indexOf(curHash)
|
|
754
754
|
|
|
755
755
|
if (curIndex !== -1) {
|
|
756
756
|
altHashes.splice(curIndex, 1)
|
|
@@ -836,9 +836,9 @@ Transaction.prototype.hasIgnoredErrorStatusCode = function _hasIgnoredErrorStatu
|
|
|
836
836
|
* considered to be an error.
|
|
837
837
|
*/
|
|
838
838
|
Transaction.prototype.hasErrors = function _hasErrors() {
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
839
|
+
const isErroredTransaction = urltils.isError(this.agent.config, this.statusCode)
|
|
840
|
+
const transactionHasExceptions = this.exceptions.length > 0
|
|
841
|
+
const transactionHasuserErrors = this.userErrors.length > 0
|
|
842
842
|
return transactionHasExceptions || transactionHasuserErrors || isErroredTransaction
|
|
843
843
|
}
|
|
844
844
|
|
|
@@ -867,7 +867,7 @@ Transaction.prototype.hasOnlyExpectedErrors = function hasOnlyExpectedErrors() {
|
|
|
867
867
|
*/
|
|
868
868
|
Transaction.prototype.getIntrinsicAttributes = function getIntrinsicAttributes() {
|
|
869
869
|
if (!this._intrinsicAttributes.totalTime) {
|
|
870
|
-
|
|
870
|
+
const config = this.agent.config
|
|
871
871
|
this._intrinsicAttributes.totalTime = this.trace.getTotalTimeDurationInMillis() * FROM_MILLIS
|
|
872
872
|
|
|
873
873
|
if (config.distributed_tracing.enabled) {
|
|
@@ -1295,7 +1295,7 @@ Transaction.prototype.addRequestParameters = addRequestParameters
|
|
|
1295
1295
|
* @param {Object.<string, string>} requestParameters
|
|
1296
1296
|
*/
|
|
1297
1297
|
function addRequestParameters(requestParameters) {
|
|
1298
|
-
for (
|
|
1298
|
+
for (const key in requestParameters) {
|
|
1299
1299
|
if (props.hasOwn(requestParameters, key)) {
|
|
1300
1300
|
this.trace.attributes.addAttribute(
|
|
1301
1301
|
DESTS.NONE,
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
'use strict'
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
const logger = require('../logger.js').child({ component: 'name-state' })
|
|
9
|
+
const NAMES = require('../metrics/names')
|
|
10
10
|
|
|
11
11
|
// TODO: Figure out a way to phase out legacy transaction names.
|
|
12
|
-
|
|
12
|
+
const LEGACY_NAMING = {
|
|
13
13
|
Custom: true,
|
|
14
14
|
|
|
15
15
|
Connect: true,
|
|
@@ -107,7 +107,7 @@ NameState.prototype.isEmpty = function isEmpty() {
|
|
|
107
107
|
*/
|
|
108
108
|
NameState.prototype.appendPath = function appendPath(path, params) {
|
|
109
109
|
if (!this._frozen && path != null) {
|
|
110
|
-
|
|
110
|
+
const strPath = path instanceof RegExp ? path.source : String(path)
|
|
111
111
|
this.pathStack.push({ path: strPath, params: params || null })
|
|
112
112
|
|
|
113
113
|
if (path !== '') {
|
|
@@ -141,7 +141,7 @@ NameState.prototype.popPath = function popPath(path) {
|
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
this._pathCache = null
|
|
144
|
-
|
|
144
|
+
let pops = 0
|
|
145
145
|
if (path != null) {
|
|
146
146
|
const idx = _findLastIndex(this.pathStack, (a) => a.path === path)
|
|
147
147
|
if (idx !== -1) {
|
|
@@ -156,17 +156,17 @@ NameState.prototype.popPath = function popPath(path) {
|
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
NameState.prototype.getPath = function getPath() {
|
|
159
|
-
|
|
160
|
-
|
|
159
|
+
const ps = !this.pathStack.length ? this.markedPath : this.pathStack
|
|
160
|
+
const psLength = ps.length
|
|
161
161
|
if (this._pathCache) {
|
|
162
162
|
return this._pathCache
|
|
163
163
|
} else if (psLength === 0) {
|
|
164
164
|
return null // nameState initialized but never set
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
-
|
|
168
|
-
for (
|
|
169
|
-
|
|
167
|
+
let path = '/'
|
|
168
|
+
for (let i = 0; i < psLength; ++i) {
|
|
169
|
+
let a = ps[i].path
|
|
170
170
|
if (a && a !== '/') {
|
|
171
171
|
if (a[0] !== '/' && path[path.length - 1] !== '/') {
|
|
172
172
|
path += '/'
|
|
@@ -181,7 +181,7 @@ NameState.prototype.getPath = function getPath() {
|
|
|
181
181
|
}
|
|
182
182
|
|
|
183
183
|
NameState.prototype.getNameNotFound = function getNameNotFound() {
|
|
184
|
-
|
|
184
|
+
const name = _getName(this, '(not found)')
|
|
185
185
|
if (LEGACY_NAMING.hasOwnProperty(this.prefix)) {
|
|
186
186
|
return name
|
|
187
187
|
}
|
|
@@ -189,7 +189,7 @@ NameState.prototype.getNameNotFound = function getNameNotFound() {
|
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
NameState.prototype.getName = function getName() {
|
|
192
|
-
|
|
192
|
+
const path = this.getPath()
|
|
193
193
|
if (path === null) {
|
|
194
194
|
return null
|
|
195
195
|
}
|
|
@@ -198,7 +198,7 @@ NameState.prototype.getName = function getName() {
|
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
NameState.prototype.getFullName = function getFullName() {
|
|
201
|
-
|
|
201
|
+
const name = this.getName()
|
|
202
202
|
if (LEGACY_NAMING.hasOwnProperty(this.prefix)) {
|
|
203
203
|
return name
|
|
204
204
|
}
|
|
@@ -234,7 +234,7 @@ NameState.prototype.reset = function reset() {
|
|
|
234
234
|
}
|
|
235
235
|
|
|
236
236
|
function _getName(nameState, path) {
|
|
237
|
-
|
|
237
|
+
const verb = nameState.verb ? '/' + nameState.verb : ''
|
|
238
238
|
return (nameState.prefix || '') + verb + (nameState.delimiter || '') + path
|
|
239
239
|
}
|
|
240
240
|
|
|
@@ -36,7 +36,7 @@ class ExclusiveCalculator {
|
|
|
36
36
|
segment: segment,
|
|
37
37
|
childPairs: []
|
|
38
38
|
})
|
|
39
|
-
for (
|
|
39
|
+
for (let i = children.length - 1; i >= 0; --i) {
|
|
40
40
|
this.toProcess.push(children[i])
|
|
41
41
|
}
|
|
42
42
|
}
|
|
@@ -103,17 +103,17 @@ function merge(first, second) {
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
const res = []
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
let resIdx = 0
|
|
107
|
+
let firstIdx = 0
|
|
108
|
+
let secondIdx = 0
|
|
109
109
|
// N.B. this is destructive, it will be updating the end times for range arrays in
|
|
110
110
|
// the input arrays. If we need to reuse these arrays for anything, this behavior
|
|
111
111
|
// must be changed.
|
|
112
|
-
|
|
112
|
+
let currInterval =
|
|
113
113
|
first[firstIdx][0] < second[secondIdx][0] ? first[firstIdx++] : second[secondIdx++]
|
|
114
114
|
|
|
115
115
|
while (firstIdx < first.length && secondIdx < second.length) {
|
|
116
|
-
|
|
116
|
+
const next = first[firstIdx][0] < second[secondIdx][0] ? first[firstIdx++] : second[secondIdx++]
|
|
117
117
|
if (next[0] <= currInterval[1]) {
|
|
118
118
|
// if the segment overlaps, update the end of the current merged segment
|
|
119
119
|
currInterval[1] = Math.max(next[1], currInterval[1])
|
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
|
|
6
6
|
'use strict'
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
const codec = require('../../util/codec')
|
|
9
|
+
const Segment = require('./segment')
|
|
10
|
+
const { Attributes, MAXIMUM_CUSTOM_ATTRIBUTES } = require('../../attributes')
|
|
11
|
+
const logger = require('../../logger').child({ component: 'trace' })
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
const { DESTINATIONS } = require('../../config/attribute-filter')
|
|
14
|
+
const FROM_MILLIS = 1e-3
|
|
15
15
|
const ATTRIBUTE_SCOPE = 'transaction'
|
|
16
16
|
|
|
17
17
|
const REQUEST_URI_KEY = 'request.uri'
|
|
@@ -41,8 +41,8 @@ function Trace(transaction) {
|
|
|
41
41
|
this.attributes = new Attributes(ATTRIBUTE_SCOPE)
|
|
42
42
|
|
|
43
43
|
// sending displayName if set by user
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
const displayName = transaction.agent.config.getDisplayHost()
|
|
45
|
+
const hostName = transaction.agent.config.getHostnameSafe()
|
|
46
46
|
if (displayName !== hostName) {
|
|
47
47
|
this.attributes.addAttribute(DESTINATIONS.TRANS_COMMON, 'host.displayName', displayName)
|
|
48
48
|
|
|
@@ -82,7 +82,7 @@ Trace.prototype.generateSpanEvents = function generateSpanEvents() {
|
|
|
82
82
|
config.span_events.enabled &&
|
|
83
83
|
config.distributed_tracing.enabled
|
|
84
84
|
) {
|
|
85
|
-
|
|
85
|
+
const toProcess = []
|
|
86
86
|
|
|
87
87
|
// Root segment does not become a span, so we need to process it separately.
|
|
88
88
|
const spanAggregator = this.transaction.agent.spanEventAggregator
|
|
@@ -113,8 +113,8 @@ Trace.prototype.generateSpanEvents = function generateSpanEvents() {
|
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
while (toProcess.length) {
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
const segmentInfo = toProcess.pop()
|
|
117
|
+
const segment = segmentInfo.segment
|
|
118
118
|
|
|
119
119
|
// Even though at some point we might want to stop adding events because all the priorities
|
|
120
120
|
// should be the same, we need to count the spans as seen.
|
|
@@ -209,11 +209,11 @@ Trace.prototype.getTotalTimeDurationInMillis = function getTotalTimeDurationInMi
|
|
|
209
209
|
if (this.root.children.length === 0) {
|
|
210
210
|
return 0
|
|
211
211
|
}
|
|
212
|
-
|
|
213
|
-
|
|
212
|
+
let segments = this.root.getChildren()
|
|
213
|
+
let totalTimeInMillis = 0
|
|
214
214
|
|
|
215
215
|
while (segments.length !== 0) {
|
|
216
|
-
|
|
216
|
+
const segment = segments.pop()
|
|
217
217
|
totalTimeInMillis += segment.getExclusiveDurationInMillis()
|
|
218
218
|
segments = segments.concat(segment.getChildren())
|
|
219
219
|
}
|