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/08 21:05:28 UTC

(superset) branch log_screenshots created (now 2c815c0cd4)

This is an automated email from the ASF dual-hosted git repository.

maximebeauchemin pushed a change to branch log_screenshots
in repository https://gitbox.apache.org/repos/asf/superset.git


      at 2c815c0cd4 feat: add logging durations for screenshot async service

This branch includes the following new commits:

     new 2c815c0cd4 feat: add logging durations for screenshot async service

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(superset) 01/01: feat: add logging durations for screenshot async service

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

maximebeauchemin pushed a commit to branch log_screenshots
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 2c815c0cd4d87ae0e0fb38bb28cd2c76622e6916
Author: Maxime Beauchemin <ma...@gmail.com>
AuthorDate: Fri Nov 8 13:04:08 2024 -0800

    feat: add logging durations for screenshot async service
    
    Using the event_logger's context manager to log the duration of computing, caching and overall compute_and_cache
---
 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