Skip to content

Commit c5c48a2

Browse files
author
Dilyan Marinov
committed
vdk-core: add log stacktrace flag
Why? When we log the stack trace, we're logging exceptions that we've already logged during execution. This increases the logs length by about 30%. What? Add flag that disables/enables logging the stack trace on exit code 1 How has this been tested? Ran vdk locally with a failing data job What type of change are you making? Feature/non-breaking
1 parent 5b4f07b commit c5c48a2

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

projects/vdk-core/src/vdk/internal/builtin_plugins/config/vdk_config.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
LOG_CONFIG = "LOG_CONFIG"
2121
LOG_LEVEL_VDK = "LOG_LEVEL_VDK"
2222
LOG_LEVEL_MODULE = "LOG_LEVEL_MODULE"
23+
LOG_STACK_TRACE_ON_EXIT = "LOG_STACK_TRACE_ON_EXIT"
2324
WORKING_DIR = "WORKING_DIR"
2425
ATTEMPT_ID = "ATTEMPT_ID"
2526
EXECUTION_ID = "EXECUTION_ID"
@@ -83,6 +84,13 @@ def vdk_configure(self, config_builder: ConfigurationBuilder) -> None:
8384
"Allowed values: CRITICAL, ERROR, WARNING, INFO, DEBUG. "
8485
"If not set python default or one set by vdk -v LEVEL is used. ",
8586
)
87+
config_builder.add(
88+
LOG_STACK_TRACE_ON_EXIT,
89+
False,
90+
True,
91+
"Controls whether the full stack trace is displayed again on exit code 1. "
92+
"False by default, shoud be set to true in production environments for more debug output. ",
93+
)
8694
config_builder.add(JOB_GITHASH, "unknown")
8795
config_builder.add(
8896
OP_ID,

projects/vdk-core/src/vdk/internal/cli_entry.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ def vdk_main(
153153
# if at least one hook implementation returned handled, means we do
154154
# not need to log the exception
155155
if not (True in handled):
156-
log.exception("Exiting with exception.")
156+
if core_context.configuration.get_value("LOG_STACK_TRACE_ON_EXIT"):
157+
log.exception("Exiting with exception.")
157158
exit_code = 1
158159
else:
159160
exit_code = 0

0 commit comments

Comments
 (0)