newrelic 5.13.0 → 6.2.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/.travis.yml +20 -21
- package/NEWS.md +166 -0
- package/README.md +10 -10
- package/api.js +84 -2
- package/bin/run-versioned-tests.sh +3 -1
- package/bin/ssl.sh +43 -1
- package/bin/travis-node.sh +51 -0
- package/bin/travis-setup.sh +0 -4
- package/lib/agent.js +148 -315
- package/lib/aggregators/base-aggregator.js +3 -12
- package/lib/collector/api.js +2 -1
- package/lib/collector/facts.js +1 -1
- package/lib/config/default.js +8 -11
- package/lib/config/env.js +19 -1
- package/lib/config/index.js +52 -8
- package/lib/injector.js +161 -0
- package/lib/instrumentation/bluebird.js +4 -3
- package/lib/instrumentation/core/http-outbound.js +1 -0
- package/lib/instrumentation/mysql.js +10 -2
- package/lib/instrumentations.js +1 -1
- package/lib/shimmer.js +153 -5
- package/lib/spans/span-event-aggregator.js +1 -1
- package/lib/spans/span-event.js +1 -1
- package/lib/transaction/handle.js +11 -0
- package/lib/transaction/index.js +14 -3
- package/lib/transaction/trace/segment.js +10 -0
- package/lib/utilization/common.js +11 -4
- package/package.json +14 -11
- package/stub_api.js +8 -0
- package/lib/event-aggregator.js +0 -94
- package/lib/harvest.js +0 -718
- package/lib/instrumentation/aws-sdk.js +0 -25
|
@@ -90,6 +90,16 @@ TraceSegment.prototype.getAttributes = function getAttributes() {
|
|
|
90
90
|
return this.attributes.get(DESTINATIONS.TRANS_SEGMENT)
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
TraceSegment.prototype.getSpanId = function getSpanId() {
|
|
94
|
+
const conf = this.transaction.agent.config
|
|
95
|
+
const enabled = conf.span_events.enabled && conf.distributed_tracing.enabled
|
|
96
|
+
if (enabled) {
|
|
97
|
+
return this.id
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return null
|
|
101
|
+
}
|
|
102
|
+
|
|
93
103
|
/**
|
|
94
104
|
* @param {string} host
|
|
95
105
|
* The name of the host of the database. This will be normalized if the string
|
|
@@ -66,7 +66,8 @@ exports.request = function request(opts, agent, cb) {
|
|
|
66
66
|
function respond(data) {
|
|
67
67
|
agent.removeListener('errored', abortRequest)
|
|
68
68
|
agent.removeListener('stopped', abortRequest)
|
|
69
|
-
|
|
69
|
+
agent.removeListener('disconnected', abortRequest)
|
|
70
|
+
|
|
70
71
|
if (res.statusCode !== 200) {
|
|
71
72
|
logger.debug(
|
|
72
73
|
'Got %d %s from metadata request %j',
|
|
@@ -83,22 +84,28 @@ exports.request = function request(opts, agent, cb) {
|
|
|
83
84
|
})
|
|
84
85
|
|
|
85
86
|
req.setTimeout(1000, function requestTimeout() {
|
|
86
|
-
|
|
87
|
-
cb(new Error('Timeout'))
|
|
87
|
+
req.abort()
|
|
88
88
|
})
|
|
89
|
+
|
|
89
90
|
req.on('error', function requestError(err) {
|
|
91
|
+
if (err.code === 'ECONNRESET') {
|
|
92
|
+
logger.debug('Request for metadata %j timed out', opts)
|
|
93
|
+
return cb(err)
|
|
94
|
+
}
|
|
95
|
+
|
|
90
96
|
logger.debug('Message for metadata %j: %s', opts, err.message)
|
|
91
97
|
cb(err)
|
|
92
98
|
})
|
|
93
|
-
|
|
94
99
|
agent.once('errored', abortRequest)
|
|
95
100
|
agent.once('stopped', abortRequest)
|
|
101
|
+
agent.once('disconnected', abortRequest)
|
|
96
102
|
|
|
97
103
|
function abortRequest() {
|
|
98
104
|
logger.debug('Aborting request for metadata at %j', opts)
|
|
99
105
|
req.abort()
|
|
100
106
|
agent.removeListener('errored', abortRequest)
|
|
101
107
|
agent.removeListener('stopped', abortRequest)
|
|
108
|
+
agent.removeListener('disconnected', abortRequest)
|
|
102
109
|
}
|
|
103
110
|
}
|
|
104
111
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "newrelic",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.2.0",
|
|
4
4
|
"author": "New Relic Node.js agent team <nodejs@newrelic.com>",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"contributors": [
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
],
|
|
97
97
|
"homepage": "http://github.com/newrelic/node-newrelic",
|
|
98
98
|
"engines": {
|
|
99
|
-
"node": ">=
|
|
99
|
+
"node": ">=8.0.0 <13.0.0",
|
|
100
100
|
"npm": ">=3.0.0"
|
|
101
101
|
},
|
|
102
102
|
"directories": {
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
"clean": "./bin/clean.sh",
|
|
109
109
|
"docker-env": "./bin/docker-env-vars.sh",
|
|
110
110
|
"docs": "npm ci && jsdoc -c ./jsdoc-conf.json --private -r .",
|
|
111
|
-
"integration": "npm run prepare-test && npm run sub-install && time tap --no-esm test/integration
|
|
111
|
+
"integration": "npm run prepare-test && npm run sub-install && time tap --no-esm test/integration/**/**/*.tap.js --timeout=120 --no-coverage",
|
|
112
112
|
"prepare-test": "npm ci && npm run ca-gen && npm run ssl && npm run docker-env",
|
|
113
113
|
"lint": "eslint ./*.js lib test",
|
|
114
114
|
"public-docs": "npm ci && jsdoc -c ./jsdoc-conf.json --tutorials examples/shim api.js lib/shim/ lib/transaction/handle.js && cp examples/shim/*.png out/",
|
|
@@ -119,7 +119,7 @@
|
|
|
119
119
|
"ssl": "./bin/ssl.sh",
|
|
120
120
|
"sub-install": "node test/bin/install_sub_deps",
|
|
121
121
|
"test": "npm run integration && npm run unit",
|
|
122
|
-
"unit": "rm -f newrelic_agent.log && mocha -r nock -c test/unit --recursive",
|
|
122
|
+
"unit": "rm -f newrelic_agent.log && mocha -r nock -c test/unit --recursive --exit",
|
|
123
123
|
"update-cross-agent-tests": "./bin/update-cats.sh",
|
|
124
124
|
"versioned-tests": "./bin/run-versioned-tests.sh",
|
|
125
125
|
"versioned": "npm run prepare-test && time ./bin/run-versioned-tests.sh"
|
|
@@ -128,18 +128,21 @@
|
|
|
128
128
|
"newrelic-naming-rules": "./bin/test-naming-rules.js"
|
|
129
129
|
},
|
|
130
130
|
"dependencies": {
|
|
131
|
-
"@newrelic/
|
|
132
|
-
"@newrelic/
|
|
131
|
+
"@newrelic/aws-sdk": "^1.0.0",
|
|
132
|
+
"@newrelic/koa": "^3.0.0",
|
|
133
|
+
"@newrelic/superagent": "^2.0.0",
|
|
133
134
|
"@tyriar/fibonacci-heap": "^2.0.7",
|
|
134
135
|
"async": "^2.1.4",
|
|
135
136
|
"concat-stream": "^2.0.0",
|
|
136
|
-
"
|
|
137
|
+
"escodegen": "^1.11.1",
|
|
138
|
+
"esprima": "^4.0.1",
|
|
139
|
+
"https-proxy-agent": "^3.0.0",
|
|
137
140
|
"json-stringify-safe": "^5.0.0",
|
|
138
141
|
"readable-stream": "^3.1.1",
|
|
139
142
|
"semver": "^5.3.0"
|
|
140
143
|
},
|
|
141
144
|
"optionalDependencies": {
|
|
142
|
-
"@newrelic/native-metrics": "^
|
|
145
|
+
"@newrelic/native-metrics": "^5.0.0"
|
|
143
146
|
},
|
|
144
147
|
"devDependencies": {
|
|
145
148
|
"@newrelic/proxy": "^1.0.0",
|
|
@@ -158,8 +161,8 @@
|
|
|
158
161
|
"lodash": "^4.17.14",
|
|
159
162
|
"memcached": ">=0.2.8",
|
|
160
163
|
"minami": "^1.1.1",
|
|
161
|
-
"mocha": "^
|
|
162
|
-
"mongodb": "^
|
|
164
|
+
"mocha": "^6.2.1",
|
|
165
|
+
"mongodb": "^3.3.3",
|
|
163
166
|
"mysql": "*",
|
|
164
167
|
"nock": "9.1.9",
|
|
165
168
|
"proxyquire": "^1.8.0",
|
|
@@ -170,7 +173,7 @@
|
|
|
170
173
|
"rimraf": "^2.6.3",
|
|
171
174
|
"should": "*",
|
|
172
175
|
"sinon": "^4.5.0",
|
|
173
|
-
"tap": "^
|
|
176
|
+
"tap": "^14.10.1",
|
|
174
177
|
"temp": "^0.8.1",
|
|
175
178
|
"through": "^2.3.6",
|
|
176
179
|
"when": "*"
|
package/stub_api.js
CHANGED
|
@@ -36,6 +36,7 @@ Stub.prototype.getTransaction = getTransaction
|
|
|
36
36
|
Stub.prototype.getBrowserTimingHeader = getBrowserTimingHeader
|
|
37
37
|
Stub.prototype.shutdown = shutdown
|
|
38
38
|
Stub.prototype.setLambdaHandler = setLambdaHandler
|
|
39
|
+
Stub.prototype.getTraceMetadata = getTraceMetadata
|
|
39
40
|
|
|
40
41
|
// This code gets injected into HTML templates
|
|
41
42
|
// and we don't want it to return undefined/null.
|
|
@@ -61,6 +62,13 @@ function startSegment(name, record, handler, callback) {
|
|
|
61
62
|
return null
|
|
62
63
|
}
|
|
63
64
|
|
|
65
|
+
function getTraceMetadata() {
|
|
66
|
+
return {
|
|
67
|
+
traceId: '',
|
|
68
|
+
spanId: ''
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
64
72
|
function startWebTransaction(url, callback) {
|
|
65
73
|
logger.debug('Not calling startWebTransaction because New Relic is disabled.')
|
|
66
74
|
if (typeof callback === 'function') {
|
package/lib/event-aggregator.js
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const logger = require('./logger').child({component: 'event_aggregator'})
|
|
4
|
-
const PriorityQueue = require('./priority-queue')
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Aggregates events up to a certain limit.
|
|
8
|
-
*
|
|
9
|
-
* @private
|
|
10
|
-
* @class
|
|
11
|
-
*/
|
|
12
|
-
class EventAggregator {
|
|
13
|
-
constructor(limit) {
|
|
14
|
-
this._events = new PriorityQueue(limit)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
get limit() {
|
|
18
|
-
return this._events.limit
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
set limit(limit) {
|
|
22
|
-
this._events.setLimit(limit)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
get seen() {
|
|
26
|
-
return this._events.seen
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
get length() {
|
|
30
|
-
return this._events.length
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
get overflow() {
|
|
34
|
-
return this._events.overflow()
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
*
|
|
39
|
-
*/
|
|
40
|
-
getQueue() {
|
|
41
|
-
return this._events
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Fetches all the span events aggregated.
|
|
46
|
-
*
|
|
47
|
-
* @return {array.<Event>} An array of span events from the aggregator.
|
|
48
|
-
*/
|
|
49
|
-
getEvents() {
|
|
50
|
-
return this._events.toArray()
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Resets the contents of the aggregator and all counters.
|
|
55
|
-
*
|
|
56
|
-
* @return {PriorityQueue} The old collection of aggregated events.
|
|
57
|
-
*/
|
|
58
|
-
clearEvents() {
|
|
59
|
-
const oldEvents = this._events
|
|
60
|
-
this._events = new PriorityQueue(this._events.limit)
|
|
61
|
-
return oldEvents
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
addEvent(event, priority) {
|
|
65
|
-
return this._events.add(event, priority)
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Merges a set of events back into the aggregator.
|
|
70
|
-
*
|
|
71
|
-
* This should only be used after a failed harvest with the `PriorityQueue`
|
|
72
|
-
* returned from `EventAggregator#clearEvents`.
|
|
73
|
-
*
|
|
74
|
-
* @param {?PriorityQueue} events - The collection of events to re-merge.
|
|
75
|
-
*/
|
|
76
|
-
mergeEvents(events) {
|
|
77
|
-
if (!events) {
|
|
78
|
-
return
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// We calculate the number that will be merged for the log, but we try to
|
|
82
|
-
// add every event because we want the ones with the highest priority, not
|
|
83
|
-
// the first `n` events.
|
|
84
|
-
const toMerge = Math.min(events.length, this.limit - this.length)
|
|
85
|
-
logger.warn(
|
|
86
|
-
'Merging %d of %d events into %s for next harvest',
|
|
87
|
-
toMerge, events.length, this.constructor.name
|
|
88
|
-
)
|
|
89
|
-
|
|
90
|
-
this._events.merge(events)
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
module.exports = EventAggregator
|