You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ma...@apache.org on 2024/11/12 17:54:42 UTC
(superset) branch master updated: feat: add logging durations for screenshot async service (#30884)
This is an automated email from the ASF dual-hosted git repository.
maximebeauchemin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new 4e8eba802a feat: add logging durations for screenshot async service (#30884)
4e8eba802a is described below
commit 4e8eba802a179605405c0c05f906abdbd4f95d1e
Author: Maxime Beauchemin <ma...@gmail.com>
AuthorDate: Tue Nov 12 09:54:33 2024 -0800
feat: add logging durations for screenshot async service (#30884)
---
superset/utils/screenshots.py | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/superset/utils/screenshots.py b/superset/utils/screenshots.py
index b31d9c0e44..96c0f40d6d 100644
--- a/superset/utils/screenshots.py
+++ b/superset/utils/screenshots.py
@@ -24,6 +24,7 @@ from flask import current_app
from superset import feature_flag_manager
from superset.dashboards.permalink.types import DashboardPermalinkState
+from superset.extensions import event_logger
from superset.utils.hashing import md5_sha_from_dict
from superset.utils.urls import modify_url_query
from superset.utils.webdriver import (
@@ -91,7 +92,8 @@ class BaseScreenshot:
self, user: User, window_size: WindowSize | None = None
) -> bytes | None:
driver = self.driver(window_size)
- self.screenshot = driver.get_screenshot(self.url, self.element, user)
+ with event_logger.log_context("screenshot", screenshot_url=self.url):
+ self.screenshot = driver.get_screenshot(self.url, self.element, user)
return self.screenshot
def get(
@@ -169,7 +171,10 @@ class BaseScreenshot:
# Assuming all sorts of things can go wrong with Selenium
try:
- payload = self.get_screenshot(user=user, window_size=window_size)
+ with event_logger.log_context(
+ f"screenshot.compute.{self.thumbnail_type}", force=force
+ ):
+ payload = self.get_screenshot(user=user, window_size=window_size)
except Exception as ex: # pylint: disable=broad-except
logger.warning("Failed at generating thumbnail %s", ex, exc_info=True)
@@ -182,7 +187,10 @@ class BaseScreenshot:
if payload:
logger.info("Caching thumbnail: %s", cache_key)
- cache.set(cache_key, payload)
+ with event_logger.log_context(
+ f"screenshot.cache.{self.thumbnail_type}", force=force
+ ):
+ cache.set(cache_key, payload)
logger.info("Done caching thumbnail")
return payload