Skip to content

Commit

Permalink
feat(tracing): track post CommandSequence work
Browse files Browse the repository at this point in the history
  • Loading branch information
vringar committed Feb 21, 2024
1 parent adbd9cc commit b933b4a
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 34 deletions.
2 changes: 1 addition & 1 deletion demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
) as manager:
# Visits the sites
for index, site in enumerate(sites):
with _tracer.start_as_current_span(name="command_issuing"):
with _tracer.start_as_current_span("command_issuing"):
span = trace.get_current_span()

def callback(success: bool, val: str = site) -> None:
Expand Down
68 changes: 35 additions & 33 deletions openwpm/browser_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,43 +506,44 @@ def execute_command_sequence(
success=False, visit_id=self.curr_visit_id
)
break
with _tracer.start_as_current_span("post_cs_chores"):
self.logger.info(
"Finished working on CommandSequence with "
"visit_id %d on browser with id %d",
self.curr_visit_id,
self.browser_id,
)
# Sleep after executing CommandSequence to provide extra time for
# internal buffers to drain. Stopgap in support of #135
time.sleep(2)

self.logger.info(
"Finished working on CommandSequence with "
"visit_id %d on browser with id %d",
self.curr_visit_id,
self.browser_id,
)
# Sleep after executing CommandSequence to provide extra time for
# internal buffers to drain. Stopgap in support of #135
time.sleep(2)

if task_manager.closing:
return

# Allow StorageWatchdog to utilize built-in browser reset functionality
# which results in a graceful restart of the browser instance
if self.browser_params.maximum_profile_size:
assert self.current_profile_path is not None
if task_manager.closing:
return

reset = profile_size_exceeds_max_size(
self.current_profile_path,
self.browser_params.maximum_profile_size,
)
# Allow StorageWatchdog to utilize built-in browser reset functionality
# which results in a graceful restart of the browser instance
if self.browser_params.maximum_profile_size:
assert self.current_profile_path is not None

if self.restart_required or reset:
success = self.restart_browser_manager(clear_profile=reset)
if not success:
self.logger.critical(
"BROWSER %i: Exceeded the maximum allowable consecutive "
"browser launch failures. Setting failure_status." % self.browser_id
reset = profile_size_exceeds_max_size(
self.current_profile_path,
self.browser_params.maximum_profile_size,
)
task_manager.failure_status = {
"ErrorType": "ExceedLaunchFailureLimit",
"CommandSequence": command_sequence,
}
return
self.restart_required = False

if self.restart_required or reset:
success = self.restart_browser_manager(clear_profile=reset)
if not success:
self.logger.critical(
"BROWSER %i: Exceeded the maximum allowable consecutive "
"browser launch failures. Setting failure_status."
% self.browser_id
)
task_manager.failure_status = {
"ErrorType": "ExceedLaunchFailureLimit",
"CommandSequence": command_sequence,
}
return
self.restart_required = False

def _unpack_pickled_error(self, pickled_error: bytes) -> Tuple[str, str]:
"""Unpacks `pickled_error` into an error `message` and `tb` string."""
Expand Down Expand Up @@ -677,6 +678,7 @@ def __init__(
crash_recovery: bool,
) -> None:
super().__init__()
self.name = "BrowserManager"
self.logger = logging.getLogger("openwpm")
self.command_queue = command_queue
self.status_queue = status_queue
Expand Down

0 comments on commit b933b4a

Please sign in to comment.