Skip to content

Commit a46f933

Browse files
committed
Return empty array from sqsContextGetter keys method if carrier is null. And fallback to message attribute value if stringValue is undefined
1 parent 2ae0370 commit a46f933

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

plugins/node/opentelemetry-instrumentation-aws-lambda/src/instrumentation.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,15 @@ const headerGetter: TextMapGetter<APIGatewayProxyEventHeaders> = {
7777
},
7878
};
7979

80-
const sqsContextGetter = {
81-
keys(carrier: any): string[] {
82-
return Object.keys(carrier || {});
80+
const sqsContextGetter: TextMapGetter = {
81+
keys(carrier): string[] {
82+
if (carrier == null) {
83+
return [];
84+
}
85+
return Object.keys(carrier);
8386
},
84-
get(carrier: any, key: string) {
85-
return carrier?.[key]?.stringValue;
87+
get(carrier, key: string) {
88+
return carrier?.[key]?.stringValue || carrier?.[key]?.value;
8689
},
8790
};
8891

0 commit comments

Comments
 (0)