@instana/core
Advanced tools
Comparing version 1.101.1 to 1.102.0
{ | ||
"name": "@instana/core", | ||
"version": "1.101.1", | ||
"version": "1.102.0", | ||
"description": "Core library for Instana's Node.js packages", | ||
@@ -136,3 +136,3 @@ "main": "src/index.js", | ||
}, | ||
"gitHead": "04872a0a5e20764eb2b433c596ece0ea54643679" | ||
"gitHead": "ffc9b8ad0bae3bcc06541297cbdac1912163ff5a" | ||
} |
@@ -51,3 +51,4 @@ 'use strict'; | ||
'./instrumentation/protocols/httpClient', | ||
'./instrumentation/protocols/httpServer' | ||
'./instrumentation/protocols/httpServer', | ||
'./instrumentation/protocols/superagent' | ||
]; | ||
@@ -156,2 +157,14 @@ var additionalInstrumentationModules = []; | ||
exports.setExtraHttpHeadersToCapture = function setExtraHttpHeadersToCapture(_extraHeaders) { | ||
extraHeaders = _extraHeaders; | ||
instrumentations.forEach(function(instrumentationKey) { | ||
if ( | ||
instrumentationModules[instrumentationKey] && | ||
typeof instrumentationModules[instrumentationKey].setExtraHttpHeadersToCapture === 'function' | ||
) { | ||
instrumentationModules[instrumentationKey].setExtraHttpHeadersToCapture(extraHeaders); | ||
} | ||
}); | ||
}; | ||
exports._getAndResetTracingMetrics = function _getAndResetTracingMetrics() { | ||
@@ -167,2 +180,10 @@ return { | ||
exports._instrument = function _instrument(name, module_) { | ||
if (name === 'superagent') { | ||
require('./instrumentation/protocols/superagent').instrument(module_); | ||
} else { | ||
throw new Error('An unknown or unsupported instrumentation has been requested: ' + name); | ||
} | ||
}; | ||
exports._debugCurrentSpanName = function _debugCurrentSpanName() { | ||
@@ -176,15 +197,3 @@ if (!cls) { | ||
} | ||
return 'current:' + s.n; | ||
return 'current: ' + s.n; | ||
}; | ||
exports.setExtraHttpHeadersToCapture = function setExtraHttpHeadersToCapture(_extraHeaders) { | ||
extraHeaders = _extraHeaders; | ||
instrumentations.forEach(function(instrumentationKey) { | ||
if ( | ||
instrumentationModules[instrumentationKey] && | ||
typeof instrumentationModules[instrumentationKey].setExtraHttpHeadersToCapture === 'function' | ||
) { | ||
instrumentationModules[instrumentationKey].setExtraHttpHeadersToCapture(extraHeaders); | ||
} | ||
}); | ||
}; |
@@ -23,3 +23,3 @@ 'use strict'; | ||
exports.init = function(config) { | ||
instrument(coreHttpModule); | ||
instrument(coreHttpModule, false); | ||
@@ -37,3 +37,3 @@ // Up until Node 8, the core https module uses the http module internally, so https calls are traced automatically | ||
if (semver.gte(process.versions.node, '9.0.0') || process.versions.node === '8.9.0') { | ||
instrument(coreHttpsModule); | ||
instrument(coreHttpsModule, true); | ||
} | ||
@@ -47,3 +47,3 @@ extraHttpHeadersToCapture = config.tracing.http.extraHttpHeadersToCapture; | ||
function instrument(coreModule) { | ||
function instrument(coreModule, forceHttps) { | ||
var originalRequest = coreModule.request; | ||
@@ -120,3 +120,3 @@ coreModule.request = function request() { | ||
} else if (options) { | ||
var urlAndQuery = constructFromUrlOpts(options, coreModule); | ||
var urlAndQuery = constructFromUrlOpts(options, coreModule, forceHttps); | ||
completeCallUrl = urlAndQuery[0]; | ||
@@ -239,3 +239,3 @@ params = urlAndQuery[1]; | ||
function constructFromUrlOpts(options, self) { | ||
function constructFromUrlOpts(options, self, forceHttps) { | ||
if (options.href) { | ||
@@ -248,3 +248,8 @@ return [discardUrlParameters(options.href), splitAndFilter(options.href)]; | ||
var port = options.port || options.defaultPort || (agent && agent.defaultPort) || 80; | ||
var protocol = (port === 443 && 'https:') || options.protocol || (agent && agent.protocol) || 'http:'; | ||
var protocol = | ||
(port === 443 && 'https:') || | ||
options.protocol || | ||
(agent && agent.protocol) || | ||
(forceHttps && 'https:') || | ||
'http:'; | ||
var host = options.hostname || options.host || 'localhost'; | ||
@@ -298,2 +303,4 @@ var path = options.path || '/'; | ||
if (!isItSafeToModifiyHeadersInOptions(options)) { | ||
// Return true to convince the caller that headers have been added although we have in fact not added them. This | ||
// will result in no headers being added. See isItSafeToModifiyHeadersInOptions for the motivation behind this. | ||
return true; | ||
@@ -300,0 +307,0 @@ } |
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
342219
81
9249