Skip to content

Commit 64cd18f

Browse files
committed
feat(tracing): track post CommandSequence work
1 parent 983fe15 commit 64cd18f

File tree

2 files changed

+36
-34
lines changed

2 files changed

+36
-34
lines changed

demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
) as manager:
8181
# Visits the sites
8282
for index, site in enumerate(sites):
83-
with _tracer.start_as_current_span(name="command_issuing"):
83+
with _tracer.start_as_current_span("command_issuing"):
8484
span = trace.get_current_span()
8585

8686
def callback(success: bool, val: str = site) -> None:

openwpm/browser_manager.py

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -506,43 +506,44 @@ def execute_command_sequence(
506506
success=False, visit_id=self.curr_visit_id
507507
)
508508
break
509+
with _tracer.start_as_current_span("post_cs_chores"):
510+
self.logger.info(
511+
"Finished working on CommandSequence with "
512+
"visit_id %d on browser with id %d",
513+
self.curr_visit_id,
514+
self.browser_id,
515+
)
516+
# Sleep after executing CommandSequence to provide extra time for
517+
# internal buffers to drain. Stopgap in support of #135
518+
time.sleep(2)
509519

510-
self.logger.info(
511-
"Finished working on CommandSequence with "
512-
"visit_id %d on browser with id %d",
513-
self.curr_visit_id,
514-
self.browser_id,
515-
)
516-
# Sleep after executing CommandSequence to provide extra time for
517-
# internal buffers to drain. Stopgap in support of #135
518-
time.sleep(2)
519-
520-
if task_manager.closing:
521-
return
522-
523-
# Allow StorageWatchdog to utilize built-in browser reset functionality
524-
# which results in a graceful restart of the browser instance
525-
if self.browser_params.maximum_profile_size:
526-
assert self.current_profile_path is not None
520+
if task_manager.closing:
521+
return
527522

528-
reset = profile_size_exceeds_max_size(
529-
self.current_profile_path,
530-
self.browser_params.maximum_profile_size,
531-
)
523+
# Allow StorageWatchdog to utilize built-in browser reset functionality
524+
# which results in a graceful restart of the browser instance
525+
if self.browser_params.maximum_profile_size:
526+
assert self.current_profile_path is not None
532527

533-
if self.restart_required or reset:
534-
success = self.restart_browser_manager(clear_profile=reset)
535-
if not success:
536-
self.logger.critical(
537-
"BROWSER %i: Exceeded the maximum allowable consecutive "
538-
"browser launch failures. Setting failure_status." % self.browser_id
528+
reset = profile_size_exceeds_max_size(
529+
self.current_profile_path,
530+
self.browser_params.maximum_profile_size,
539531
)
540-
task_manager.failure_status = {
541-
"ErrorType": "ExceedLaunchFailureLimit",
542-
"CommandSequence": command_sequence,
543-
}
544-
return
545-
self.restart_required = False
532+
533+
if self.restart_required or reset:
534+
success = self.restart_browser_manager(clear_profile=reset)
535+
if not success:
536+
self.logger.critical(
537+
"BROWSER %i: Exceeded the maximum allowable consecutive "
538+
"browser launch failures. Setting failure_status."
539+
% self.browser_id
540+
)
541+
task_manager.failure_status = {
542+
"ErrorType": "ExceedLaunchFailureLimit",
543+
"CommandSequence": command_sequence,
544+
}
545+
return
546+
self.restart_required = False
546547

547548
def _unpack_pickled_error(self, pickled_error: bytes) -> Tuple[str, str]:
548549
"""Unpacks `pickled_error` into an error `message` and `tb` string."""
@@ -677,6 +678,7 @@ def __init__(
677678
crash_recovery: bool,
678679
) -> None:
679680
super().__init__()
681+
self.name = "BrowserManager"
680682
self.logger = logging.getLogger("openwpm")
681683
self.command_queue = command_queue
682684
self.status_queue = status_queue

0 commit comments

Comments
 (0)