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)
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')
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)
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)
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)
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)
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)
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')
def get_output_measurement(self): """ Formats and escapes measurement name that can be rendered to line protocol """ return format_string(self.measurement)
def get_output_measurement(self) -> str: return format_string(self.measurement)
def get_output_measurement(self): return format_string(self.measurement)