diff --git a/lib/harvest.js b/lib/harvest.js index e104776d43..dd970e5096 100644 --- a/lib/harvest.js +++ b/lib/harvest.js @@ -2,7 +2,7 @@ const a = require('async') const CollectorResponse = require('./collector/response') -const logger = require('./logger').child({component: 'Harvest'}) +const logger = require('./logger').child({ component: 'Harvest' }) const FROM_MILLIS = 1e-3 const NAMES = require('./metrics/names') @@ -188,7 +188,12 @@ class HarvestStep { // Done! self.result = response self.payload = response.payload - callback() + + try { + callback() + } catch (err) { + console.warn(err, 'Failed to call callback') + } }) } @@ -426,7 +431,7 @@ class TransactionTraceHarvest extends HarvestStep { constructor(harvest) { const traceAggr = harvest.agent.traces const maxTraceSegments = harvest.agent.config.max_trace_segments - const traces = [].concat(traceAggr.syntheticsTraces) + const traces = [].concat(traceAggr.syntheticsTraces) if (traceAggr.trace) { const trace = traceAggr.trace @@ -611,7 +616,7 @@ class Harvest { // Pull out and log any errors from harvest steps. const errors = results.map((r) => r.error).filter((e) => !!e) if (errors.length > 0) { - logger.warn({errors}, 'Errors during harvest!') + logger.warn({ errors }, 'Errors during harvest!') } // See if any endpoints told us to shutdown or restart. A shutdown trumps @@ -654,7 +659,7 @@ function _splitPayload(runId, queue) { toMerge: queue, payload: [ runId, - {reservoir_size: queue.limit, events_seen: queue.seen}, + { reservoir_size: queue.limit, events_seen: queue.seen }, queue.toArray() ] }] @@ -672,14 +677,14 @@ function _splitPayload(runId, queue) { toMerge: firstHalf, payload: [ runId, - {reservoir_size: limit, events_seen: seen}, + { reservoir_size: limit, events_seen: seen }, firstHalf.map(rawEventsToValues) ] }, { toMerge: events, payload: [ runId, - {reservoir_size: queue.limit - limit, events_seen: queue.seen - seen}, + { reservoir_size: queue.limit - limit, events_seen: queue.seen - seen }, events.map(rawEventsToValues) ] }] diff --git a/lib/instrumentation/core/http-outbound.js b/lib/instrumentation/core/http-outbound.js index 721b6a96ba..5d44cecb11 100644 --- a/lib/instrumentation/core/http-outbound.js +++ b/lib/instrumentation/core/http-outbound.js @@ -37,7 +37,12 @@ module.exports = function instrumentOutbound(agent, opts, makeRequest) { opts = copy.shallow(opts) } - let hostname = opts.hostname || opts.host || DEFAULT_HOST + let hostname = + (opts.getHeader && opts.getHeader("Host")) || + (opts.headers && opts.headers.Host) || + opts.hostname || + opts.host || + DEFAULT_HOST let port = opts.port || opts.defaultPort if (!port) { port = (!opts.protocol || opts.protocol === 'http:') ? DEFAULT_PORT : DEFAULT_SSL_PORT @@ -55,7 +60,7 @@ module.exports = function instrumentOutbound(agent, opts, makeRequest) { // but due to legacy issues we can't do that without moving customer's cheese. // // TODO: Move customers cheese by not appending the default port for https. - if (port && port !== DEFAULT_PORT) { + if (port && port !== DEFAULT_PORT && !hostname.includes(':')) { hostname += ':' + port } diff --git a/package.json b/package.json index eff7ddad5f..dc36985425 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "newrelic", - "version": "5.6.1", + "name": "@ruguoapp/newrelic", + "version": "5.6.1-jike-alpha.2", "author": "New Relic Node.js agent team ", "licenses": [ {