Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

More logging

Magnus Müller4a62fe11f916
diff --git a/browser_use/browser/session.py b/browser_use/browser/session.py
index b6ccb06f1..60e8dbd64 100644
--- a/browser_use/browser/session.py
+++ b/browser_use/browser/session.py
@@ -813,6 +813,7 @@ class BrowserSession(BaseModel):
assert self._cdp_client_root is not None, 'CDP client not initialized - browser may not be connected yet'
return self._cdp_client_root
+ @observe_debug(ignore_input=True, ignore_output=True, name='get_or_create_cdp_session')
async def get_or_create_cdp_session(
self, target_id: TargetID | None = None, focus: bool = True, new_socket: bool | None = None
) -> CDPSession:
@@ -1345,6 +1346,7 @@ class BrowserSession(BaseModel):
except Exception as e:
self.logger.debug(f'Skipping proxy auth setup: {type(e).__name__}: {e}')
+ @observe_debug(ignore_input=True, ignore_output=True, name='get_tabs')
async def get_tabs(self) -> list[TabInfo]:
"""Get information about all open tabs using CDP Target.getTargetInfo for speed."""
tabs = []
@@ -1423,6 +1425,7 @@ class BrowserSession(BaseModel):
return target
return None
+ @observe_debug(ignore_input=True, ignore_output=True, name='get_current_page_url')
async def get_current_page_url(self) -> str:
"""Get the URL of the current page using CDP."""
target = await self.get_current_target_info()
diff --git a/browser_use/browser/watchdogs/dom_watchdog.py b/browser_use/browser/watchdogs/dom_watchdog.py
index 2558dc777..10ed2c1fc 100644
--- a/browser_use/browser/watchdogs/dom_watchdog.py
+++ b/browser_use/browser/watchdogs/dom_watchdog.py
@@ -16,6 +16,7 @@ from browser_use.dom.views import (
EnhancedDOMTreeNode,
SerializedDOMState,
)
+from browser_use.observability import observe_debug
if TYPE_CHECKING:
from browser_use.browser.views import BrowserStateSummary, PageInfo
@@ -424,6 +425,7 @@ class DOMWatchdog(BaseWatchdog):
)
raise
+ @observe_debug(ignore_input=True, ignore_output=True, name='build_dom_tree_without_highlights')
async def _build_dom_tree_without_highlights(self, previous_state: SerializedDOMState | None = None) -> SerializedDOMState:
"""Build DOM tree without injecting JavaScript highlights (for parallel execution)."""
try:
@@ -471,6 +473,7 @@ class DOMWatchdog(BaseWatchdog):
)
raise
+ @observe_debug(ignore_input=True, ignore_output=True, name='capture_clean_screenshot')
async def _capture_clean_screenshot(self) -> str:
"""Capture a clean screenshot without JavaScript highlights."""
try:
@@ -524,6 +527,7 @@ class DOMWatchdog(BaseWatchdog):
elapsed = time.time() - start_time
self.logger.debug(f'✅ Page stability wait completed in {elapsed:.2f}s')
+ @observe_debug(ignore_input=True, ignore_output=True, name='get_page_info')
async def _get_page_info(self) -> 'PageInfo':
"""Get comprehensive page information using a single CDP call.