Skip to content

Commit

Permalink
fix: compare kafka header keys case insensitively
Browse files Browse the repository at this point in the history
  • Loading branch information
seemk committed Sep 27, 2023
1 parent e2a6e39 commit 1a2d86b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/instrumentations/external/kafkajs/kafkajs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 1a2d86b

Please sign in to comment.