@instana/core
Advanced tools
Comparing version 2.2.0 to 2.3.0
@@ -6,2 +6,20 @@ # Change Log | ||
# [2.3.0](https://github.com/instana/nodejs/compare/v2.2.0...v2.3.0) (2022-05-24) | ||
### Bug Fixes | ||
* **http:** only capture response status/headers when they have been sent ([850b8e4](https://github.com/instana/nodejs/commit/850b8e43f93749e422e9923c10cef9a8d1e2f3ea)), closes [#548](https://github.com/instana/nodejs/issues/548) | ||
* **kafkajs:** use long trace IDs with new Kafka message headers ([5674b08](https://github.com/instana/nodejs/commit/5674b086b1481e0aaf7c352924fbd45634456461)) | ||
* **rdkafka:** use long trace IDs with new Kafka message headers ([9c47349](https://github.com/instana/nodejs/commit/9c47349b5de214828c075eded71242a32c1f26c8)) | ||
### Features | ||
* **kafkajs:** remove Instana headers on arrival ([f65bc75](https://github.com/instana/nodejs/commit/f65bc753667c8aaf636b0c0c6100f772338e639c)) | ||
# [2.2.0](https://github.com/instana/nodejs/compare/v2.1.0...v2.2.0) (2022-05-18) | ||
@@ -8,0 +26,0 @@ |
{ | ||
"name": "@instana/core", | ||
"version": "2.2.0", | ||
"version": "2.3.0", | ||
"description": "Core library for Instana's Node.js packages", | ||
@@ -139,3 +139,3 @@ "main": "src/index.js", | ||
}, | ||
"gitHead": "5f039b739bf6726e6a0da401721f6ea790d9850d" | ||
"gitHead": "d7e2170d1b4071200200f9b2437d2c7d5ec7b8d9" | ||
} |
@@ -21,11 +21,11 @@ /* | ||
// legacy kafka trace correlation (binary values) | ||
exports.kafkaTraceContextHeaderNameBinary = 'X_INSTANA_C'; | ||
exports.kafkaTraceLevelHeaderNameBinary = 'X_INSTANA_L'; | ||
exports.kafkaTraceLevelBinaryValueSuppressed = Buffer.from([0]); | ||
exports.kafkaTraceLevelBinaryValueInherit = Buffer.from([1]); | ||
exports.kafkaLegacyTraceContextHeaderName = 'X_INSTANA_C'; | ||
exports.kafkaLegacyTraceLevelHeaderName = 'X_INSTANA_L'; | ||
exports.kafkaLegacyTraceLevelValueSuppressed = Buffer.from([0]); | ||
exports.kafkaLegacyTraceLevelValueInherit = Buffer.from([1]); | ||
// new kafka trace correlation (string values) starting approximately 2021-11 | ||
exports.kafkaTraceIdHeaderNameString = 'X_INSTANA_T'; | ||
exports.kafkaSpanIdHeaderNameString = 'X_INSTANA_S'; | ||
exports.kafkaTraceLevelHeaderNameString = 'X_INSTANA_L_S'; | ||
exports.kafkaTraceIdHeaderName = 'X_INSTANA_T'; | ||
exports.kafkaSpanIdHeaderName = 'X_INSTANA_S'; | ||
exports.kafkaTraceLevelHeaderName = 'X_INSTANA_L_S'; | ||
@@ -37,2 +37,10 @@ exports.kafkaTraceCorrelationDefault = true; | ||
exports.allInstanaKafkaHeaders = [ | ||
exports.kafkaTraceIdHeaderName, | ||
exports.kafkaSpanIdHeaderName, | ||
exports.kafkaTraceLevelHeaderName, | ||
exports.kafkaLegacyTraceContextHeaderName, | ||
exports.kafkaLegacyTraceLevelHeaderName | ||
]; | ||
exports.w3cTraceParent = 'traceparent'; | ||
@@ -39,0 +47,0 @@ exports.w3cTraceState = 'tracestate'; |
@@ -10,2 +10,4 @@ /* | ||
const tracingUtil = require('../../tracingUtil'); | ||
const { limitTraceId } = require('../../tracingHeaders'); | ||
const leftPad = require('../../leftPad'); | ||
const constants = require('../../constants'); | ||
@@ -240,2 +242,3 @@ const cls = require('../../cls'); | ||
let traceId; | ||
let longTraceId; | ||
let parentSpanId; | ||
@@ -245,10 +248,15 @@ let level; | ||
// Look for the the newer string header format first. | ||
if (message.headers[constants.kafkaTraceIdHeaderNameString]) { | ||
traceId = String(message.headers[constants.kafkaTraceIdHeaderNameString]); | ||
if (message.headers[constants.kafkaTraceIdHeaderName]) { | ||
traceId = String(message.headers[constants.kafkaTraceIdHeaderName]); | ||
if (traceId) { | ||
const limited = limitTraceId({ traceId }); | ||
traceId = limited.traceId; | ||
longTraceId = limited.longTraceId; | ||
} | ||
} | ||
if (message.headers[constants.kafkaSpanIdHeaderNameString]) { | ||
parentSpanId = String(message.headers[constants.kafkaSpanIdHeaderNameString]); | ||
if (message.headers[constants.kafkaSpanIdHeaderName]) { | ||
parentSpanId = String(message.headers[constants.kafkaSpanIdHeaderName]); | ||
} | ||
if (message.headers[constants.kafkaTraceLevelHeaderNameString]) { | ||
level = String(message.headers[constants.kafkaTraceLevelHeaderNameString]); | ||
if (message.headers[constants.kafkaTraceLevelHeaderName]) { | ||
level = String(message.headers[constants.kafkaTraceLevelHeaderName]); | ||
} | ||
@@ -258,4 +266,4 @@ // Only fall back to legacy binary trace correlation headers if no new header is present. | ||
// The newer string header format has not been found, fall back to legacy binary headers. | ||
if (message.headers[constants.kafkaTraceContextHeaderNameBinary]) { | ||
const traceContextBuffer = message.headers[constants.kafkaTraceContextHeaderNameBinary]; | ||
if (message.headers[constants.kafkaLegacyTraceContextHeaderName]) { | ||
const traceContextBuffer = message.headers[constants.kafkaLegacyTraceContextHeaderName]; | ||
if (Buffer.isBuffer(traceContextBuffer) && traceContextBuffer.length === 24) { | ||
@@ -271,2 +279,4 @@ const traceContext = tracingUtil.readTraceContextFromBuffer(traceContextBuffer); | ||
removeInstanaHeadersFromMessage(message); | ||
return cls.ns.runAndReturn(() => { | ||
@@ -279,2 +289,5 @@ if (isSuppressed(level)) { | ||
const span = cls.startSpan('kafka', constants.ENTRY, traceId, parentSpanId); | ||
if (longTraceId) { | ||
span.lt = longTraceId; | ||
} | ||
span.stack = []; | ||
@@ -322,2 +335,3 @@ span.data.kafka = { | ||
let traceId; | ||
let longTraceId; | ||
let parentSpanId; | ||
@@ -328,13 +342,15 @@ let level; | ||
for (let msgIdx = 0; msgIdx < batch.messages.length; msgIdx++) { | ||
if (batch.messages[msgIdx].headers && batch.messages[msgIdx].headers[constants.kafkaTraceIdHeaderNameString]) { | ||
traceId = String(batch.messages[msgIdx].headers[constants.kafkaTraceIdHeaderNameString]); | ||
if (batch.messages[msgIdx].headers && batch.messages[msgIdx].headers[constants.kafkaTraceIdHeaderName]) { | ||
traceId = String(batch.messages[msgIdx].headers[constants.kafkaTraceIdHeaderName]); | ||
if (traceId) { | ||
const limited = limitTraceId({ traceId }); | ||
traceId = limited.traceId; | ||
longTraceId = limited.longTraceId; | ||
} | ||
} | ||
if (batch.messages[msgIdx].headers && batch.messages[msgIdx].headers[constants.kafkaSpanIdHeaderNameString]) { | ||
parentSpanId = String(batch.messages[msgIdx].headers[constants.kafkaSpanIdHeaderNameString]); | ||
if (batch.messages[msgIdx].headers && batch.messages[msgIdx].headers[constants.kafkaSpanIdHeaderName]) { | ||
parentSpanId = String(batch.messages[msgIdx].headers[constants.kafkaSpanIdHeaderName]); | ||
} | ||
if ( | ||
batch.messages[msgIdx].headers && | ||
batch.messages[msgIdx].headers[constants.kafkaTraceLevelHeaderNameString] | ||
) { | ||
level = String(batch.messages[msgIdx].headers[constants.kafkaTraceLevelHeaderNameString]); | ||
if (batch.messages[msgIdx].headers && batch.messages[msgIdx].headers[constants.kafkaTraceLevelHeaderName]) { | ||
level = String(batch.messages[msgIdx].headers[constants.kafkaTraceLevelHeaderName]); | ||
} | ||
@@ -352,5 +368,5 @@ if (traceId != null || parentSpanId != null || level != null) { | ||
batch.messages[msgIdx].headers && | ||
batch.messages[msgIdx].headers[constants.kafkaTraceContextHeaderNameBinary] | ||
batch.messages[msgIdx].headers[constants.kafkaLegacyTraceContextHeaderName] | ||
) { | ||
const traceContextBuffer = batch.messages[msgIdx].headers[constants.kafkaTraceContextHeaderNameBinary]; | ||
const traceContextBuffer = batch.messages[msgIdx].headers[constants.kafkaLegacyTraceContextHeaderName]; | ||
if (Buffer.isBuffer(traceContextBuffer) && traceContextBuffer.length === 24) { | ||
@@ -368,2 +384,6 @@ const traceContext = tracingUtil.readTraceContextFromBuffer(traceContextBuffer); | ||
} | ||
for (let msgIdx = 0; msgIdx < batch.messages.length; msgIdx++) { | ||
removeInstanaHeadersFromMessage(batch.messages[msgIdx]); | ||
} | ||
} | ||
@@ -378,2 +398,5 @@ | ||
const span = cls.startSpan('kafka', constants.ENTRY, traceId, parentSpanId); | ||
if (longTraceId) { | ||
span.lt = longTraceId; | ||
} | ||
span.stack = []; | ||
@@ -406,4 +429,4 @@ span.data.kafka = { | ||
function readTraceLevelBinary(message) { | ||
if (message.headers[constants.kafkaTraceLevelHeaderNameBinary]) { | ||
const traceLevelBuffer = message.headers[constants.kafkaTraceLevelHeaderNameBinary]; | ||
if (message.headers[constants.kafkaLegacyTraceLevelHeaderName]) { | ||
const traceLevelBuffer = message.headers[constants.kafkaLegacyTraceLevelHeaderName]; | ||
if (Buffer.isBuffer(traceLevelBuffer) && traceLevelBuffer.length >= 1) { | ||
@@ -422,6 +445,6 @@ return String(traceLevelBuffer.readInt8()); | ||
case 'binary': | ||
addTraceContextHeaderToAllMessagesBinary(messages, span); | ||
addLegacyTraceContextHeaderToAllMessages(messages, span); | ||
break; | ||
case 'string': | ||
addTraceContextHeaderToAllMessagesString(messages, span); | ||
addTraceIdSpanIdToAllMessages(messages, span); | ||
break; | ||
@@ -431,8 +454,8 @@ case 'both': | ||
default: | ||
addTraceContextHeaderToAllMessagesBinary(messages, span); | ||
addTraceContextHeaderToAllMessagesString(messages, span); | ||
addLegacyTraceContextHeaderToAllMessages(messages, span); | ||
addTraceIdSpanIdToAllMessages(messages, span); | ||
} | ||
} | ||
function addTraceContextHeaderToAllMessagesBinary(messages, span) { | ||
function addLegacyTraceContextHeaderToAllMessages(messages, span) { | ||
if (Array.isArray(messages)) { | ||
@@ -442,10 +465,10 @@ for (let msgIdx = 0; msgIdx < messages.length; msgIdx++) { | ||
messages[msgIdx].headers = { | ||
[constants.kafkaTraceContextHeaderNameBinary]: tracingUtil.renderTraceContextToBuffer(span), | ||
[constants.kafkaTraceLevelHeaderNameBinary]: constants.kafkaTraceLevelBinaryValueInherit | ||
[constants.kafkaLegacyTraceContextHeaderName]: tracingUtil.renderTraceContextToBuffer(span), | ||
[constants.kafkaLegacyTraceLevelHeaderName]: constants.kafkaLegacyTraceLevelValueInherit | ||
}; | ||
} else if (messages[msgIdx].headers && typeof messages[msgIdx].headers === 'object') { | ||
messages[msgIdx].headers[constants.kafkaTraceContextHeaderNameBinary] = | ||
messages[msgIdx].headers[constants.kafkaLegacyTraceContextHeaderName] = | ||
tracingUtil.renderTraceContextToBuffer(span); | ||
messages[msgIdx].headers[constants.kafkaTraceLevelHeaderNameBinary] = | ||
constants.kafkaTraceLevelBinaryValueInherit; | ||
messages[msgIdx].headers[constants.kafkaLegacyTraceLevelHeaderName] = | ||
constants.kafkaLegacyTraceLevelValueInherit; | ||
} | ||
@@ -456,3 +479,3 @@ } | ||
function addTraceContextHeaderToAllMessagesString(messages, span) { | ||
function addTraceIdSpanIdToAllMessages(messages, span) { | ||
if (Array.isArray(messages)) { | ||
@@ -462,8 +485,8 @@ for (let msgIdx = 0; msgIdx < messages.length; msgIdx++) { | ||
messages[msgIdx].headers = { | ||
[constants.kafkaTraceIdHeaderNameString]: span.t, | ||
[constants.kafkaSpanIdHeaderNameString]: span.s | ||
[constants.kafkaTraceIdHeaderName]: leftPad(span.t, 32), | ||
[constants.kafkaSpanIdHeaderName]: span.s | ||
}; | ||
} else if (messages[msgIdx].headers && typeof messages[msgIdx].headers === 'object') { | ||
messages[msgIdx].headers[constants.kafkaTraceIdHeaderNameString] = span.t; | ||
messages[msgIdx].headers[constants.kafkaSpanIdHeaderNameString] = span.s; | ||
messages[msgIdx].headers[constants.kafkaTraceIdHeaderName] = leftPad(span.t, 32); | ||
messages[msgIdx].headers[constants.kafkaSpanIdHeaderName] = span.s; | ||
} | ||
@@ -498,7 +521,7 @@ } | ||
messages[msgIdx].headers = { | ||
[constants.kafkaTraceLevelHeaderNameBinary]: constants.kafkaTraceLevelBinaryValueSuppressed | ||
[constants.kafkaLegacyTraceLevelHeaderName]: constants.kafkaLegacyTraceLevelValueSuppressed | ||
}; | ||
} else if (messages[msgIdx].headers && typeof messages[msgIdx].headers === 'object') { | ||
messages[msgIdx].headers[constants.kafkaTraceLevelHeaderNameBinary] = | ||
constants.kafkaTraceLevelBinaryValueSuppressed; | ||
messages[msgIdx].headers[constants.kafkaLegacyTraceLevelHeaderName] = | ||
constants.kafkaLegacyTraceLevelValueSuppressed; | ||
} | ||
@@ -514,6 +537,6 @@ } | ||
messages[msgIdx].headers = { | ||
[constants.kafkaTraceLevelHeaderNameString]: '0' | ||
[constants.kafkaTraceLevelHeaderName]: '0' | ||
}; | ||
} else if (messages[msgIdx].headers && typeof messages[msgIdx].headers === 'object') { | ||
messages[msgIdx].headers[constants.kafkaTraceLevelHeaderNameString] = '0'; | ||
messages[msgIdx].headers[constants.kafkaTraceLevelHeaderName] = '0'; | ||
} | ||
@@ -523,1 +546,10 @@ } | ||
} | ||
function removeInstanaHeadersFromMessage(message) { | ||
if (message.headers && typeof message.headers === 'object') { | ||
constants.allInstanaKafkaHeaders.forEach(name => { | ||
// If the header is not present, deleting it is a no-op. | ||
delete message.headers[name]; | ||
}); | ||
} | ||
} |
@@ -9,2 +9,4 @@ /* | ||
const tracingUtil = require('../../tracingUtil'); | ||
const { limitTraceId } = require('../../tracingHeaders'); | ||
const leftPad = require('../../leftPad'); | ||
const constants = require('../../constants'); | ||
@@ -228,10 +230,2 @@ const cls = require('../../cls'); | ||
if (messageData.headers && messageData.headers.length) { | ||
const instanaHeaders = [ | ||
constants.kafkaTraceLevelHeaderNameString, | ||
constants.kafkaTraceLevelHeaderNameBinary, | ||
constants.kafkaTraceIdHeaderNameString, | ||
constants.kafkaSpanIdHeaderNameString, | ||
constants.kafkaTraceContextHeaderNameBinary | ||
].map(header => header.toLowerCase()); | ||
for (let i = messageData.headers.length - 1; i >= 0; i--) { | ||
@@ -242,5 +236,5 @@ const headerObject = messageData.headers[i]; | ||
// messageData.headers array | ||
const headerKey = Object.keys(headerObject)[0]; | ||
const headerKey = Object.keys(headerObject)[0].toUpperCase(); | ||
if (instanaHeaders.indexOf(headerKey.toLocaleLowerCase()) > -1) { | ||
if (constants.allInstanaKafkaHeaders.includes(headerKey)) { | ||
messageData.headers.splice(i, 1); | ||
@@ -279,4 +273,4 @@ } | ||
const instanaHeaders = (messageData.headers || []).filter(headerObject => { | ||
const headerKey = Object.keys(headerObject)[0].toLowerCase(); | ||
return headerKey.indexOf('x_instana') > -1; | ||
const headerKey = Object.keys(headerObject)[0].toUpperCase(); | ||
return constants.allInstanaKafkaHeaders.includes(headerKey); | ||
}); | ||
@@ -286,5 +280,4 @@ | ||
const instanaHeadersAsObject = {}; | ||
instanaHeaders.forEach(instanaHeader => { | ||
const key = Object.keys(instanaHeader)[0]; | ||
const key = Object.keys(instanaHeader)[0].toUpperCase(); | ||
instanaHeadersAsObject[key] = instanaHeader[key]; | ||
@@ -294,2 +287,3 @@ }); | ||
let traceId; | ||
let longTraceId; | ||
let parentSpanId; | ||
@@ -302,2 +296,3 @@ let level; | ||
traceId: _traceId, | ||
longTraceId: _longTraceId, | ||
parentSpanId: _parentSpanId | ||
@@ -307,2 +302,3 @@ } = findInstanaHeaderValues(instanaHeadersAsObject); | ||
traceId = _traceId; | ||
longTraceId = _longTraceId; | ||
parentSpanId = _parentSpanId; | ||
@@ -321,2 +317,5 @@ level = _level; | ||
const span = cls.startSpan('kafka', constants.ENTRY, traceId, parentSpanId); | ||
if (longTraceId) { | ||
span.lt = longTraceId; | ||
} | ||
span.stack = tracingUtil.getStackTrace(instrumentedConsumerEmit, 1); | ||
@@ -348,4 +347,4 @@ | ||
function readTraceLevelBinary(instanaHeadersAsObject) { | ||
if (instanaHeadersAsObject[constants.kafkaTraceLevelHeaderNameBinary]) { | ||
const traceLevelBuffer = instanaHeadersAsObject[constants.kafkaTraceLevelHeaderNameBinary]; | ||
if (instanaHeadersAsObject[constants.kafkaLegacyTraceLevelHeaderName]) { | ||
const traceLevelBuffer = instanaHeadersAsObject[constants.kafkaLegacyTraceLevelHeaderName]; | ||
if (Buffer.isBuffer(traceLevelBuffer) && traceLevelBuffer.length >= 1) { | ||
@@ -387,8 +386,8 @@ return String(traceLevelBuffer.readInt8()); | ||
headers = [ | ||
{ [constants.kafkaTraceContextHeaderNameBinary]: tracingUtil.renderTraceContextToBuffer(span) }, | ||
{ [constants.kafkaTraceLevelHeaderNameBinary]: constants.kafkaTraceLevelBinaryValueInherit } | ||
{ [constants.kafkaLegacyTraceContextHeaderName]: tracingUtil.renderTraceContextToBuffer(span) }, | ||
{ [constants.kafkaLegacyTraceLevelHeaderName]: constants.kafkaLegacyTraceLevelValueInherit } | ||
]; | ||
} else if (headers && Array.isArray(headers)) { | ||
headers.push({ [constants.kafkaTraceContextHeaderNameBinary]: tracingUtil.renderTraceContextToBuffer(span) }); | ||
headers.push({ [constants.kafkaTraceLevelHeaderNameBinary]: constants.kafkaTraceLevelBinaryValueInherit }); | ||
headers.push({ [constants.kafkaLegacyTraceContextHeaderName]: tracingUtil.renderTraceContextToBuffer(span) }); | ||
headers.push({ [constants.kafkaLegacyTraceLevelHeaderName]: constants.kafkaLegacyTraceLevelValueInherit }); | ||
} | ||
@@ -401,10 +400,10 @@ return headers; | ||
headers = [ | ||
{ [constants.kafkaTraceIdHeaderNameString]: span.t }, | ||
{ [constants.kafkaSpanIdHeaderNameString]: span.s }, | ||
{ [constants.kafkaTraceLevelHeaderNameString]: '1' } | ||
{ [constants.kafkaTraceIdHeaderName]: leftPad(span.t, 32) }, | ||
{ [constants.kafkaSpanIdHeaderName]: span.s }, | ||
{ [constants.kafkaTraceLevelHeaderName]: '1' } | ||
]; | ||
} else if (headers && Array.isArray(headers)) { | ||
headers.push({ [constants.kafkaTraceIdHeaderNameString]: span.t }); | ||
headers.push({ [constants.kafkaSpanIdHeaderNameString]: span.s }); | ||
headers.push({ [constants.kafkaTraceLevelHeaderNameString]: '1' }); | ||
headers.push({ [constants.kafkaTraceIdHeaderName]: leftPad(span.t, 32) }); | ||
headers.push({ [constants.kafkaSpanIdHeaderName]: span.s }); | ||
headers.push({ [constants.kafkaTraceLevelHeaderName]: '1' }); | ||
} | ||
@@ -434,7 +433,7 @@ return headers; | ||
{ | ||
[constants.kafkaTraceLevelHeaderNameBinary]: constants.kafkaTraceLevelBinaryValueSuppressed | ||
[constants.kafkaLegacyTraceLevelHeaderName]: constants.kafkaLegacyTraceLevelValueSuppressed | ||
} | ||
]; | ||
} else if (headers && typeof Array.isArray(headers)) { | ||
headers.push({ [constants.kafkaTraceLevelHeaderNameBinary]: constants.kafkaTraceLevelBinaryValueSuppressed }); | ||
headers.push({ [constants.kafkaLegacyTraceLevelHeaderName]: constants.kafkaLegacyTraceLevelValueSuppressed }); | ||
} | ||
@@ -448,7 +447,7 @@ return headers; | ||
{ | ||
[constants.kafkaTraceLevelHeaderNameString]: '0' | ||
[constants.kafkaTraceLevelHeaderName]: '0' | ||
} | ||
]; | ||
} else if (headers && Array.isArray(headers)) { | ||
headers.push({ [constants.kafkaTraceLevelHeaderNameString]: '0' }); | ||
headers.push({ [constants.kafkaTraceLevelHeaderName]: '0' }); | ||
} | ||
@@ -460,2 +459,3 @@ return headers; | ||
let traceId; | ||
let longTraceId; | ||
let parentSpanId; | ||
@@ -465,10 +465,15 @@ let level; | ||
// CASE: Look for the the newer string header format first. | ||
if (instanaHeadersAsObject[constants.kafkaTraceIdHeaderNameString]) { | ||
traceId = String(instanaHeadersAsObject[constants.kafkaTraceIdHeaderNameString]); | ||
if (instanaHeadersAsObject[constants.kafkaTraceIdHeaderName]) { | ||
traceId = String(instanaHeadersAsObject[constants.kafkaTraceIdHeaderName]); | ||
if (traceId) { | ||
const limited = limitTraceId({ traceId }); | ||
traceId = limited.traceId; | ||
longTraceId = limited.longTraceId; | ||
} | ||
} | ||
if (instanaHeadersAsObject[constants.kafkaSpanIdHeaderNameString]) { | ||
parentSpanId = String(instanaHeadersAsObject[constants.kafkaSpanIdHeaderNameString]); | ||
if (instanaHeadersAsObject[constants.kafkaSpanIdHeaderName]) { | ||
parentSpanId = String(instanaHeadersAsObject[constants.kafkaSpanIdHeaderName]); | ||
} | ||
if (instanaHeadersAsObject[constants.kafkaTraceLevelHeaderNameString]) { | ||
level = String(instanaHeadersAsObject[constants.kafkaTraceLevelHeaderNameString]); | ||
if (instanaHeadersAsObject[constants.kafkaTraceLevelHeaderName]) { | ||
level = String(instanaHeadersAsObject[constants.kafkaTraceLevelHeaderName]); | ||
} | ||
@@ -479,4 +484,4 @@ | ||
// The newer string header format has not been found, fall back to legacy binary headers. | ||
if (instanaHeadersAsObject[constants.kafkaTraceContextHeaderNameBinary]) { | ||
const traceContextBuffer = instanaHeadersAsObject[constants.kafkaTraceContextHeaderNameBinary]; | ||
if (instanaHeadersAsObject[constants.kafkaLegacyTraceContextHeaderName]) { | ||
const traceContextBuffer = instanaHeadersAsObject[constants.kafkaLegacyTraceContextHeaderName]; | ||
@@ -493,3 +498,3 @@ if (Buffer.isBuffer(traceContextBuffer) && traceContextBuffer.length === 24) { | ||
return { level, traceId, parentSpanId }; | ||
return { level, traceId, longTraceId, parentSpanId }; | ||
} |
@@ -174,8 +174,10 @@ /* | ||
span.data.http = span.data.http || {}; | ||
span.data.http.status = res.statusCode; | ||
span.data.http.header = httpCommon.mergeExtraHeadersFromServerResponseOrClientResponse( | ||
span.data.http.header, | ||
res, | ||
extraHttpHeadersToCapture | ||
); | ||
if (res.headersSent) { | ||
span.data.http.status = res.statusCode; | ||
span.data.http.header = httpCommon.mergeExtraHeadersFromServerResponseOrClientResponse( | ||
span.data.http.header, | ||
res, | ||
extraHttpHeadersToCapture | ||
); | ||
} | ||
@@ -182,0 +184,0 @@ if (!span.postponeTransmit) { |
@@ -58,4 +58,2 @@ /* | ||
function leftPad(str, len) { | ||
// use '0' as the padding char, always | ||
let ch = '0'; | ||
// `len` is the `pad`'s length now | ||
@@ -67,2 +65,5 @@ len -= str.length; | ||
if (len < 33) return cache[len] + str; | ||
// use '0' as the padding char, always | ||
let ch = '0'; | ||
// `pad` starts with an empty string | ||
@@ -69,0 +70,0 @@ let pad = ''; |
@@ -135,7 +135,7 @@ /* | ||
}; | ||
return limitTraceId(result); | ||
return exports.limitTraceId(result); | ||
} else if (xInstanaT && xInstanaS) { | ||
// X-INSTANA- headers are present but W3C trace context headers are not. Use the received IDs and also create a W3C | ||
// trace context based on those IDs. | ||
return limitTraceId({ | ||
return exports.limitTraceId({ | ||
traceId: /** @type {string} */ (xInstanaT), | ||
@@ -168,3 +168,3 @@ parentId: /** @type {string} */ (xInstanaS), | ||
} | ||
return limitTraceId({ | ||
return exports.limitTraceId({ | ||
traceId: !isSuppressed(level) ? w3cTraceContext.traceParentTraceId : null, | ||
@@ -197,3 +197,3 @@ parentId: !isSuppressed(level) ? w3cTraceContext.traceParentParentId : null, | ||
} | ||
return limitTraceId({ | ||
return exports.limitTraceId({ | ||
traceId, | ||
@@ -216,3 +216,3 @@ parentId, | ||
// header on outgoing requests, even if we didn't sample and it has to have a parent ID field. | ||
return limitTraceId({ | ||
return exports.limitTraceId({ | ||
usedTraceParent: false, | ||
@@ -232,3 +232,3 @@ level, | ||
w3cTraceContext = w3c.create(xInstanaT, '0000000000000000', true); | ||
return limitTraceId({ | ||
return exports.limitTraceId({ | ||
traceId: xInstanaT, | ||
@@ -369,3 +369,3 @@ parentId: null, | ||
*/ | ||
function limitTraceId(result) { | ||
exports.limitTraceId = function limitTraceId(result) { | ||
if (result.traceId && result.traceId.length >= 32) { | ||
@@ -376,3 +376,3 @@ result.longTraceId = result.traceId; | ||
return result; | ||
} | ||
}; | ||
@@ -379,0 +379,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
633545
17414