コード例 #1
0
    def test_flush(self):
        output = StringIO()
        dest = Stream(output)

        metrics = [('logins', 12, 456789), ('mem', 53, 98765)]
        dest.flush(metrics)
        self.assertEqual("logins 12 456789\nmem 53 98765\n", output.getvalue())
コード例 #2
0
    def test_flush(self):
        output = StringIO()
        dest = Stream(output)

        metrics = [('logins', 12, 456789), ('mem', 53, 98765)]
        dest.flush(metrics)
        self.assertEqual("logins 12 456789\nmem 53 98765\n", output.getvalue())
コード例 #3
0
    def test_flush_with_append(self):
        output = StringIO()
        dest = Stream(output)
        dest.append = "+++"

        metrics = [('users', 800, 5678), ('cpu', 99, 1234)]
        dest.flush(metrics)
        self.assertEqual("users 800 5678+++cpu 99 1234+++", output.getvalue())
コード例 #4
0
    def test_flush_with_append(self):
        output = StringIO()
        dest = Stream(output)
        dest.append = "+++"

        metrics = [('users', 800, 5678), ('cpu', 99, 1234)]
        dest.flush(metrics)
        self.assertEqual("users 800 5678+++cpu 99 1234+++", output.getvalue())
コード例 #5
0
    def test_flush_with_partial_pattern_and_append(self):
        output = StringIO()
        dest = Stream(output)
        dest.pattern = "({name}:'{value}'"
        dest.append = ")"

        metrics = [('users', 800, 5678), ('cpu', 99, 1234)]
        dest.flush(metrics)
        self.assertEqual("(users:'800')(cpu:'99')", output.getvalue())
コード例 #6
0
    def test_flush_with_pattern(self):
        output = StringIO()
        dest = Stream(output)
        dest.pattern = '"{name}"={value}@{timestamp}'

        metrics = [('logins', 12, 456789), ('mem', 53, 98765)]
        dest.flush(metrics)
        self.assertEqual('"logins"=12@456789\n"mem"=53@98765\n',
                         output.getvalue())
コード例 #7
0
    def test_flush_with_partial_pattern_and_append(self):
        output = StringIO()
        dest = Stream(output)
        dest.pattern = "({name}:'{value}'"
        dest.append = ")"

        metrics = [('users', 800, 5678), ('cpu', 99, 1234)]
        dest.flush(metrics)
        self.assertEqual("(users:'800')(cpu:'99')", output.getvalue())
コード例 #8
0
    def test_flush_with_pattern(self):
        output = StringIO()
        dest = Stream(output)
        dest.pattern = '"{name}"={value}@{timestamp}'

        metrics = [('logins', 12, 456789), ('mem', 53, 98765)]
        dest.flush(metrics)
        self.assertEqual('"logins"=12@456789\n"mem"=53@98765\n',
                         output.getvalue())