elastic-apm-http-client
Advanced tools
Comparing version 6.0.0 to 6.0.1
36
index.js
@@ -27,2 +27,4 @@ 'use strict' | ||
const node8 = process.version.indexOf('v8.') === 0 | ||
// All sockets on the agent are unreffed when they are created. This means that | ||
@@ -208,3 +210,3 @@ // when those are the only handles left, the `beforeExit` event will be | ||
this._maybeCork() | ||
return this.write({span}, Client.encoding.SPAN, cb) | ||
return this.write({ span }, Client.encoding.SPAN, cb) | ||
} | ||
@@ -214,3 +216,3 @@ | ||
this._maybeCork() | ||
return this.write({transaction}, Client.encoding.TRANSACTION, cb) | ||
return this.write({ transaction }, Client.encoding.TRANSACTION, cb) | ||
} | ||
@@ -220,3 +222,3 @@ | ||
this._maybeCork() | ||
return this.write({error}, Client.encoding.ERROR, cb) | ||
return this.write({ error }, Client.encoding.ERROR, cb) | ||
} | ||
@@ -264,2 +266,24 @@ | ||
// Abort the current request if the server responds prior to the request | ||
// being finished | ||
req.on('response', function (res) { | ||
if (!req.finished) { | ||
// In Node.js 8, the zlib stream will emit a 'zlib binding closed' | ||
// error when destroyed. Furthermore, the HTTP response will not emit | ||
// any data events after the request have been destroyed, so it becomes | ||
// impossible to see the error returned by the server if we abort the | ||
// request. So for Node.js 8, we'll work around this by closing the | ||
// stream gracefully. | ||
// | ||
// This results in the gzip buffer being flushed and a little more data | ||
// being sent to the APM Server, but it's better than not getting the | ||
// error body. | ||
if (node8) { | ||
stream.end() | ||
} else { | ||
destroyStream(stream) | ||
} | ||
} | ||
}) | ||
// Mointor streams for errors so that we can make sure to destory the | ||
@@ -312,3 +336,3 @@ // output stream as soon as that occurs | ||
if (!client._payloadLogFile) { | ||
client._payloadLogFile = require('fs').createWriteStream(opts.payloadLogFile, {flags: 'a'}) | ||
client._payloadLogFile = require('fs').createWriteStream(opts.payloadLogFile, { flags: 'a' }) | ||
} | ||
@@ -324,3 +348,3 @@ | ||
// All requests to the APM Server must start with a metadata object | ||
stream.write(client._encode({metadata: getMetadata(opts)}, Client.encoding.METADATA)) | ||
stream.write(client._encode({ metadata: getMetadata(opts) }, Client.encoding.METADATA)) | ||
} | ||
@@ -363,3 +387,3 @@ } | ||
const normalized = Object.assign({}, opts, {objectMode: true}) | ||
const normalized = Object.assign({}, opts, { objectMode: true }) | ||
@@ -366,0 +390,0 @@ // default values |
{ | ||
"name": "elastic-apm-http-client", | ||
"version": "6.0.0", | ||
"version": "6.0.1", | ||
"description": "A low-level HTTP client for communicating with the Elastic APM intake API", | ||
@@ -33,3 +33,3 @@ "main": "index.js", | ||
"semver": "^5.5.1", | ||
"standard": "^11.0.1", | ||
"standard": "^12.0.1", | ||
"tape": "^4.9.1" | ||
@@ -52,5 +52,5 @@ }, | ||
"coordinates": [ | ||
55.778287, | ||
12.592905 | ||
55.778241, | ||
12.593175 | ||
] | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
32340
560
0