From ce506bdf65b46f5bccee84ca8254417f63b124a5 Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Fri, 19 May 2017 10:25:58 -0700 Subject: [PATCH] Logging a few more actions (#2783) * Logging a few more actions * adding statsd dep --- dev-reqs.txt | 1 + superset/stats_logger.py | 2 ++ superset/views/core.py | 2 ++ superset/viz.py | 3 +++ 4 files changed, 8 insertions(+) diff --git a/dev-reqs.txt b/dev-reqs.txt index e3c2aa03f..370aaa11e 100644 --- a/dev-reqs.txt +++ b/dev-reqs.txt @@ -9,5 +9,6 @@ psycopg2 pylint pythrifthiveapi pyyaml +statsd # Also install everything we need to build Sphinx docs -r dev-reqs-for-docs.txt diff --git a/superset/stats_logger.py b/superset/stats_logger.py index 0203adc33..b79cc8ffa 100644 --- a/superset/stats_logger.py +++ b/superset/stats_logger.py @@ -52,6 +52,8 @@ try: self.client.decr(key) def gauge(self, key): + # pylint: disable=no-value-for-parameter self.client.gauge(key) + except Exception as e: pass diff --git a/superset/views/core.py b/superset/views/core.py index 8618e70d0..069b5ab1e 100755 --- a/superset/views/core.py +++ b/superset/views/core.py @@ -46,6 +46,7 @@ from .base import ( ) config = app.config +stats_logger = config.get('STATS_LOGGER') log_this = models.Log.log_this can_access = utils.can_access DAR = models.DatasourceAccessRequest @@ -2091,6 +2092,7 @@ class Superset(BaseSupersetView): @expose("/queries/") def queries(self, last_updated_ms): """Get the updated queries.""" + stats_logger.incr('queries') if not g.user.get_id(): return json_error_response( "Please login to access the queries.", status=403) diff --git a/superset/viz.py b/superset/viz.py index bc147bb82..102612022 100755 --- a/superset/viz.py +++ b/superset/viz.py @@ -31,6 +31,7 @@ from superset import app, utils, cache from superset.utils import DTTM_ALIAS config = app.config +stats_logger = config.get('STATS_LOGGER') class BaseViz(object): @@ -214,6 +215,7 @@ class BaseViz(object): payload = cache.get(cache_key) if payload: + stats_logger.incr('loaded_from_source') is_cached = True try: cached_data = zlib.decompress(payload) @@ -227,6 +229,7 @@ class BaseViz(object): logging.info("Serving from cache") if not payload: + stats_logger.incr('loaded_from_cache') data = None is_cached = False cache_timeout = self.cache_timeout