-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
841e18a
commit 7c5f61d
Showing
4 changed files
with
64 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,6 @@ | |
down_revision = '979c03af3341' | ||
|
||
|
||
|
||
def upgrade(): | ||
op.add_column( | ||
'query', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
|
||
class BaseStatsLogger(object): | ||
"""Base class for logging realtime events""" | ||
|
||
def __init__(self, prefix='superset'): | ||
self.prefix = prefix | ||
|
||
def key(self, key): | ||
if self.prefix: | ||
return self.prefix + key | ||
return key | ||
|
||
def incr(self, key): | ||
"""Increment a counter""" | ||
raise NotImplementedError() | ||
|
||
def decr(self, key): | ||
"""Decrement a counter""" | ||
raise NotImplementedError() | ||
|
||
def gauge(self, key): | ||
"""Setup a gauge""" | ||
raise NotImplementedError() | ||
|
||
|
||
class DummyStatsLogger(BaseStatsLogger): | ||
|
||
def incr(self, key): | ||
pass | ||
|
||
def decr(self, key): | ||
pass | ||
|
||
def gauge(self, key): | ||
pass | ||
|
||
|
||
try: | ||
from statsd import StatsClient | ||
|
||
class StatsdStatsLogger(BaseStatsLogger): | ||
def __init__(self, host, port, prefix='superset'): | ||
self.client = StatsClient( | ||
host=host, | ||
port=port, | ||
prefix=prefix) | ||
|
||
def incr(self, key): | ||
self.client.incr(key) | ||
|
||
def decr(self, key): | ||
self.client.decr(key) | ||
|
||
def gauge(self, key): | ||
self.client.gauge(key) | ||
except Exception as e: | ||
pass |