Skip to content
This repository has been archived by the owner on Jul 10, 2023. It is now read-only.

Commit

Permalink
fix check error logic and check event header
Browse files Browse the repository at this point in the history
  • Loading branch information
fatihaydilek committed Apr 18, 2020
1 parent 1980939 commit 1ab5be6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions src/ThundraWrapper.ts
Expand Up @@ -484,13 +484,14 @@ class ThundraWrapper {

isErrorResponse(result: any) {
let isError = false;
if (Utils.isValidResponse(result) && typeof result.body === 'string') {
const statusCode = result.statusCode.toString();
if (statusCode.startsWith('4') || statusCode.startsWith('5')) {
if (Utils.isValidResponse(result) && result.body) {
if (typeof result.body === 'string') {
if (result.statusCode >= 400 && result.statusCode <= 599) {
isError = true;
}
} else {
isError = true;
}
} else if (Utils.isValidResponse(result)) {
isError = true;
}
return isError;
}
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/Trace.ts
Expand Up @@ -319,7 +319,7 @@ export class Trace {
const lambdaEventType = LambdaEventUtils.getLambdaEventType(originalEvent, originalContext);
if (lambdaEventType === LambdaEventType.Lambda) {
return this.tracer.extract(opentracing.FORMAT_TEXT_MAP, originalContext.clientContext.custom);
} else if (lambdaEventType === LambdaEventType.APIGatewayProxy) {
} else if (lambdaEventType === LambdaEventType.APIGatewayProxy && originalEvent.headers) {
return this.tracer.extract(opentracing.FORMAT_HTTP_HEADERS, originalEvent.headers);
} else if (lambdaEventType === LambdaEventType.SNS) {
return LambdaEventUtils.extractSpanContextFromSNSEvent(this.tracer, originalEvent);
Expand Down

0 comments on commit 1ab5be6

Please sign in to comment.