Record exceptions for top level OTel span
If there is an exception in the code, the cli_main function captures it, saves the traceback and exits the process. With the original tracing span, the instrumentation never saw the actual exception, only SystemExit. This meant the span was not recorded as failed. (Technically python-opentelemetry 1.31.0 does record it, but that change was reverted in 1.32.0.) It is somewhat tricky to structure the code so that the exception is recorded implicitly. The status update to DOOMED must happen inside the span (in order to propagate it to the trace). Thus a new function is exported from the tracing module to record the exception explicitly before it gets discarded and replaced with the exit. Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
16eda470c9
commit
d3630bfa6f
2 changed files with 15 additions and 0 deletions
|
|
@ -651,6 +651,7 @@ def cli_main():
|
|||
try:
|
||||
main()
|
||||
except (Exception, KeyboardInterrupt) as ex:
|
||||
tracing.record_exception(ex)
|
||||
if COMPOSE:
|
||||
COMPOSE.log_error("Compose run failed: %s" % ex)
|
||||
COMPOSE.traceback(show_locals=getattr(ex, "show_locals", True))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue