From db215b121087ca99ee5c0f1356f08bc0b8a82462 Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Thu, 18 May 2017 16:33:28 -0700 Subject: [PATCH 1/2] Logging a few more actions --- superset/views/core.py | 2 ++ superset/viz.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/superset/views/core.py b/superset/views/core.py index 8618e70d0398..069b5ab1eb4a 100755 --- a/superset/views/core.py +++ b/superset/views/core.py @@ -46,6 +46,7 @@ ) 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 @@ def fetch_datasource_metadata(self): @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 bc147bb82d93..102612022621 100755 --- a/superset/viz.py +++ b/superset/viz.py @@ -31,6 +31,7 @@ from superset.utils import DTTM_ALIAS config = app.config +stats_logger = config.get('STATS_LOGGER') class BaseViz(object): @@ -214,6 +215,7 @@ def get_payload(self, force=False): 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 @@ def get_payload(self, force=False): logging.info("Serving from cache") if not payload: + stats_logger.incr('loaded_from_cache') data = None is_cached = False cache_timeout = self.cache_timeout From fb4846ad29855e854b84ddd1b9d44ce77012af4f Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Thu, 18 May 2017 17:19:22 -0700 Subject: [PATCH 2/2] adding statsd dep --- dev-reqs.txt | 1 + superset/stats_logger.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/dev-reqs.txt b/dev-reqs.txt index e3c2aa03f2f7..370aaa11e8cd 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 0203adc330d3..b79cc8ffa70d 100644 --- a/superset/stats_logger.py +++ b/superset/stats_logger.py @@ -52,6 +52,8 @@ def decr(self, key): self.client.decr(key) def gauge(self, key): + # pylint: disable=no-value-for-parameter self.client.gauge(key) + except Exception as e: pass