From d8bf0ce377115eeaa6c186f6447072a06f45055a Mon Sep 17 00:00:00 2001 From: athirasomanath <144906220+athirasomanath@users.noreply.github.com> Date: Fri, 20 Oct 2023 16:45:01 +0530 Subject: [PATCH] fix(rdkafka): only log warning about header format once (#897) --- .../src/tracing/instrumentation/messaging/rdkafka.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/core/src/tracing/instrumentation/messaging/rdkafka.js b/packages/core/src/tracing/instrumentation/messaging/rdkafka.js index a9e9a931ec..3e340e05d4 100644 --- a/packages/core/src/tracing/instrumentation/messaging/rdkafka.js +++ b/packages/core/src/tracing/instrumentation/messaging/rdkafka.js @@ -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 => { @@ -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; };