Skip to content

Commit 15ef6e4

Browse files
committed
Avoid critical-then-exception logs.
While Logger.exception is a handy way of printing stack traces, any log message can include them. Include the stack trace as part of critical logs instead of in a separate message.
1 parent 035abdd commit 15ef6e4

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

python/activator/driver_gunicorn.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,8 @@ def create_app():
9999
app.register_error_handler(500, server_error)
100100
_log.info("Worker ready to handle requests.")
101101
return app
102-
except Exception as e:
103-
_log.critical("Failed to start worker; aborting.")
104-
_log.exception(e)
102+
except Exception:
103+
_log.critical("Failed to start worker; aborting.", exc_info=True)
105104
# gunicorn assumes exit code 3 means "Worker failed to boot", though this is not documented
106105
sys.exit(3)
107106

python/activator/driver_keda.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,8 @@ def keda_start():
297297

298298
_log.info("Worker ready to handle requests.")
299299

300-
except Exception as e:
301-
_log.critical("Failed to start worker; aborting.")
302-
_log.exception(e)
300+
except Exception:
301+
_log.critical("Failed to start worker; aborting.", exc_info=True)
303302
sys.exit(1)
304303

305304
fan_out_listen_start_time = time.time()
@@ -336,9 +335,8 @@ def keda_start():
336335
_log.debug("Seconds since fan out message delivered %r", fan_out_to_prompt_time)
337336

338337
# TODO Review Redis Errors and determine what should be retriable.
339-
except redis.exceptions.RedisError as e:
340-
_log.critical("Redis Streams error; aborting.")
341-
_log.exception(e)
338+
except redis.exceptions.RedisError:
339+
_log.critical("Redis Streams error; aborting.", exc_info=True)
342340
sys.exit(1)
343341
except ValueError as e:
344342
_log.error("Invalid redis stream message %s", e)

0 commit comments

Comments
 (0)