Ejemplo n.º 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)
Ejemplo n.º 2
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')
     self.assertEquals(format_string('foo ,bar,baz=foobar'),
                       'foo\ \,bar\,baz\=foobar')
Ejemplo n.º 3
0
    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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 6
0
    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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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')
Ejemplo n.º 10
0
 def get_output_measurement(self):
     """
     Formats and escapes measurement name that can be rendered to line protocol
     """
     return format_string(self.measurement)
Ejemplo n.º 11
0
 def get_output_measurement(self) -> str:
     return format_string(self.measurement)
Ejemplo n.º 12
0
 def get_output_measurement(self):
     return format_string(self.measurement)