diff --git a/src/instrumentations/external/kafkajs/kafkajs.ts b/src/instrumentations/external/kafkajs/kafkajs.ts index 54c020c9..a3436239 100644 --- a/src/instrumentations/external/kafkajs/kafkajs.ts +++ b/src/instrumentations/external/kafkajs/kafkajs.ts @@ -43,7 +43,7 @@ import type { } from 'kafkajs'; import { KafkaJsInstrumentationConfig } from './types'; import { VERSION } from '../../../version'; -import { bufferTextMapGetter } from './propagtor'; +import { bufferTextMapGetter } from './propagator'; import { InstrumentationBase, InstrumentationModuleDefinition, diff --git a/src/instrumentations/external/kafkajs/propagtor.ts b/src/instrumentations/external/kafkajs/propagator.ts similarity index 77% rename from src/instrumentations/external/kafkajs/propagtor.ts rename to src/instrumentations/external/kafkajs/propagator.ts index a5e9d11b..0abe7e8f 100644 --- a/src/instrumentations/external/kafkajs/propagtor.ts +++ b/src/instrumentations/external/kafkajs/propagator.ts @@ -22,7 +22,19 @@ adding toString() to make sure string is returned */ export const bufferTextMapGetter: TextMapGetter = { get(carrier, key) { - return carrier?.[key]?.toString(); + if (carrier === undefined) { + return undefined; + } + + const keys = Object.keys(carrier); + + for (const carrierKey of keys) { + if (carrierKey.toLowerCase() === key) { + return carrier[carrierKey]?.toString(); + } + } + + return undefined; }, keys(carrier) {