Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
span.setAttributes({
[AttributeNames.HTTP_ERROR_NAME]: error.name,
[AttributeNames.HTTP_ERROR_MESSAGE]: message,
});
if (!obj) {
span.setStatus({ code: CanonicalCode.UNKNOWN, message });
return;
}
let status: Status;
if ((obj as IncomingMessage).statusCode) {
status = parseResponseStatus((obj as IncomingMessage).statusCode!);
} else if ((obj as ClientRequest).aborted) {
status = { code: CanonicalCode.ABORTED };
} else {
status = { code: CanonicalCode.UNKNOWN };
}
status.message = message;
span.setStatus(status);
};
response.on('end', () => {
this._logger.debug('outgoingRequest on end()');
if (response.statusCode) {
span.setAttributes({
[AttributeNames.HTTP_STATUS_CODE]: response.statusCode,
[AttributeNames.HTTP_STATUS_TEXT]: response.statusMessage,
});
}
if (response.aborted && !response.complete) {
span.setStatus({ code: CanonicalCode.ABORTED });
} else {
span.setStatus(Utils.parseResponseStatus(response.statusCode!));
}
if (this._config.applyCustomAttributesOnSpan) {
this._config.applyCustomAttributesOnSpan(span, request, response);
}
span.end();
});
Utils.setSpanOnError(span, response);