newrelic 9.0.0 → 9.0.3
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 +33 -0
- package/THIRD_PARTY_NOTICES.md +5998 -365
- package/lib/collector/api.js +1 -1
- package/lib/collector/facts.js +79 -79
- package/lib/collector/remote-method.js +3 -3
- package/lib/config/default.js +10 -0
- package/lib/config/env.js +1 -0
- package/lib/config/index.js +0 -1
- package/lib/db/query-trace-aggregator.js +20 -3
- package/lib/environment.js +152 -273
- package/lib/instrumentation/grpc-js/grpc.js +1 -3
- package/lib/metrics/names.js +2 -1
- package/lib/transaction/index.js +36 -33
- package/lib/transaction/trace/aggregator.js +19 -7
- package/lib/transaction/transaction-event-aggregator.js +18 -20
- package/lib/util/application-logging.js +14 -1
- package/lib/util/unwrapped-core.js +2 -0
- package/package.json +4 -11
package/lib/transaction/index.js
CHANGED
|
@@ -418,13 +418,7 @@ function finalizeNameFromUri(requestURL, statusCode) {
|
|
|
418
418
|
|
|
419
419
|
this.url = urltils.scrub(requestURL)
|
|
420
420
|
this.statusCode = statusCode
|
|
421
|
-
|
|
422
|
-
// Derive the name from the request URL.
|
|
423
|
-
const partialName = this._partialNameFromUri(requestURL, statusCode)
|
|
424
|
-
this._partialName = partialName.value
|
|
425
|
-
if (partialName.ignore) {
|
|
426
|
-
this.ignore = true
|
|
427
|
-
}
|
|
421
|
+
this.name = this.getFullName()
|
|
428
422
|
|
|
429
423
|
// If a namestate stack exists, copy route parameters over to the trace.
|
|
430
424
|
if (!this.nameState.isEmpty() && this.baseSegment) {
|
|
@@ -448,17 +442,6 @@ function finalizeNameFromUri(requestURL, statusCode) {
|
|
|
448
442
|
}, this)
|
|
449
443
|
}
|
|
450
444
|
|
|
451
|
-
// Apply transaction name normalization rules (sent by server) to full name.
|
|
452
|
-
const fullName = TYPE_METRICS[this.type] + '/' + this._partialName
|
|
453
|
-
const normalized = this.agent.transactionNameNormalizer.normalize(fullName)
|
|
454
|
-
if (normalized.ignore) {
|
|
455
|
-
this.ignore = true
|
|
456
|
-
}
|
|
457
|
-
this.name = normalized.value
|
|
458
|
-
|
|
459
|
-
// 5. transaction segment term normalizer
|
|
460
|
-
this.name = this.agent.txSegmentNormalizer.normalize(this.name).value
|
|
461
|
-
|
|
462
445
|
// Allow the API to explicitly set the ignored status.
|
|
463
446
|
if (this.forceIgnore !== null) {
|
|
464
447
|
this.ignore = this.forceIgnore
|
|
@@ -528,25 +511,22 @@ Transaction.prototype._markAsWeb = function _markAsWeb(rawURL) {
|
|
|
528
511
|
Transaction.prototype.finalizeName = function finalizeName(name) {
|
|
529
512
|
// If no name is given, and this is a web transaction with a url, then
|
|
530
513
|
// finalize the name using the stored url.
|
|
531
|
-
if (name == null && this.
|
|
514
|
+
if (name == null && this.isWeb() && this.url) {
|
|
532
515
|
return this.finalizeNameFromUri(this.url, this.statusCode)
|
|
533
516
|
}
|
|
534
517
|
|
|
535
|
-
this
|
|
536
|
-
|
|
518
|
+
// this may seem out of place but certain API methods
|
|
519
|
+
// set the _partialName directly so use that as a fallback
|
|
520
|
+
this._partialName = name || this._partialName
|
|
521
|
+
|
|
522
|
+
name = this.getFullName()
|
|
523
|
+
|
|
524
|
+
if (!name) {
|
|
537
525
|
logger.debug('No name for transaction %s, not finalizing.', this.id)
|
|
538
526
|
return
|
|
539
527
|
}
|
|
540
528
|
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
// Transaction normalizers run on the full metric name, not the user facing
|
|
544
|
-
// transaction name.
|
|
545
|
-
const normalized = this.agent.transactionNameNormalizer.normalize(fullName)
|
|
546
|
-
if (normalized.ignore) {
|
|
547
|
-
this.ignore = true
|
|
548
|
-
}
|
|
549
|
-
this.name = normalized.value
|
|
529
|
+
this.name = name
|
|
550
530
|
|
|
551
531
|
if (this.forceIgnore !== null) {
|
|
552
532
|
this.ignore = this.forceIgnore
|
|
@@ -582,17 +562,25 @@ Transaction.prototype.finalizeName = function finalizeName(name) {
|
|
|
582
562
|
*/
|
|
583
563
|
Transaction.prototype.getName = function getName() {
|
|
584
564
|
if (this.isWeb() && this.url) {
|
|
585
|
-
|
|
565
|
+
const finalName = this._partialNameFromUri(this.url, this.statusCode)
|
|
566
|
+
if (finalName.ignore) {
|
|
567
|
+
this.ignore = true
|
|
568
|
+
}
|
|
569
|
+
return finalName.value
|
|
586
570
|
}
|
|
587
571
|
return this._partialName
|
|
588
572
|
}
|
|
589
573
|
|
|
590
574
|
Transaction.prototype.getFullName = function getFullName() {
|
|
591
575
|
let name = null
|
|
576
|
+
// use value from `api.setTransaction`
|
|
592
577
|
if (this.forceName) {
|
|
593
578
|
name = this.forceName
|
|
579
|
+
// use value from previously finalized named
|
|
594
580
|
} else if (this.name) {
|
|
595
581
|
return this.name
|
|
582
|
+
// derive name from uri in web case
|
|
583
|
+
// or just use whatever was this._partialName
|
|
596
584
|
} else {
|
|
597
585
|
name = this.getName()
|
|
598
586
|
}
|
|
@@ -600,8 +588,23 @@ Transaction.prototype.getFullName = function getFullName() {
|
|
|
600
588
|
if (!name) {
|
|
601
589
|
return null
|
|
602
590
|
}
|
|
603
|
-
|
|
604
|
-
|
|
591
|
+
|
|
592
|
+
this._partialName = name
|
|
593
|
+
let fullName = TYPE_METRICS[this.type] + '/' + name
|
|
594
|
+
const normalized = this.agent.transactionNameNormalizer.normalize(fullName)
|
|
595
|
+
if (normalized.ignore) {
|
|
596
|
+
this.ignore = true
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
fullName = normalized.value
|
|
600
|
+
|
|
601
|
+
// apply transaction segment term normalizer
|
|
602
|
+
// only to web transactions
|
|
603
|
+
if (this.isWeb() && this.url) {
|
|
604
|
+
fullName = this.agent.txSegmentNormalizer.normalize(fullName).value
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
return fullName
|
|
605
608
|
}
|
|
606
609
|
|
|
607
610
|
/**
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
'use strict'
|
|
7
|
-
const a = require('async')
|
|
8
7
|
const logger = require('../../logger').child({ component: 'Transaction Trace Aggregator' })
|
|
9
8
|
|
|
10
9
|
/*
|
|
@@ -185,16 +184,29 @@ class TransactionTraceAggregator extends TraceAggregator {
|
|
|
185
184
|
return [this.runId, traces.map((trace) => trace.generateJSONSync())]
|
|
186
185
|
}
|
|
187
186
|
|
|
188
|
-
_toPayload(callback) {
|
|
187
|
+
async _toPayload(callback) {
|
|
189
188
|
const traces = this.getTraces()
|
|
190
189
|
if (!traces) {
|
|
191
190
|
return callback(null, traces)
|
|
192
191
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
(
|
|
196
|
-
|
|
197
|
-
|
|
192
|
+
|
|
193
|
+
const tracePromises = traces.map((trace) => {
|
|
194
|
+
return new Promise((resolve, reject) => {
|
|
195
|
+
trace.generateJSON((err, data) => {
|
|
196
|
+
if (err) {
|
|
197
|
+
reject(err)
|
|
198
|
+
}
|
|
199
|
+
resolve(data)
|
|
200
|
+
})
|
|
201
|
+
})
|
|
202
|
+
})
|
|
203
|
+
|
|
204
|
+
try {
|
|
205
|
+
const encodedTraces = await Promise.all(tracePromises)
|
|
206
|
+
callback(null, [this.runId, encodedTraces])
|
|
207
|
+
} catch (err) {
|
|
208
|
+
callback(err)
|
|
209
|
+
}
|
|
198
210
|
}
|
|
199
211
|
|
|
200
212
|
_afterSend(successful) {
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
|
|
6
6
|
'use strict'
|
|
7
7
|
|
|
8
|
-
const async = require('async')
|
|
9
8
|
const logger = require('../logger').child({ component: 'transaction-event-aggregator' })
|
|
10
9
|
const EventAggregator = require('../aggregators/event-aggregator')
|
|
11
10
|
|
|
@@ -100,20 +99,19 @@ class TransactionEventAggregator extends EventAggregator {
|
|
|
100
99
|
return rawEvent.value
|
|
101
100
|
}
|
|
102
101
|
|
|
103
|
-
_sendMultiple(eventPayloadPairs, sendCallback) {
|
|
102
|
+
async _sendMultiple(eventPayloadPairs, sendCallback) {
|
|
104
103
|
const self = this
|
|
105
104
|
|
|
106
105
|
// Send payloads one at a time
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
106
|
+
const promises = eventPayloadPairs.map((payloadPair, index) => {
|
|
107
|
+
logger.debug(
|
|
108
|
+
'Sending payload %d of %d to %s',
|
|
109
|
+
index + 1,
|
|
110
|
+
eventPayloadPairs.length,
|
|
111
|
+
self.method
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
return new Promise((resolve) => {
|
|
117
115
|
self._sendSplitPayload(payloadPair.rawData, payloadPair.payload, (error) => {
|
|
118
116
|
if (error) {
|
|
119
117
|
logger.warn(error, 'An error occurred sending payload')
|
|
@@ -126,16 +124,16 @@ class TransactionEventAggregator extends EventAggregator {
|
|
|
126
124
|
self.method
|
|
127
125
|
)
|
|
128
126
|
|
|
129
|
-
//
|
|
130
|
-
|
|
127
|
+
// swallow error, allow all payloads to attempt to send
|
|
128
|
+
resolve()
|
|
131
129
|
})
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
logger.debug('Finished sending %d payloads to %s', eventPayloadPairs.length, self.method)
|
|
130
|
+
})
|
|
131
|
+
})
|
|
135
132
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
133
|
+
await Promise.all(promises)
|
|
134
|
+
logger.debug('Finished sending %d payloads to %s', eventPayloadPairs.length, self.method)
|
|
135
|
+
|
|
136
|
+
sendCallback()
|
|
139
137
|
}
|
|
140
138
|
|
|
141
139
|
_sendSplitPayload(rawData, payload, callback) {
|
|
@@ -82,8 +82,10 @@ utils.isLogForwardingEnabled = function isLogForwardingEnabled(config, agent) {
|
|
|
82
82
|
* @param {object} metrics metrics module
|
|
83
83
|
*/
|
|
84
84
|
utils.incrementLoggingLinesMetrics = function incrementLoggingLinesMetrics(level, metrics) {
|
|
85
|
+
const levelMetric = getLogLevel(level)
|
|
86
|
+
|
|
85
87
|
metrics.getOrCreateMetric(LOGGING.LINES).incrementCallCount()
|
|
86
|
-
metrics.getOrCreateMetric(
|
|
88
|
+
metrics.getOrCreateMetric(levelMetric).incrementCallCount()
|
|
87
89
|
}
|
|
88
90
|
|
|
89
91
|
/**
|
|
@@ -95,3 +97,14 @@ utils.incrementLoggingLinesMetrics = function incrementLoggingLinesMetrics(level
|
|
|
95
97
|
utils.createModuleUsageMetric = function createModuleUsageMetric(lib, metrics) {
|
|
96
98
|
metrics.getOrCreateMetric(LOGGING.LIBS[lib.toUpperCase()]).incrementCallCount()
|
|
97
99
|
}
|
|
100
|
+
|
|
101
|
+
function getLogLevel(level) {
|
|
102
|
+
if (!level) {
|
|
103
|
+
return LOGGING.LEVELS.UNKNOWN
|
|
104
|
+
}
|
|
105
|
+
const logLevel = LOGGING.LEVELS[level.toUpperCase()]
|
|
106
|
+
if (!logLevel) {
|
|
107
|
+
return LOGGING.LEVELS.UNKNOWN
|
|
108
|
+
}
|
|
109
|
+
return logLevel
|
|
110
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "newrelic",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.3",
|
|
4
4
|
"author": "New Relic Node.js agent team <nodejs@newrelic.com>",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"contributors": [
|
|
@@ -169,7 +169,6 @@
|
|
|
169
169
|
"@newrelic/koa": "^7.0.0",
|
|
170
170
|
"@newrelic/superagent": "^6.0.0",
|
|
171
171
|
"@tyriar/fibonacci-heap": "^2.0.7",
|
|
172
|
-
"async": "^3.2.3",
|
|
173
172
|
"concat-stream": "^2.0.0",
|
|
174
173
|
"https-proxy-agent": "^5.0.0",
|
|
175
174
|
"json-stringify-safe": "^5.0.0",
|
|
@@ -188,9 +187,7 @@
|
|
|
188
187
|
"@octokit/rest": "^18.0.15",
|
|
189
188
|
"@slack/bolt": "^3.7.0",
|
|
190
189
|
"ajv": "^6.12.6",
|
|
191
|
-
"
|
|
192
|
-
"benchmark": "^2.1.4",
|
|
193
|
-
"bluebird": "^3.4.7",
|
|
190
|
+
"async": "^3.2.4",
|
|
194
191
|
"chai": "^4.1.2",
|
|
195
192
|
"commander": "^7.0.0",
|
|
196
193
|
"eslint": "^7.32.0",
|
|
@@ -201,22 +198,18 @@
|
|
|
201
198
|
"eslint-plugin-node": "^11.1.0",
|
|
202
199
|
"eslint-plugin-prettier": "^3.4.0",
|
|
203
200
|
"express": "*",
|
|
204
|
-
"generic-pool": "^3.6.1",
|
|
205
201
|
"glob": "^7.1.2",
|
|
206
202
|
"got": "^11.8.5",
|
|
207
203
|
"husky": "^6.0.0",
|
|
208
204
|
"jsdoc": "^3.6.3",
|
|
209
205
|
"lint-staged": "^11.0.0",
|
|
210
206
|
"memcached": ">=0.2.8",
|
|
211
|
-
"minami": "^1.
|
|
212
|
-
"mongodb": "^3.3.3",
|
|
213
|
-
"mysql": "*",
|
|
207
|
+
"minami": "^1.2.3",
|
|
214
208
|
"nock": "11.8.0",
|
|
215
209
|
"prettier": "^2.3.2",
|
|
216
210
|
"proxyquire": "^1.8.0",
|
|
217
211
|
"q": "*",
|
|
218
|
-
"
|
|
219
|
-
"request": "^2.88.0",
|
|
212
|
+
"request": "^2.88.2",
|
|
220
213
|
"rimraf": "^2.6.3",
|
|
221
214
|
"should": "*",
|
|
222
215
|
"sinon": "^4.5.0",
|