Skip to content

Commit

Permalink
chore: adapt pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
abhilash-sivan committed Dec 24, 2024
1 parent 5e80c7b commit 94bd095
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
8 changes: 4 additions & 4 deletions packages/collector/src/agentConnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,11 @@ exports.sendSpans = function sendSpans(spans, cb) {
if (err && !maxContentErrorHasBeenLogged && err instanceof PayloadTooLargeError) {
logLargeSpans(spans);
} else if (err) {
const obj = getSpanLengthInfo(spans);
logger.debug({ obj }, 'Failed to transmit.');
const spanInfo = getSpanLengthInfo(spans);
logger.debug({ spanInfo }, 'Failed to send.');
} else {
const obj = getSpanLengthInfo(spans);
logger.debug({ obj }, 'Successfully transmitted');
const spanInfo = getSpanLengthInfo(spans);
logger.debug({ spanInfo }, 'Successfully sent');
}
cb(err);
});
Expand Down
7 changes: 2 additions & 5 deletions packages/collector/src/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ try {
// thread (0).
}

const { uninstrumentedLogger: pinoCopy } = require('@instana/core');

const pino = pinoCopy;
const { uninstrumentedLogger: pino } = require('@instana/core');

const { logger } = require('@instana/core');
const pinoToAgentStream = require('./agent/loggerToAgentStream');
Expand Down Expand Up @@ -55,8 +53,7 @@ exports.init = function init(config, isReInit) {
write(chunk) {
consoleStream.write(chunk);

const logRecord = JSON.parse(chunk);
pinoToAgentStream.write(logRecord);
pinoToAgentStream.write(chunk);
}
};

Expand Down
7 changes: 7 additions & 0 deletions packages/core/src/tracing/instrumentation/loggers/bunyan.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ function instrument(Logger) {
function shimLog(markAsError) {
return originalLog =>
function () {
if (arguments.length === 0) {
// * arguments.length === 0 -> This is a logger.warn() type of call (without arguments), this will not log
// anything but simply return whether the log level in question is enabled for this logger.
// * this.fields.__in -> This is one of Instana's own loggers, we never want to trace those log calls.
return originalLog.apply(this, arguments);
}

if (cls.skipExitTracing({ isActive, skipAllowRootExitSpanPresence: true })) {
return originalLog.apply(this, arguments);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/uninstrumentedLogger.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
const logger = require('pino');

function createCustomLogger() {
const customPino = Object.assign(function (/** @type {any} */ ...args) {
const customLogger = Object.assign(function (/** @type {any} */ ...args) {
// @ts-ignore
return logger(...args);
}, logger);

return customPino;
return customLogger;
}

module.exports = createCustomLogger();

0 comments on commit 94bd095

Please sign in to comment.