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
|
@@ -5,27 +5,27 @@
|
|
|
5
5
|
|
|
6
6
|
'use strict'
|
|
7
7
|
|
|
8
|
-
const logger = require('../logger').child({component: 'transactionHandle'})
|
|
8
|
+
const logger = require('../logger').child({ component: 'transactionHandle' })
|
|
9
9
|
|
|
10
10
|
const NAMES = require('../../lib/metrics/names')
|
|
11
11
|
|
|
12
12
|
class TransactionHandle {
|
|
13
13
|
/**
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
* A light representation of a transaction instance, returned by calling
|
|
15
|
+
* {@link API#getTransaction}.
|
|
16
|
+
*
|
|
17
|
+
* @constructor
|
|
18
|
+
*/
|
|
19
19
|
constructor(transaction, metrics) {
|
|
20
20
|
this._transaction = transaction
|
|
21
21
|
this._metrics = metrics
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
* End the transaction.
|
|
26
|
+
*
|
|
27
|
+
* @param {Function} callback
|
|
28
|
+
*/
|
|
29
29
|
end(callback) {
|
|
30
30
|
const tx = this._transaction.end()
|
|
31
31
|
if (typeof callback === 'function') {
|
|
@@ -37,15 +37,15 @@ class TransactionHandle {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
* Mark the transaction to be ignored.
|
|
41
|
+
*/
|
|
42
42
|
ignore() {
|
|
43
43
|
this._transaction.setForceIgnore(true)
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
* Return whether this Transaction is being sampled
|
|
48
|
+
*/
|
|
49
49
|
isSampled() {
|
|
50
50
|
return this._transaction.isSampled()
|
|
51
51
|
}
|
|
@@ -95,22 +95,22 @@ module.exports.Stub = class TransactionHandleStub {
|
|
|
95
95
|
if (callback instanceof Function) {
|
|
96
96
|
setImmediate(callback)
|
|
97
97
|
}
|
|
98
|
-
logger.debug(
|
|
98
|
+
logger.debug('No transaction found when calling Transaction.end')
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
ignore() {
|
|
102
|
-
logger.debug(
|
|
102
|
+
logger.debug('No transaction found when calling Transaction.ignore')
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
isSampled() {
|
|
106
|
-
logger.debug(
|
|
106
|
+
logger.debug('No transaction found when calling Transaction.isSampled')
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
acceptDistributedTraceHeaders() {
|
|
110
|
-
logger.debug(
|
|
110
|
+
logger.debug('No transaction found when calling Transaction.acceptDistributedTraceHeaders')
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
insertDistributedTraceHeaders() {
|
|
114
|
-
logger.debug(
|
|
114
|
+
logger.debug('No transaction found when calling Transaction.insertDistributedTraceHeaders')
|
|
115
115
|
}
|
|
116
116
|
}
|
package/lib/transaction/index.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
const errorHelper = require('../errors/helper')
|
|
9
9
|
var hashes = require('../util/hashes')
|
|
10
|
-
var logger = require('../logger').child({component: 'transaction'})
|
|
10
|
+
var logger = require('../logger').child({ component: 'transaction' })
|
|
11
11
|
var Metrics = require('../metrics')
|
|
12
12
|
var NAMES = require('../metrics/names')
|
|
13
13
|
var NameState = require('./name-state')
|
|
@@ -58,7 +58,7 @@ const NEWRELIC_TRACE_HEADER = 'newrelic'
|
|
|
58
58
|
|
|
59
59
|
const MULTIPLE_INSERT_MESSAGE =
|
|
60
60
|
'insertDistributedTraceHeaders called on headers object that already contains ' +
|
|
61
|
-
|
|
61
|
+
"distributed trace data. These may be overwritten. traceparent? '%s', newrelic? '%s'."
|
|
62
62
|
|
|
63
63
|
/**
|
|
64
64
|
* Bundle together the metrics and the trace segment for a single agent
|
|
@@ -67,7 +67,9 @@ const MULTIPLE_INSERT_MESSAGE =
|
|
|
67
67
|
* @param {Object} agent The agent.
|
|
68
68
|
*/
|
|
69
69
|
function Transaction(agent) {
|
|
70
|
-
if (!agent)
|
|
70
|
+
if (!agent) {
|
|
71
|
+
throw new Error('every transaction must be bound to the agent')
|
|
72
|
+
}
|
|
71
73
|
|
|
72
74
|
this.traceFlag = false
|
|
73
75
|
if (agent.config.logging.diagnostics) {
|
|
@@ -77,11 +79,7 @@ function Transaction(agent) {
|
|
|
77
79
|
}
|
|
78
80
|
|
|
79
81
|
this.agent = agent
|
|
80
|
-
this.metrics = new Metrics(
|
|
81
|
-
agent.config.apdex_t,
|
|
82
|
-
agent.mapper,
|
|
83
|
-
agent.metricNameNormalizer
|
|
84
|
-
)
|
|
82
|
+
this.metrics = new Metrics(agent.config.apdex_t, agent.mapper, agent.metricNameNormalizer)
|
|
85
83
|
|
|
86
84
|
++agent.activeTransactions
|
|
87
85
|
|
|
@@ -132,7 +130,7 @@ function Transaction(agent) {
|
|
|
132
130
|
this.parentTransportType = null
|
|
133
131
|
this.parentTransportDuration = null
|
|
134
132
|
this._traceId = null
|
|
135
|
-
Object.defineProperty(this,
|
|
133
|
+
Object.defineProperty(this, 'traceId', {
|
|
136
134
|
get() {
|
|
137
135
|
if (this._traceId === null) {
|
|
138
136
|
this._traceId = hashes.makeId(32)
|
|
@@ -153,7 +151,7 @@ function Transaction(agent) {
|
|
|
153
151
|
this.traceContext = new TraceContext(this)
|
|
154
152
|
|
|
155
153
|
agent.emit('transactionStarted', this)
|
|
156
|
-
this.probe('Transaction created', {id: this.id})
|
|
154
|
+
this.probe('Transaction created', { id: this.id })
|
|
157
155
|
}
|
|
158
156
|
|
|
159
157
|
Transaction.TYPES = TYPES
|
|
@@ -165,7 +163,7 @@ Transaction.TRACE_CONTEXT_PARENT_HEADER = TRACE_CONTEXT_PARENT_HEADER
|
|
|
165
163
|
Transaction.prototype.probe = function probe(action, extra) {
|
|
166
164
|
if (this.traceStacks) {
|
|
167
165
|
this.traceStacks.push({
|
|
168
|
-
stack:
|
|
166
|
+
stack: new Error(action).stack.split('\n'),
|
|
169
167
|
extra: extra
|
|
170
168
|
})
|
|
171
169
|
}
|
|
@@ -193,10 +191,12 @@ Transaction.prototype.isActive = function isActive() {
|
|
|
193
191
|
* instances of this transaction annotated onto the call stack.
|
|
194
192
|
*/
|
|
195
193
|
Transaction.prototype.end = function end() {
|
|
196
|
-
if (!this.timer.isActive())
|
|
194
|
+
if (!this.timer.isActive()) {
|
|
195
|
+
return
|
|
196
|
+
}
|
|
197
197
|
if (this.traceFlag) {
|
|
198
198
|
logger.warn(
|
|
199
|
-
{segment: {name: this.name, stacks: this.traceStacks}},
|
|
199
|
+
{ segment: { name: this.name, stacks: this.traceStacks } },
|
|
200
200
|
'Flagged transaction ended.'
|
|
201
201
|
)
|
|
202
202
|
}
|
|
@@ -380,7 +380,7 @@ Transaction.prototype.setForceIgnore = function setForceIgnore(ignore) {
|
|
|
380
380
|
if (ignore != null) {
|
|
381
381
|
this.forceIgnore = ignore
|
|
382
382
|
} else {
|
|
383
|
-
logger.debug(
|
|
383
|
+
logger.debug('Transaction#setForceIgnore called with null value')
|
|
384
384
|
}
|
|
385
385
|
}
|
|
386
386
|
|
|
@@ -406,8 +406,15 @@ Transaction.prototype.isIgnored = function getIgnore() {
|
|
|
406
406
|
Transaction.prototype.finalizeNameFromUri = finalizeNameFromUri
|
|
407
407
|
function finalizeNameFromUri(requestURL, statusCode) {
|
|
408
408
|
if (logger.traceEnabled()) {
|
|
409
|
-
logger.trace(
|
|
410
|
-
|
|
409
|
+
logger.trace(
|
|
410
|
+
{
|
|
411
|
+
requestURL: requestURL,
|
|
412
|
+
statusCode: statusCode,
|
|
413
|
+
transactionId: this.id,
|
|
414
|
+
transactionName: this.name
|
|
415
|
+
},
|
|
416
|
+
'Setting transaction name'
|
|
417
|
+
)
|
|
411
418
|
}
|
|
412
419
|
|
|
413
420
|
this.url = urltils.scrub(requestURL)
|
|
@@ -425,24 +432,17 @@ function finalizeNameFromUri(requestURL, statusCode) {
|
|
|
425
432
|
this.nameState.forEachParams(function forEachRouteParams(params) {
|
|
426
433
|
for (var key in params) {
|
|
427
434
|
if (props.hasOwn(params, key)) {
|
|
428
|
-
this.trace.attributes.addAttribute(
|
|
429
|
-
DESTS.NONE,
|
|
430
|
-
'request.parameters.' + key,
|
|
431
|
-
params[key]
|
|
432
|
-
)
|
|
435
|
+
this.trace.attributes.addAttribute(DESTS.NONE, 'request.parameters.' + key, params[key])
|
|
433
436
|
|
|
434
437
|
const segment = this.agent.tracer.getSegment()
|
|
435
438
|
|
|
436
439
|
if (!segment) {
|
|
437
|
-
logger
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
} else {
|
|
441
|
-
segment.attributes.addAttribute(
|
|
442
|
-
DESTS.NONE,
|
|
443
|
-
'request.parameters.' + key,
|
|
444
|
-
params[key]
|
|
440
|
+
logger.trace(
|
|
441
|
+
'Active segment not available, not adding request.parameters attribute for %s',
|
|
442
|
+
key
|
|
445
443
|
)
|
|
444
|
+
} else {
|
|
445
|
+
segment.attributes.addAttribute(DESTS.NONE, 'request.parameters.' + key, params[key])
|
|
446
446
|
}
|
|
447
447
|
}
|
|
448
448
|
}
|
|
@@ -470,11 +470,14 @@ function finalizeNameFromUri(requestURL, statusCode) {
|
|
|
470
470
|
this._copyNameToActiveSpan(this.name)
|
|
471
471
|
|
|
472
472
|
if (logger.traceEnabled()) {
|
|
473
|
-
logger.trace(
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
473
|
+
logger.trace(
|
|
474
|
+
{
|
|
475
|
+
transactionId: this.id,
|
|
476
|
+
transactionName: this.name,
|
|
477
|
+
ignore: this.ignore
|
|
478
|
+
},
|
|
479
|
+
'Finished setting transaction name from Uri'
|
|
480
|
+
)
|
|
478
481
|
}
|
|
479
482
|
}
|
|
480
483
|
|
|
@@ -499,25 +502,17 @@ Transaction.prototype._markAsWeb = function _markAsWeb(rawURL) {
|
|
|
499
502
|
var params = urltils.parseParameters(rawURL)
|
|
500
503
|
for (var key in params) {
|
|
501
504
|
if (props.hasOwn(params, key)) {
|
|
502
|
-
this.trace.attributes.addAttribute(
|
|
503
|
-
DESTS.NONE,
|
|
504
|
-
'request.parameters.' + key,
|
|
505
|
-
params[key]
|
|
506
|
-
)
|
|
505
|
+
this.trace.attributes.addAttribute(DESTS.NONE, 'request.parameters.' + key, params[key])
|
|
507
506
|
|
|
508
507
|
const segment = this.agent.tracer.getSegment()
|
|
509
508
|
|
|
510
509
|
if (!segment) {
|
|
511
|
-
logger
|
|
512
|
-
.
|
|
513
|
-
|
|
514
|
-
key)
|
|
515
|
-
} else {
|
|
516
|
-
segment.attributes.addAttribute(
|
|
517
|
-
DESTS.NONE,
|
|
518
|
-
'request.parameters.' + key,
|
|
519
|
-
params[key]
|
|
510
|
+
logger.trace(
|
|
511
|
+
'Active segment not available, not adding request.parameters span attribute for %s',
|
|
512
|
+
key
|
|
520
513
|
)
|
|
514
|
+
} else {
|
|
515
|
+
segment.attributes.addAttribute(DESTS.NONE, 'request.parameters.' + key, params[key])
|
|
521
516
|
}
|
|
522
517
|
}
|
|
523
518
|
}
|
|
@@ -563,11 +558,14 @@ Transaction.prototype.finalizeName = function finalizeName(name) {
|
|
|
563
558
|
this._copyNameToActiveSpan(this.name)
|
|
564
559
|
|
|
565
560
|
if (logger.traceEnabled()) {
|
|
566
|
-
logger.trace(
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
561
|
+
logger.trace(
|
|
562
|
+
{
|
|
563
|
+
transactionId: this.id,
|
|
564
|
+
transactionName: this.name,
|
|
565
|
+
ignore: this.ignore
|
|
566
|
+
},
|
|
567
|
+
'Finished setting transaction name from string'
|
|
568
|
+
)
|
|
571
569
|
}
|
|
572
570
|
}
|
|
573
571
|
|
|
@@ -618,8 +616,12 @@ Transaction.prototype.getFullName = function getFullName() {
|
|
|
618
616
|
* Returns a string or undefined.
|
|
619
617
|
*/
|
|
620
618
|
Transaction.prototype.getScrubbedUrl = function getScrubbedUrl() {
|
|
621
|
-
if (!this.isWeb())
|
|
622
|
-
|
|
619
|
+
if (!this.isWeb()) {
|
|
620
|
+
return
|
|
621
|
+
}
|
|
622
|
+
if (this._scrubbedUrl) {
|
|
623
|
+
return this._scrubbedUrl
|
|
624
|
+
}
|
|
623
625
|
|
|
624
626
|
// If we don't have a parsedUrl, lets populate it from .url
|
|
625
627
|
if (!this.parsedUrl) {
|
|
@@ -627,7 +629,9 @@ Transaction.prototype.getScrubbedUrl = function getScrubbedUrl() {
|
|
|
627
629
|
// because that is what .isWeb() checks against. In the future it may be
|
|
628
630
|
// instead checking a enum or other property so guard ourselves just in
|
|
629
631
|
// case.
|
|
630
|
-
if (!this.url)
|
|
632
|
+
if (!this.url) {
|
|
633
|
+
return
|
|
634
|
+
}
|
|
631
635
|
this.parsedUrl = url.parse(this.url)
|
|
632
636
|
}
|
|
633
637
|
|
|
@@ -722,7 +726,9 @@ Transaction.prototype._setApdex = function _setApdex(name, duration, keyApdexInM
|
|
|
722
726
|
* @param {string} pathHash Path hash
|
|
723
727
|
*/
|
|
724
728
|
Transaction.prototype.pushPathHash = function pushPathHash(pathHash) {
|
|
725
|
-
if (this.pathHashes.length >= 10 || this.pathHashes.indexOf(pathHash) !== -1)
|
|
729
|
+
if (this.pathHashes.length >= 10 || this.pathHashes.indexOf(pathHash) !== -1) {
|
|
730
|
+
return
|
|
731
|
+
}
|
|
726
732
|
this.pathHashes.unshift(pathHash)
|
|
727
733
|
}
|
|
728
734
|
|
|
@@ -746,7 +752,9 @@ Transaction.prototype.alternatePathHashes = function alternatePathHashes() {
|
|
|
746
752
|
var altHashes = this.pathHashes.slice()
|
|
747
753
|
var curIndex = altHashes.indexOf(curHash)
|
|
748
754
|
|
|
749
|
-
if (curIndex !== -1)
|
|
755
|
+
if (curIndex !== -1) {
|
|
756
|
+
altHashes.splice(curIndex, 1)
|
|
757
|
+
}
|
|
750
758
|
|
|
751
759
|
return altHashes.length === 0 ? null : altHashes.sort().join(',')
|
|
752
760
|
}
|
|
@@ -831,7 +839,7 @@ Transaction.prototype.hasErrors = function _hasErrors() {
|
|
|
831
839
|
var isErroredTransaction = urltils.isError(this.agent.config, this.statusCode)
|
|
832
840
|
var transactionHasExceptions = this.exceptions.length > 0
|
|
833
841
|
var transactionHasuserErrors = this.userErrors.length > 0
|
|
834
|
-
return
|
|
842
|
+
return transactionHasExceptions || transactionHasuserErrors || isErroredTransaction
|
|
835
843
|
}
|
|
836
844
|
|
|
837
845
|
// Returns true if all the errors/exceptions collected so far are expected errors
|
|
@@ -840,21 +848,12 @@ Transaction.prototype.hasOnlyExpectedErrors = function hasOnlyExpectedErrors() {
|
|
|
840
848
|
return false
|
|
841
849
|
}
|
|
842
850
|
|
|
843
|
-
for (let i = 0;i < this.exceptions.length;i++) {
|
|
851
|
+
for (let i = 0; i < this.exceptions.length; i++) {
|
|
844
852
|
const exception = this.exceptions[i]
|
|
845
853
|
// this exception is neither expected nor ignored
|
|
846
854
|
const isUnexpected = !(
|
|
847
|
-
errorHelper.isExpectedException(
|
|
848
|
-
|
|
849
|
-
exception.error,
|
|
850
|
-
this.agent.config,
|
|
851
|
-
urltils
|
|
852
|
-
) ||
|
|
853
|
-
errorHelper.shouldIgnoreError(
|
|
854
|
-
this,
|
|
855
|
-
exception.error,
|
|
856
|
-
this.agent.config
|
|
857
|
-
)
|
|
855
|
+
errorHelper.isExpectedException(this, exception.error, this.agent.config, urltils) ||
|
|
856
|
+
errorHelper.shouldIgnoreError(this, exception.error, this.agent.config)
|
|
858
857
|
)
|
|
859
858
|
if (isUnexpected) {
|
|
860
859
|
return false
|
|
@@ -869,8 +868,7 @@ Transaction.prototype.hasOnlyExpectedErrors = function hasOnlyExpectedErrors() {
|
|
|
869
868
|
Transaction.prototype.getIntrinsicAttributes = function getIntrinsicAttributes() {
|
|
870
869
|
if (!this._intrinsicAttributes.totalTime) {
|
|
871
870
|
var config = this.agent.config
|
|
872
|
-
this._intrinsicAttributes.totalTime =
|
|
873
|
-
this.trace.getTotalTimeDurationInMillis() * FROM_MILLIS
|
|
871
|
+
this._intrinsicAttributes.totalTime = this.trace.getTotalTimeDurationInMillis() * FROM_MILLIS
|
|
874
872
|
|
|
875
873
|
if (config.distributed_tracing.enabled) {
|
|
876
874
|
this.addDistributedTraceIntrinsics(this._intrinsicAttributes)
|
|
@@ -882,8 +880,7 @@ Transaction.prototype.getIntrinsicAttributes = function getIntrinsicAttributes()
|
|
|
882
880
|
)
|
|
883
881
|
this._intrinsicAttributes.trip_id = this.tripId || this.id
|
|
884
882
|
if (this.referringTransactionGuid) {
|
|
885
|
-
this._intrinsicAttributes.referring_transaction_guid =
|
|
886
|
-
this.referringTransactionGuid
|
|
883
|
+
this._intrinsicAttributes.referring_transaction_guid = this.referringTransactionGuid
|
|
887
884
|
}
|
|
888
885
|
if (this.incomingCatId) {
|
|
889
886
|
this._intrinsicAttributes.client_cross_process_id = this.incomingCatId
|
|
@@ -911,7 +908,8 @@ function acceptDistributedTraceHeaders(transportType, headers) {
|
|
|
911
908
|
if (headers == null || typeof headers !== 'object') {
|
|
912
909
|
logger.trace(
|
|
913
910
|
'Ignoring distributed trace headers for transaction %s. Headers not passed in as object.',
|
|
914
|
-
this.id
|
|
911
|
+
this.id
|
|
912
|
+
)
|
|
915
913
|
return
|
|
916
914
|
}
|
|
917
915
|
|
|
@@ -995,8 +993,7 @@ function acceptTraceContextPayload(traceparent, tracestate, transport) {
|
|
|
995
993
|
return
|
|
996
994
|
}
|
|
997
995
|
|
|
998
|
-
const traceContext =
|
|
999
|
-
this.traceContext.acceptTraceContextPayload(traceparent, tracestate)
|
|
996
|
+
const traceContext = this.traceContext.acceptTraceContextPayload(traceparent, tracestate)
|
|
1000
997
|
|
|
1001
998
|
if (traceContext.acceptedTraceparent) {
|
|
1002
999
|
this.acceptedDistributedTrace = true
|
|
@@ -1039,9 +1036,7 @@ function _acceptDistributedTracePayload(payload, transport) {
|
|
|
1039
1036
|
if (this.parentId) {
|
|
1040
1037
|
this.agent.recordSupportability('DistributedTrace/AcceptPayload/Ignored/Multiple')
|
|
1041
1038
|
} else {
|
|
1042
|
-
this.agent.recordSupportability(
|
|
1043
|
-
'DistributedTrace/AcceptPayload/Ignored/CreateBeforeAccept'
|
|
1044
|
-
)
|
|
1039
|
+
this.agent.recordSupportability('DistributedTrace/AcceptPayload/Ignored/CreateBeforeAccept')
|
|
1045
1040
|
}
|
|
1046
1041
|
return
|
|
1047
1042
|
}
|
|
@@ -1053,7 +1048,7 @@ function _acceptDistributedTracePayload(payload, transport) {
|
|
|
1053
1048
|
if (!distTraceEnabled || !trustedAccount) {
|
|
1054
1049
|
logger.debug(
|
|
1055
1050
|
'Invalid configuration for distributed trace payload, not accepting ' +
|
|
1056
|
-
|
|
1051
|
+
'(distributed_tracing.enabled: %s, trustKey: %s',
|
|
1057
1052
|
distTraceEnabled,
|
|
1058
1053
|
trustedAccount
|
|
1059
1054
|
)
|
|
@@ -1070,16 +1065,10 @@ function _acceptDistributedTracePayload(payload, transport) {
|
|
|
1070
1065
|
|
|
1071
1066
|
if (!parsed.v || !parsed.d) {
|
|
1072
1067
|
if (!parsed.v) {
|
|
1073
|
-
logger.warn(
|
|
1074
|
-
'Received a distributed trace payload with no version field',
|
|
1075
|
-
this.id
|
|
1076
|
-
)
|
|
1068
|
+
logger.warn('Received a distributed trace payload with no version field', this.id)
|
|
1077
1069
|
}
|
|
1078
1070
|
if (!parsed.d) {
|
|
1079
|
-
logger.warn(
|
|
1080
|
-
'Received a distributed trace payload with no data field',
|
|
1081
|
-
this.id
|
|
1082
|
-
)
|
|
1071
|
+
logger.warn('Received a distributed trace payload with no data field', this.id)
|
|
1083
1072
|
}
|
|
1084
1073
|
this.agent.recordSupportability('DistributedTrace/AcceptPayload/ParseException')
|
|
1085
1074
|
return
|
|
@@ -1090,7 +1079,8 @@ function _acceptDistributedTracePayload(payload, transport) {
|
|
|
1090
1079
|
logger.warn('Invalid distributed trace payload, not accepting')
|
|
1091
1080
|
this.agent.recordSupportability('DistributedTrace/AcceptPayload/Exception')
|
|
1092
1081
|
}
|
|
1093
|
-
if (majorVersion > 0) {
|
|
1082
|
+
if (majorVersion > 0) {
|
|
1083
|
+
// TODO: Add DistributedTracePayload class?
|
|
1094
1084
|
this.agent.recordSupportability('DistributedTrace/AcceptPayload/Ignored/MajorVersion')
|
|
1095
1085
|
return
|
|
1096
1086
|
}
|
|
@@ -1107,16 +1097,14 @@ function _acceptDistributedTracePayload(payload, transport) {
|
|
|
1107
1097
|
return data[key] != null
|
|
1108
1098
|
})
|
|
1109
1099
|
// Either parentSpanId or parentId are required.
|
|
1110
|
-
if (!requiredKeysExist || data.tx == null && data.id == null) {
|
|
1100
|
+
if (!requiredKeysExist || (data.tx == null && data.id == null)) {
|
|
1111
1101
|
this.agent.recordSupportability('DistributedTrace/AcceptPayload/ParseException')
|
|
1112
1102
|
return
|
|
1113
1103
|
}
|
|
1114
1104
|
|
|
1115
1105
|
const trustedAccountKey = data.tk || data.ac
|
|
1116
1106
|
if (trustedAccountKey !== trustedAccount) {
|
|
1117
|
-
this.agent.recordSupportability(
|
|
1118
|
-
`DistributedTrace/AcceptPayload/Ignored/UntrustedAccount`
|
|
1119
|
-
)
|
|
1107
|
+
this.agent.recordSupportability(`DistributedTrace/AcceptPayload/Ignored/UntrustedAccount`)
|
|
1120
1108
|
return
|
|
1121
1109
|
}
|
|
1122
1110
|
|
|
@@ -1161,11 +1149,7 @@ Transaction.prototype._getParsedPayload = function _getParsedPayload(payload) {
|
|
|
1161
1149
|
try {
|
|
1162
1150
|
payload = Buffer.from(payload, 'base64').toString('utf-8')
|
|
1163
1151
|
} catch (err) {
|
|
1164
|
-
logger.warn(
|
|
1165
|
-
err,
|
|
1166
|
-
'Got unparseable distributed trace payload in transaction %s',
|
|
1167
|
-
this.id
|
|
1168
|
-
)
|
|
1152
|
+
logger.warn(err, 'Got unparseable distributed trace payload in transaction %s', this.id)
|
|
1169
1153
|
this.agent.recordSupportability('DistributedTrace/AcceptPayload/ParseException')
|
|
1170
1154
|
return null
|
|
1171
1155
|
}
|
|
@@ -1173,11 +1157,7 @@ Transaction.prototype._getParsedPayload = function _getParsedPayload(payload) {
|
|
|
1173
1157
|
try {
|
|
1174
1158
|
parsed = JSON.parse(payload)
|
|
1175
1159
|
} catch (err) {
|
|
1176
|
-
logger.warn(
|
|
1177
|
-
err,
|
|
1178
|
-
'Failed to parse distributed trace payload in transaction %s',
|
|
1179
|
-
this.id
|
|
1180
|
-
)
|
|
1160
|
+
logger.warn(err, 'Failed to parse distributed trace payload in transaction %s', this.id)
|
|
1181
1161
|
this.agent.recordSupportability('DistributedTrace/AcceptPayload/ParseException')
|
|
1182
1162
|
return null
|
|
1183
1163
|
}
|
|
@@ -1200,8 +1180,8 @@ function _createDistributedTracePayload() {
|
|
|
1200
1180
|
if (!accountId || !appId || !distTraceEnabled) {
|
|
1201
1181
|
logger.debug(
|
|
1202
1182
|
'Invalid configuration for distributed trace payload ' +
|
|
1203
|
-
|
|
1204
|
-
|
|
1183
|
+
'(distributed_tracing.enabled: %s, account_id: %s, application_id: %s) ' +
|
|
1184
|
+
'in transaction %s',
|
|
1205
1185
|
distTraceEnabled,
|
|
1206
1186
|
accountId,
|
|
1207
1187
|
appId,
|
|
@@ -1293,15 +1273,17 @@ Transaction.prototype._calculatePriority = function _calculatePriority() {
|
|
|
1293
1273
|
|
|
1294
1274
|
// Truncate the priority after potentially modifying it to avoid floating
|
|
1295
1275
|
// point errors.
|
|
1296
|
-
this.priority = (this.priority * 1e6 | 0) / 1e6
|
|
1276
|
+
this.priority = ((this.priority * 1e6) | 0) / 1e6
|
|
1297
1277
|
}
|
|
1298
1278
|
}
|
|
1299
1279
|
|
|
1300
1280
|
function _makeValueSet(obj) {
|
|
1301
|
-
return Object.keys(obj)
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1281
|
+
return Object.keys(obj)
|
|
1282
|
+
.map((t) => obj[t])
|
|
1283
|
+
.reduce(function reduceToMap(o, t) {
|
|
1284
|
+
o[t] = true
|
|
1285
|
+
return o
|
|
1286
|
+
}, Object.create(null))
|
|
1305
1287
|
}
|
|
1306
1288
|
|
|
1307
1289
|
Transaction.prototype.addRequestParameters = addRequestParameters
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
'use strict'
|
|
7
7
|
|
|
8
|
-
var logger = require('../logger.js').child({component: 'name-state'})
|
|
8
|
+
var logger = require('../logger.js').child({ component: 'name-state' })
|
|
9
9
|
var NAMES = require('../metrics/names')
|
|
10
10
|
|
|
11
11
|
// TODO: Figure out a way to phase out legacy transaction names.
|
|
@@ -45,7 +45,7 @@ NameState.prototype.setName = function setName(prefix, verb, delimiter, path) {
|
|
|
45
45
|
this.setPrefix(prefix)
|
|
46
46
|
this.verb = verb && verb.toUpperCase()
|
|
47
47
|
this.delimiter = delimiter
|
|
48
|
-
this.pathStack = path ? [{path: path, params: null}] : []
|
|
48
|
+
this.pathStack = path ? [{ path: path, params: null }] : []
|
|
49
49
|
this._pathCache = null
|
|
50
50
|
this.markedPath = []
|
|
51
51
|
logger.trace('setName called on name state, path stack now %j', this.pathStack)
|
|
@@ -77,8 +77,7 @@ NameState.prototype.setPrefix = function setPrefix(prefix) {
|
|
|
77
77
|
this.prefix = null
|
|
78
78
|
return
|
|
79
79
|
}
|
|
80
|
-
this.prefix =
|
|
81
|
-
prefix.substring(0, prefix.length - 1) : prefix
|
|
80
|
+
this.prefix = prefix[prefix.length - 1] === '/' ? prefix.substring(0, prefix.length - 1) : prefix
|
|
82
81
|
}
|
|
83
82
|
|
|
84
83
|
/**
|
|
@@ -109,7 +108,7 @@ NameState.prototype.isEmpty = function isEmpty() {
|
|
|
109
108
|
NameState.prototype.appendPath = function appendPath(path, params) {
|
|
110
109
|
if (!this._frozen && path != null) {
|
|
111
110
|
var strPath = path instanceof RegExp ? path.source : String(path)
|
|
112
|
-
this.pathStack.push({path: strPath, params: params || null})
|
|
111
|
+
this.pathStack.push({ path: strPath, params: params || null })
|
|
113
112
|
|
|
114
113
|
if (path !== '') {
|
|
115
114
|
this._pathCache = null
|
|
@@ -178,7 +177,7 @@ NameState.prototype.getPath = function getPath() {
|
|
|
178
177
|
}
|
|
179
178
|
}
|
|
180
179
|
|
|
181
|
-
return this._pathCache = path
|
|
180
|
+
return (this._pathCache = path)
|
|
182
181
|
}
|
|
183
182
|
|
|
184
183
|
NameState.prototype.getNameNotFound = function getNameNotFound() {
|