예제 #1
0
    def get_output_tags(self) -> str:
        if not self.tags:
            self.tags = dict()

        sorted_tags = sorted(self.tags.items())

        return ','.join('{0}={1}'.format(format_string(k), format_string(v)) for k, v in sorted_tags)
예제 #2
0
파일: tests.py 프로젝트: sruedat/TFM_Srueda
 def test_format_key(self):
     self.assertEquals(format_string('foo'), 'foo')
     self.assertEquals(format_string('foo,bar'), 'foo\,bar')
     self.assertEquals(format_string('foo bar'), 'foo\ bar')
     self.assertEquals(format_string('foo ,bar'), 'foo\ \,bar')
     self.assertEquals(format_string('foo ,bar,baz=foobar'),
                       'foo\ \,bar\,baz\=foobar')
예제 #3
0
파일: protocol.py 프로젝트: C2python/ceph
    def get_output_tags(self):
        if not self.tags:
            self.tags = dict()

        sorted_tags = sorted(self.tags.items())

        return u','.join(u'{0}={1}'.format(format_string(k), format_string(v)) for k, v in sorted_tags)
예제 #4
0
    def get_output_tags(self):
        """
        Return an escaped string of comma separated tag_name: tag_value pairs

        Tags should be sorted by key before being sent for best performance. The sort should
        match that from the Go bytes. Compare function (http://golang.org/pkg/bytes/#Compare).
        """

        # Sort the tags in lexicographically by tag name
        sorted_tags = sorted(self.tags.items())

        # Finally render, escape and return the tag string
        return u",".join(u"{0}={1}".format(format_string(k), format_string(v)) for k, v in sorted_tags)
예제 #5
0
    def get_output_values(self) -> str:
        if not isinstance(self.values, dict):
            metric_values = {'value': self.values}
        else:
            metric_values = self.values

        sorted_values = sorted(metric_values.items())
        sorted_values = [(k, v) for k, v in sorted_values if v is not None]

        return ','.join('{0}={1}'.format(format_string(k), format_value(v)) for k, v in sorted_values)
예제 #6
0
파일: protocol.py 프로젝트: C2python/ceph
    def get_output_values(self):
        if not isinstance(self.values, dict):
            metric_values = {'value': self.values}
        else:
            metric_values = self.values

        sorted_values = sorted(metric_values.items())
        sorted_values = [(k, v) for k, v in sorted_values if v is not None]

        return u','.join(u'{0}={1}'.format(format_string(k), format_value(v)) for k, v in sorted_values)
예제 #7
0
    def get_output_values(self):
        """
        Return an escaped string of comma separated value_name: value pairs
        """
        # Handle primitive values here and implicitly convert them to a dict because
        # it allows the API to be simpler.

        # Also influxDB mandates that each value also has a name so the default name
        # for any non-dict value is "value"
        if not isinstance(self.values, dict):
            metric_values = {'value': self.values}
        else:
            metric_values = self.values

        # Sort the values in lexicographically by value name
        sorted_values = sorted(metric_values.items())

        return ",".join("{0}={1}".format(format_string(k), format_value(v)) for k, v in sorted_values)
예제 #8
0
    def get_output_values(self):
        """
        Return an escaped string of comma separated value_name: value pairs
        """
        # Handle primitive values here and implicitly convert them to a dict because
        # it allows the API to be simpler.

        # Also influxDB mandates that each value also has a name so the default name
        # for any non-dict value is "value"
        if not isinstance(self.values, dict):
            metric_values = {'value': self.values}
        else:
            metric_values = self.values

        # Sort the values in lexicographically by value name
        sorted_values = sorted(metric_values.items())

        return ",".join("{0}={1}".format(format_string(k), format_value(v))
                        for k, v in sorted_values)
예제 #9
0
 def test_format_key(self):
     self.assertEquals(format_string('foo'), 'foo')
     self.assertEquals(format_string('foo,bar'), 'foo\,bar')
     self.assertEquals(format_string('foo bar'), 'foo\ bar')
     self.assertEquals(format_string('foo ,bar'), 'foo\ \,bar')
예제 #10
0
 def get_output_measurement(self):
     """
     Formats and escapes measurement name that can be rendered to line protocol
     """
     return format_string(self.measurement)
예제 #11
0
 def get_output_measurement(self) -> str:
     return format_string(self.measurement)
예제 #12
0
파일: protocol.py 프로젝트: C2python/ceph
 def get_output_measurement(self):
     return format_string(self.measurement)