newrelic 8.7.0 → 8.9.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 +158 -49
- package/README.md +4 -2
- package/THIRD_PARTY_NOTICES.md +10 -10
- package/index.js +2 -3
- package/lib/config/default.js +2 -0
- package/lib/config/env.js +2 -0
- package/lib/config/index.js +10 -2
- package/lib/instrumentation/mongodb/common.js +39 -2
- package/lib/instrumentation/mongodb/v3-mongo.js +4 -0
- package/lib/logger.js +10 -9
- package/lib/shim/shim.js +1 -1
- package/lib/shim/webframework-shim.js +71 -128
- package/lib/util/logger.js +36 -1
- package/lib/utilization/aws-info.js +35 -16
- package/lib/utilization/common.js +7 -3
- package/package.json +10 -10
|
@@ -9,6 +9,7 @@ const logger = require('../logger.js').child({ component: 'aws-info' })
|
|
|
9
9
|
const common = require('./common')
|
|
10
10
|
const NAMES = require('../metrics/names.js')
|
|
11
11
|
let results = null
|
|
12
|
+
const INSTANCE_HOST = '169.254.169.254'
|
|
12
13
|
|
|
13
14
|
module.exports = fetchAWSInfo
|
|
14
15
|
module.exports.clearCache = function clearAWSCache() {
|
|
@@ -24,27 +25,45 @@ function fetchAWSInfo(agent, callback) {
|
|
|
24
25
|
return setImmediate(callback, null, results)
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
const authTokenOpts = {
|
|
29
|
+
headers: { 'X-aws-ec2-metadata-token-ttl-seconds': '21600' },
|
|
30
|
+
host: INSTANCE_HOST,
|
|
31
|
+
method: 'PUT',
|
|
32
|
+
path: '/latest/api/token',
|
|
33
|
+
timeout: 500
|
|
34
|
+
}
|
|
35
|
+
common.request(authTokenOpts, agent, function getAuthToken(err, authToken) {
|
|
32
36
|
if (err) {
|
|
37
|
+
logger.debug('Failed to get AWS auth token.')
|
|
33
38
|
return callback(err)
|
|
34
39
|
}
|
|
35
40
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
const metadataOpts = {
|
|
42
|
+
headers: { 'X-aws-ec2-metadata-token': authToken },
|
|
43
|
+
host: INSTANCE_HOST,
|
|
44
|
+
method: 'GET',
|
|
45
|
+
path: '/latest/dynamic/instance-identity/document',
|
|
46
|
+
timeout: 500
|
|
41
47
|
}
|
|
42
48
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
common.request(metadataOpts, agent, function getMetadata(metaErr, data) {
|
|
50
|
+
if (metaErr) {
|
|
51
|
+
return callback(metaErr)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
try {
|
|
55
|
+
data = JSON.parse(data)
|
|
56
|
+
} catch (e) {
|
|
57
|
+
logger.debug(e, 'Failed to parse AWS metadata.')
|
|
58
|
+
data = null
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
results = common.getKeys(data, ['availabilityZone', 'instanceId', 'instanceType'])
|
|
62
|
+
if (results == null) {
|
|
63
|
+
logger.debug('AWS metadata was invalid.')
|
|
64
|
+
agent.metrics.getOrCreateMetric(NAMES.UTILIZATION.AWS_ERROR).incrementCallCount()
|
|
65
|
+
}
|
|
66
|
+
callback(null, results)
|
|
67
|
+
})
|
|
49
68
|
})
|
|
50
69
|
}
|
|
@@ -65,6 +65,12 @@ exports.request = function request(opts, agent, cb) {
|
|
|
65
65
|
|
|
66
66
|
opts.timeout = opts.timeout || 1000
|
|
67
67
|
|
|
68
|
+
// This can make more that GET requests if you pass in an object
|
|
69
|
+
// Node.js just pass this method into ClientRequest which accepts
|
|
70
|
+
// any valid HTTP Method
|
|
71
|
+
// see: https://github.com/nodejs/node/blob/master/lib/http.js#L106
|
|
72
|
+
// Technically this wouldn't work for a PUT/POST with a body
|
|
73
|
+
// but works fine in all cases where this is being used.
|
|
68
74
|
const req = http.get(opts, function awsRequest(res) {
|
|
69
75
|
res.pipe(concat(respond))
|
|
70
76
|
function respond(data) {
|
|
@@ -89,9 +95,7 @@ exports.request = function request(opts, agent, cb) {
|
|
|
89
95
|
}
|
|
90
96
|
})
|
|
91
97
|
|
|
92
|
-
req.
|
|
93
|
-
req.abort()
|
|
94
|
-
})
|
|
98
|
+
req.on('timeout', abortRequest)
|
|
95
99
|
|
|
96
100
|
req.on('error', function requestError(err) {
|
|
97
101
|
if (err.code === 'ECONNRESET') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "newrelic",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.9.0",
|
|
4
4
|
"author": "New Relic Node.js agent team <nodejs@newrelic.com>",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"contributors": [
|
|
@@ -136,7 +136,7 @@
|
|
|
136
136
|
"prepare-test": "npm run ca-gen && npm run ssl && npm run docker-env",
|
|
137
137
|
"lint": "eslint ./*.js lib test bin examples",
|
|
138
138
|
"lint:fix": "eslint --fix, ./*.js lib test bin examples",
|
|
139
|
-
"public-docs": "
|
|
139
|
+
"public-docs": "jsdoc -c ./jsdoc-conf.json --tutorials examples/shim api.js lib/shim/ lib/transaction/handle.js && cp examples/shim/*.png out/",
|
|
140
140
|
"publish-docs": "./bin/publish-docs.sh",
|
|
141
141
|
"services": "./bin/docker-services.sh",
|
|
142
142
|
"smoke": "npm run ssl && time tap test/smoke/**/**/*.tap.js --timeout=180 --no-coverage",
|
|
@@ -159,13 +159,13 @@
|
|
|
159
159
|
"newrelic-naming-rules": "./bin/test-naming-rules.js"
|
|
160
160
|
},
|
|
161
161
|
"dependencies": {
|
|
162
|
-
"@grpc/grpc-js": "^1.
|
|
163
|
-
"@grpc/proto-loader": "^0.
|
|
164
|
-
"@newrelic/aws-sdk": "^4.
|
|
165
|
-
"@newrelic/koa": "^6.
|
|
166
|
-
"@newrelic/superagent": "^5.0
|
|
162
|
+
"@grpc/grpc-js": "^1.5.5",
|
|
163
|
+
"@grpc/proto-loader": "^0.6.9",
|
|
164
|
+
"@newrelic/aws-sdk": "^4.1.1",
|
|
165
|
+
"@newrelic/koa": "^6.1.1",
|
|
166
|
+
"@newrelic/superagent": "^5.1.0",
|
|
167
167
|
"@tyriar/fibonacci-heap": "^2.0.7",
|
|
168
|
-
"async": "^3.2.
|
|
168
|
+
"async": "^3.2.3",
|
|
169
169
|
"concat-stream": "^2.0.0",
|
|
170
170
|
"https-proxy-agent": "^5.0.0",
|
|
171
171
|
"json-stringify-safe": "^5.0.0",
|
|
@@ -173,13 +173,13 @@
|
|
|
173
173
|
"semver": "^5.3.0"
|
|
174
174
|
},
|
|
175
175
|
"optionalDependencies": {
|
|
176
|
-
"@newrelic/native-metrics": "^7.
|
|
176
|
+
"@newrelic/native-metrics": "^7.1.1"
|
|
177
177
|
},
|
|
178
178
|
"devDependencies": {
|
|
179
179
|
"@newrelic/eslint-config": "^0.0.3",
|
|
180
180
|
"@newrelic/newrelic-oss-cli": "^0.1.2",
|
|
181
181
|
"@newrelic/proxy": "^2.0.0",
|
|
182
|
-
"@newrelic/test-utilities": "^6.
|
|
182
|
+
"@newrelic/test-utilities": "^6.3.0",
|
|
183
183
|
"@octokit/rest": "^18.0.15",
|
|
184
184
|
"@slack/bolt": "^3.7.0",
|
|
185
185
|
"ajv": "^6.12.6",
|