Skip to content

Commit c63450c

Browse files
committed
Improve checking logic for undefineds
1 parent 2025567 commit c63450c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,9 @@ export class AwsLambdaInstrumentation extends InstrumentationBase<AwsLambdaInstr
437437

438438
private static _extractFullUrl(event: any): string | undefined {
439439
// API gateway encodes a lot of url information in various places to recompute this
440-
440+
if (!event.headers) {
441+
return undefined;
442+
}
441443
// Helper function to deal with case variations (instead of making a tolower() copy of the headers)
442444
function findAny(
443445
event: any,
@@ -449,7 +451,7 @@ export class AwsLambdaInstrumentation extends InstrumentationBase<AwsLambdaInstr
449451
const host = findAny(event, 'host', 'Host');
450452
const proto = findAny(event, 'x-forwarded-proto', 'X-Forwarded-Proto');
451453
const port = findAny(event, 'x-forwarded-port', 'X-Forwarded-Port');
452-
if (!(event.headers && (event.path || event.rawPath) && host && proto)) {
454+
if (!(proto && host && (event.path || event.rawPath))) {
453455
return undefined;
454456
}
455457
let answer = proto + '://' + host;

0 commit comments

Comments
 (0)