コード例 #1
0
ファイル: protocol.py プロジェクト: gyaozhou/ceph-read
    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
ファイル: protocol.py プロジェクト: yijxiang/pytelegraf
    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
ファイル: protocol.py プロジェクト: gyaozhou/ceph-read
    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
ファイル: protocol.py プロジェクト: FlyingHorse/pytelegraf
    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
ファイル: tests.py プロジェクト: FlyingHorse/pytelegraf
 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
ファイル: protocol.py プロジェクト: yijxiang/pytelegraf
 def get_output_measurement(self):
     """
     Formats and escapes measurement name that can be rendered to line protocol
     """
     return format_string(self.measurement)
コード例 #11
0
ファイル: protocol.py プロジェクト: gyaozhou/ceph-read
 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)