refactor: improve logging from http integration (#946)

This commit is contained in:
Alex Christoffer Rasmussen
2024-05-11 14:23:07 +02:00
committed by GitHub
parent 7da3480dfe
commit b2668e61a5
@@ -51,7 +51,24 @@ export class HttpIntegration implements IIntegration<HttpSubscription, HttpSetti
emit(path: string) {
got.get(path, { retry: { limit: 0 } }).catch((err) => {
logger.error(LogOrigin.Tx, `HTTP Integration: ${err.code}`);
logger.warning(LogOrigin.Tx, `HTTP Integration: ${err.message}`);
if (err.code === 'ECONNREFUSED') {
logger.warning(LogOrigin.Tx, `HTTP Integration: '${err.code}' The server refused the connection`);
return;
}
if (err.code === 'ENOTFOUND') {
logger.warning(LogOrigin.Tx, `HTTP Integration: '${err.code}' DNS lookup failed`);
return;
}
if (err.code === 'ETIMEDOUT') {
logger.warning(LogOrigin.Tx, `HTTP Integration: '${err.code}' The connection timed out`);
return;
}
logger.warning(LogOrigin.Tx, `HTTP Integration: ${err.code}`);
});
}