InfluxDbReporter extends ScheduledMetrics2Reporter { public static String getInfluxDbLineProtocolString(MetricName metricName) { String influxDbString = metricNameToInfluxDBFormatCache.get(metricName); if (influxDbString == null) { final StringBuilder sb = new StringBuilder(metricName.getName().length() + metricName.getTagKeys().size() * 16 + metricName.getTagKeys().size()); sb.append(escapeForInfluxDB(metricName.getName())); appendTags(sb, metricName.getTags()); influxDbString = sb.toString(); metricNameToInfluxDBFormatCache.put(metricName, influxDbString); } return influxDbString; } private  InfluxDbReporter(Builder builder); static Builder forRegistry(Metric2Registry registry, CorePlugin corePlugin); @Override void reportMetrics(Map<MetricName, Gauge> gauges,
							  Map<MetricName, Counter> counters,
							  Map<MetricName, Histogram> histograms,
							  Map<MetricName, Meter> meters,
							  Map<MetricName, Timer> timers); static String getInfluxDbLineProtocolString(MetricName metricName);  }
@Test public void testGetInfluxDbStringOrderedTags() throws Exception { assertEquals("cpu_usage,core=1,level=user", InfluxDbReporter.getInfluxDbLineProtocolString(name("cpu_usage").tag("level", "user").tag("core", "1").build())); }
@Test public void testGetInfluxDbStringWhiteSpace() throws Exception { assertEquals("cpu\\ usage,level=soft\\ irq", InfluxDbReporter.getInfluxDbLineProtocolString(name("cpu usage").tag("level", "soft irq").build())); }
@Test public void testGetInfluxDbStringNoTags() throws Exception { assertEquals("cpu_usage", InfluxDbReporter.getInfluxDbLineProtocolString(name("cpu_usage").build())); }
@Test public void testGetInfluxDbStringAllEscapingAndQuotingBehavior() throws Exception { assertEquals("\"measurement\\ with\\ quotes\",tag\\ key\\ with\\ spaces=tag\\,value\\,with\"commas\"", InfluxDbReporter.getInfluxDbLineProtocolString(name("\"measurement with quotes\"").tag("tag key with spaces", "tag,value,with\"commas\"").build())); }