Skip to content

Commit

Permalink
Merge pull request #2370 from andreasferber/fix-tagged-carbonlink
Browse files Browse the repository at this point in the history
Fix carbonlink queries for tagged series.
  • Loading branch information
deniszh committed Oct 30, 2018
2 parents 64f3b10 + 08c1ac7 commit 839b443
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
5 changes: 3 additions & 2 deletions webapp/graphite/finders/standard.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,14 @@ def find_nodes(self, query):
datasource_pattern = None

absolute_path = join(root_dir, relative_path)
metric_path = fs_to_metric(relative_path)
real_metric_path = get_real_metric_path(absolute_path, metric_path)

# if we're finding by tag, return the proper metric path
if tagged:
metric_path = query.pattern
real_metric_path = query.pattern
else:
metric_path = fs_to_metric(relative_path)
real_metric_path = get_real_metric_path(absolute_path, metric_path)
metric_path_parts = metric_path.split('.')
for field_index in find_escaped_pattern_fields(query.pattern):
metric_path_parts[field_index] = pattern_parts[field_index].replace('\\', '')
Expand Down
19 changes: 19 additions & 0 deletions webapp/tests/test_finders.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,25 @@ def test_standard_finder_gzipped_whisper(self, scandir_mock):
scandir_mock.call_count = 0
self.wipe_whisper()

def test_standard_finder_tagged_whisper_carbonlink(self):
try:
self.create_whisper(join(
'_tagged',
'b34',
'2de',
# foo;bar=baz2
'b342defa10cb579981c63ef78be5ac248f681f4bd2c35bc0209d3a7b9eb99346.wsp'
))

finder = get_finders('graphite.finders.standard.StandardFinder')[0]

nodes = list(finder.find_nodes(FindQuery('foo;bar=baz2', None, None)))
self.assertEqual(len(nodes), 1)
self.assertEqual(nodes[0].reader.real_metric_path, 'foo;bar=baz2')

finally:
self.wipe_whisper()

def test_globstar(self):
self.addCleanup(self.wipe_whisper)
store = Store(finders=get_finders('graphite.finders.standard.StandardFinder'))
Expand Down

0 comments on commit 839b443

Please sign in to comment.