Skip to content

Commit

Permalink
fix(rdkafka): only log warning about header format once (#897)
Browse files Browse the repository at this point in the history
  • Loading branch information
athirasomanath authored Oct 20, 2023
1 parent c078492 commit d8bf0ce
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/core/src/tracing/instrumentation/messaging/rdkafka.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const cls = require('../../cls');
const shimmer = require('../../shimmer');
const { getFunctionArguments } = require('../../../util/function_arguments');
let traceCorrelationEnabled = constants.kafkaTraceCorrelationDefault;
let configHeader = null;

let logger;
logger = require('../../../logger').getLogger('tracing/rdkafka', newLogger => {
Expand All @@ -27,21 +28,23 @@ exports.init = function init(config) {
requireHook.onModuleLoad('node-rdkafka', instrumentConsumer);

traceCorrelationEnabled = config.tracing.kafka.traceCorrelation;
logWarningForKafkaHeaderFormat(config.tracing.kafka.headerFormat);
configHeader = config.tracing.kafka.headerFormat;
};

exports.updateConfig = function updateConfig(config) {
traceCorrelationEnabled = config.tracing.kafka.traceCorrelation;
logWarningForKafkaHeaderFormat(config.tracing.kafka.headerFormat);
configHeader = config.tracing.kafka.headerFormat;
};

// The extraConfig is coming from the agent configs. You can set the kafka format in the agent.
exports.activate = function activate(extraConfig) {
let extraConfigHeader = null;
if (extraConfig && extraConfig.tracing && extraConfig.tracing.kafka) {
if (extraConfig.tracing.kafka.traceCorrelation != null) {
traceCorrelationEnabled = extraConfig.tracing.kafka.traceCorrelation;
}
logWarningForKafkaHeaderFormat(extraConfig.tracing.kafka.headerFormat);
extraConfigHeader = extraConfig.tracing.kafka.headerFormat;
}
logWarningForKafkaHeaderFormat(extraConfigHeader || configHeader);
isActive = true;
};

Expand Down

0 comments on commit d8bf0ce

Please sign in to comment.