You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/05/26 10:53:05 UTC

[GitHub] [superset] dpgaspar commented on a diff in pull request #20158: feat: add statsd metrics for notifications

dpgaspar commented on code in PR #20158:
URL: https://github.com/apache/superset/pull/20158#discussion_r882549929


##########
superset/utils/decorators.py:
##########
@@ -32,6 +32,27 @@
     from superset.stats_logger import BaseStatsLogger
 
 
+def statsd_gauge(metric_prefix: Optional[str] = None) -> Callable[..., Any]:
+    def decorate(f: Callable[..., Any]) -> Callable[..., Any]:
+        """
+        Handle sending statsd gauge metric from any method or function
+        """
+
+        def wrapped(*args: Any, **kwargs: Any) -> Any:
+            metric_prefix_ = metric_prefix or f.__name__
+            try:
+                result = f(*args, **kwargs)
+                current_app.config["STATS_LOGGER"].gauge(f"{metric_prefix_}.ok", 1)

Review Comment:
   yes, when creating a custom statsd logger class



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org