@instana/core
Advanced tools
Comparing version 1.74.2 to 1.75.0
{ | ||
"name": "@instana/core", | ||
"version": "1.74.2", | ||
"version": "1.75.0", | ||
"description": "Core library for Instana's Node.js packages", | ||
@@ -14,7 +14,7 @@ "main": "src/index.js", | ||
"audit": "npm audit --production", | ||
"test": "npm run test:nolint && npm run test:lint", | ||
"test:nolint": "NODE_ENV=debug USE_OPENTRACING_DEBUG_IMPL=true npm run test:mocha", | ||
"test": "NODE_ENV=debug USE_OPENTRACING_DEBUG_IMPL=true npm run test:mocha", | ||
"test:mocha": "mocha --reporter spec $(find test -name '*test.js')", | ||
"test:debug": "WITH_STDOUT=true npm run test:mocha", | ||
"test:lint": "eslint src test", | ||
"lint": "eslint src test", | ||
"verify": "npm run lint && npm test", | ||
"prettier": "prettier --write 'src/**/*.js' 'test/**/*.js' 'bin/**/*.js'" | ||
@@ -136,3 +136,3 @@ }, | ||
}, | ||
"gitHead": "de6e7ec86045ab2482587d2564d36d4ee836b6ee" | ||
"gitHead": "d127eb54c91c658eca2a390a10ff6cda6d5f679b" | ||
} |
'use strict'; | ||
exports.getExtraHeaders = function getExtraHeaders(incomingMessage, extraHttpHeadersToCapture) { | ||
exports.getExtraHeaders = function getExtraHeaders(message, extraHttpHeadersToCapture) { | ||
if (!extraHttpHeadersToCapture || extraHttpHeadersToCapture.length === 0) { | ||
@@ -8,11 +8,47 @@ return undefined; | ||
var extraHeadersFound = false; | ||
var extraHeaders = {}; | ||
for (var i = 0; i < extraHttpHeadersToCapture.length; i++) { | ||
var key = extraHttpHeadersToCapture[i]; | ||
var value = incomingMessage.headers[key]; | ||
var value = message.headers[key]; | ||
if (value) { | ||
extraHeaders[key] = value; | ||
extraHeadersFound = true; | ||
} | ||
} | ||
if (!extraHeadersFound) { | ||
return undefined; | ||
} | ||
return extraHeaders; | ||
}; | ||
exports.mergeExtraHeaders = function mergeExtraHeaders( | ||
headersAlreadyCapturedIfAny, | ||
message, | ||
extraHttpHeadersToCapture | ||
) { | ||
if (!extraHttpHeadersToCapture || extraHttpHeadersToCapture.length === 0) { | ||
return headersAlreadyCapturedIfAny; | ||
} | ||
var additionalHeadersFound = false; | ||
var additionalHeaders = {}; | ||
for (var i = 0; i < extraHttpHeadersToCapture.length; i++) { | ||
var key = extraHttpHeadersToCapture[i]; | ||
var value = message.getHeader(key); | ||
if (value) { | ||
additionalHeaders[key] = value; | ||
additionalHeadersFound = true; | ||
} | ||
} | ||
if (!additionalHeadersFound) { | ||
additionalHeaders = undefined; | ||
} | ||
if (headersAlreadyCapturedIfAny && additionalHeaders) { | ||
return Object.assign(headersAlreadyCapturedIfAny, additionalHeaders); | ||
} else if (additionalHeaders) { | ||
return additionalHeaders; | ||
} | ||
return headersAlreadyCapturedIfAny; | ||
}; |
@@ -105,2 +105,3 @@ 'use strict'; | ||
span.data.http.status = res.statusCode; | ||
span.data.http.header = httpCommon.mergeExtraHeaders(span.data.http.header, res, extraHttpHeadersToCapture); | ||
span.error = res.statusCode >= 500; | ||
@@ -107,0 +108,0 @@ span.ec = span.error ? 1 : 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
245930
6924