Skip to content

Commit 9453596

Browse files
committed
Add current module tag to Sentry crash reports
1 parent f29efc4 commit 9453596

4 files changed

Lines changed: 5 additions & 0 deletions

File tree

‎plain2code_state.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def __init__(self, spec_filename: str, replay_with: Optional[str] = None):
2424
self.render_time_accumulated: int = 0
2525
self.last_render_start_timestamp: float = time.monotonic()
2626
# Mirrored from the render state machine for crash reporting; not authoritative.
27+
self.current_module: Optional[str] = None
2728
self.current_frid: Optional[str] = None
2829
self.current_render_state: Optional[str] = None
2930

‎plain2code_telemetry.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ def capture_crash(exc_info, run_state: Optional[RunState], args) -> bool:
9595
with sentry_sdk.new_scope() as scope:
9696
if run_state is not None:
9797
scope.set_tag("render_id", run_state.render_id)
98+
scope.set_tag("current_module", run_state.current_module)
9899
scope.set_tag("current_frid", run_state.current_frid)
99100
scope.set_tag("render_state", run_state.current_render_state)
100101
scope.set_tag("headless", bool(getattr(args, "headless", False)))

‎render_machine/code_renderer.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def __init__(self, render_context: RenderContext):
4242
def run(self):
4343
"""Execute the main rendering workflow."""
4444
self.render_context.event_bus.publish(RenderModuleStarted(module_name=self.render_context.module_name))
45+
self.render_context.run_state.current_module = self.render_context.module_name
4546
previous_action_payload = None
4647
previous_state = None
4748

‎tests/test_telemetry.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ def test_capture_crash_sends_event_with_tags(transport):
7777
init_with_transport(transport)
7878

7979
run_state = RunState(spec_filename="test.plain")
80+
run_state.current_module = "my_module"
8081
run_state.current_frid = "2.1"
8182
run_state.current_render_state = "IMPLEMENTING_FRID"
8283

@@ -86,6 +87,7 @@ def test_capture_crash_sends_event_with_tags(transport):
8687
assert len(transport.events) == 1
8788
tags = transport.events[0]["tags"]
8889
assert tags["render_id"] == run_state.render_id
90+
assert tags["current_module"] == "my_module"
8991
assert tags["current_frid"] == "2.1"
9092
assert tags["render_state"] == "IMPLEMENTING_FRID"
9193
assert tags["headless"] is True

0 commit comments

Comments
 (0)