Skip to content
This repository was archived by the owner on Oct 3, 2023. It is now read-only.

Commit e1078b1

Browse files
tcolgatekjin
authored andcommitted
fix: detect HTTP client request errors. (#73)
1 parent 64e0402 commit e1078b1

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

  • packages/opencensus-instrumentation-http/src

packages/opencensus-instrumentation-http/src/http.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,14 @@ export class HttpPlugin extends BasePlugin {
313313
});
314314
});
315315

316+
request.on('error', error => {
317+
span.addAttribute(HttpPlugin.ATTRIBUTE_HTTP_ERROR_NAME, error.name);
318+
span.addAttribute(
319+
HttpPlugin.ATTRIBUTE_HTTP_ERROR_MESSAGE, error.message);
320+
span.status = TraceStatusCodes.UNKNOWN;
321+
span.end();
322+
});
323+
316324
plugin.logger.debug('makeRequestTrace retun request');
317325
return request;
318326
};

0 commit comments

Comments
 (0)