Skip to content

Commit

Permalink
Logging a few more actions (#2783)
Browse files Browse the repository at this point in the history
* Logging a few more actions

* adding statsd dep
  • Loading branch information
mistercrunch authored May 19, 2017
1 parent 922cc03 commit ce506bd
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions dev-reqs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ psycopg2
pylint
pythrifthiveapi
pyyaml
statsd
# Also install everything we need to build Sphinx docs
-r dev-reqs-for-docs.txt
2 changes: 2 additions & 0 deletions superset/stats_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions superset/views/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -2091,6 +2092,7 @@ def fetch_datasource_metadata(self):
@expose("/queries/<last_updated_ms>")
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)
Expand Down
3 changes: 3 additions & 0 deletions superset/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from superset.utils import DTTM_ALIAS

config = app.config
stats_logger = config.get('STATS_LOGGER')


class BaseViz(object):
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit ce506bd

Please sign in to comment.