Skip to content

Commit

Permalink
Add trace ID to clipboard debug info and title bar (#9157)
Browse files Browse the repository at this point in the history
  • Loading branch information
HakonSohoel authored Nov 12, 2024
1 parent e50f2d3 commit efb812c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/ert/gui/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from ert.gui.tools.plugins import PluginHandler, PluginsTool
from ert.gui.tools.workflows import WorkflowsTool
from ert.plugins import ErtPluginManager
from ert.trace import get_trace_id

BUTTON_STYLE_SHEET: str = """
QToolButton {
Expand Down Expand Up @@ -78,7 +79,9 @@ def __init__(
self.config_file = config_file
self.log_handler = log_handler

self.setWindowTitle(f"ERT - {config_file} - {find_ert_info()}")
self.setWindowTitle(
f"ERT - {config_file} - {find_ert_info()} - {get_trace_id()[:8]}"
)
self.plugin_manager = plugin_manager
self.central_widget = QFrame(self)
self.central_layout = QHBoxLayout(self.central_widget)
Expand Down
2 changes: 2 additions & 0 deletions src/ert/gui/simulation/experiment_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
format_running_time,
get_ert_memory_usage,
)
from ert.trace import get_trace_id

from ..summarypanel import SummaryPanel
from .combobox_with_description import QComboBoxWithDescription
Expand Down Expand Up @@ -385,6 +386,7 @@ def populate_clipboard_debug_info(self) -> None:
kv[field.name.replace("_", " ").capitalize()] = str(field_value)

kv["**Status**"] = ""
kv["Trace ID"] = get_trace_id()
kv["Running time"] = (
format_running_time(self._model.get_runtime()).split(":")[1].strip()
)
Expand Down
4 changes: 4 additions & 0 deletions src/ert/trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@
trace.set_tracer_provider(tracer_provider)

tracer = trace.get_tracer("ert.main")


def get_trace_id() -> str:
return trace.format_trace_id(trace.get_current_span().get_span_context().trace_id)
7 changes: 6 additions & 1 deletion tests/ert/unit_tests/gui/simulation/test_run_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,12 @@ def test_that_debug_info_button_provides_data_in_clipboard(qtbot: QtBot, storage

clipboard_text = QApplication.clipboard().text()

for keyword in ["Single realization test-run", "Local", r"minimal\_config.ert"]:
for keyword in [
"Single realization test-run",
"Local",
r"minimal\_config.ert",
"Trace ID",
]:
assert keyword in clipboard_text


Expand Down

0 comments on commit efb812c

Please sign in to comment.