Skip to content

Commit

Permalink
fix: added log to capture instana headers from incoming request
Browse files Browse the repository at this point in the history
  • Loading branch information
aryamohanan committed Oct 4, 2024
1 parent 13f73e8 commit 89c3051
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions packages/core/src/tracing/instrumentation/protocols/httpServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ const {
} = require('./captureHttpHeadersUtil');
const shimmer = require('../../shimmer');
const cls = require('../../cls');

let logger;
logger = require('../../../logger').getLogger('tracing/httpServer', newLogger => {
logger = newLogger;
});
let extraHttpHeadersToCapture;
let isActive = false;

Expand Down Expand Up @@ -65,7 +68,7 @@ function shimEmit(realEmit) {
if (res && res.on && res.addListener && res.emit) {
cls.ns.bindEmitter(res);
}

logInstanaHeaders(req);
const headers = tracingHeaders.fromHttpRequest(req);
const w3cTraceContext = headers.w3cTraceContext;

Expand Down Expand Up @@ -203,3 +206,12 @@ function shimEmit(realEmit) {
});
};
}
function logInstanaHeaders(req) {
if (req.headers) {
Object.keys(req.headers).forEach(header => {
if (header?.toLowerCase()?.startsWith('x-instana')) {
logger.debug(`Instana header found in the request: ${header}: ${req.headers[header]}`);
}
});
}
}

0 comments on commit 89c3051

Please sign in to comment.