Skip to content

Commit

Permalink
Merge pull request #2206 from iksaif/pr-disable-tags
Browse files Browse the repository at this point in the history
Make it possible to fully disable tags
  • Loading branch information
iksaif committed Jan 18, 2018
2 parents d83a548 + c4dfc1a commit c698848
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
10 changes: 5 additions & 5 deletions webapp/graphite/render/datalib.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ def __init__(self, name, start, end, step, values, consolidate='average', tags=N
else:
self.tags = {'name': name}
# parse for tags if a tagdb is configured and name doesn't look like a function-wrapped name
if STORE.tagdb and not re.match('^[a-z]+[(].+[)]$', name, re.IGNORECASE):
try:
try:
if STORE.tagdb and not re.match('^[a-z]+[(].+[)]$', name, re.IGNORECASE):
self.tags = STORE.tagdb.parse(name).tags
except Exception as err:
# tags couldn't be parsed, just use "name" tag
log.debug("Couldn't parse tags for %s: %s" % (name, err))
except Exception as err:
# tags couldn't be parsed, just use "name" tag
log.debug("Couldn't parse tags for %s: %s" % (name, err))

def __eq__(self, other):
if not isinstance(other, TimeSeries):
Expand Down
2 changes: 1 addition & 1 deletion webapp/graphite/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def __init__(self, finders=None, tagdb=None):
self.finders = finders

if tagdb is None:
tagdb = get_tagdb(settings.TAGDB or 'graphite.tags.localdatabase.LocalDatabaseTagDB')
tagdb = get_tagdb(settings.TAGDB or 'graphite.tags.base.DummyTagDB')
self.tagdb = tagdb

def get_finders(self, local=False):
Expand Down
24 changes: 24 additions & 0 deletions webapp/graphite/tags/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,3 +269,27 @@ def parse_tagspec(tagspec):
spec = m.group(3)

return (tag, operator, spec)


class DummyTagDB(BaseTagDB):

def _find_series(self, tags, requestContext=None):
return []

def get_series(self, path, requestContext=None):
return None

def list_tags(self, tagFilter=None, limit=None, requestContext=None):
return []

def get_tag(self, tag, valueFilter=None, limit=None, requestContext=None):
return None

def list_values(self, tag, valueFilter=None, limit=None, requestContext=None):
return []

def tag_series(self, series, requestContext=None):
raise NotImplementedError('Tagging not implemented with DummyTagDB')

def del_series(self, series, requestContext=None):
return True

0 comments on commit c698848

Please sign in to comment.