def test_taggedseries(self): # test path with tags parsed = TaggedSeries.parse('test.a;hello=tiger;blah=blah') self.assertIsInstance(parsed, TaggedSeries) self.assertEqual(parsed.metric, 'test.a') self.assertEqual(parsed.tags, {'blah': 'blah', 'hello': 'tiger', 'name': 'test.a'}) # test formatting self.assertEqual(parsed.path, 'test.a;blah=blah;hello=tiger') # test encoding self.assertEqual(TaggedSeries.encode(parsed.path), '_tagged.2b0.2af.test-a;blah=blah;hello=tiger') # test path without tags parsed = TaggedSeries.parse('test.a') self.assertIsInstance(parsed, TaggedSeries) self.assertEqual(parsed.metric, 'test.a') self.assertEqual(parsed.tags, {'name': 'test.a'}) # test formatting self.assertEqual(parsed.path, 'test.a') # test encoding self.assertEqual(TaggedSeries.encode(parsed.path), 'test.a') # test parsing openmetrics parsed = TaggedSeries.parse(r'test.a{hello="tiger",blah="bla\"h"}') self.assertIsInstance(parsed, TaggedSeries) self.assertEqual(parsed.metric, 'test.a') self.assertEqual(parsed.tags, {'blah': 'bla"h', 'hello': 'tiger', 'name': 'test.a'})
def test_taggedseries(self): # test path with tags parsed = TaggedSeries.parse('test.a;hello=tiger;blah=blah') self.assertIsInstance(parsed, TaggedSeries) self.assertEqual(parsed.metric, 'test.a') self.assertEqual(parsed.tags, {'blah': 'blah', 'hello': 'tiger', 'name': 'test.a'}) # test formatting self.assertEqual(parsed.path, 'test.a;blah=blah;hello=tiger') # test encoding self.assertEqual(TaggedSeries.encode(parsed.path), '_tagged.2b0.2af.test-a;blah=blah;hello=tiger') # test path without tags parsed = TaggedSeries.parse('test.a') self.assertIsInstance(parsed, TaggedSeries) self.assertEqual(parsed.metric, 'test.a') self.assertEqual(parsed.tags, {'name': 'test.a'}) # test formatting self.assertEqual(parsed.path, 'test.a') # test encoding self.assertEqual(TaggedSeries.encode(parsed.path), 'test.a') # test parsing openmetrics parsed = TaggedSeries.parse(r'test.a{hello="tiger",blah="bla\"h"}') self.assertIsInstance(parsed, TaggedSeries) self.assertEqual(parsed.metric, 'test.a') self.assertEqual(parsed.tags, {'blah': 'bla"h', 'hello': 'tiger', 'name': 'test.a'})
def parse(path): return TaggedSeries.parse(path)
def parse(path): return TaggedSeries.parse(path)