@Test public void badKeyNameNoInvalidCharProvided() throws IOException { StatsDWriter2 writer = new StatsDWriter2(ImmutableList.of("scope", "name"), "root", "g", true, 1L, "___"); StringWriter out = new StringWriter(); writer.write(out, dummyServer(), dummyQuery(), dummyResultWithColon()); assertThat(out.toString()) .isEqualTo("root.host_example_net_4321.com_yammer_metrics_reporting_JmxReporter$Meter.127_0_0_1___8008_4XX.Count:10|g\n" + "root.host_example_net_4321.VerboseMemory.Verbose.true:1|g\n"); }
@Override public void write(@Nonnull Writer writer, @Nonnull Server server, @Nonnull Query query, @Nonnull Iterable<Result> results) throws IOException { for (Result result : results) { String key = KeyUtils.getKeyString(server, query, result, typeNames, rootPrefix); if (isNotValidValue(result.getValue())) { log.debug("Skipping message key[{}] with value: {}.", key, result.getValue()); continue; } String line = STATSD_INVALID.matcher(key).replaceAll(replacementForInvalidChar) + computeActualValue(result.getValue()) + "|" + bucketType + "\n"; writer.write(line); } }
StatsDWriter2 implements WriterBasedOutputWriter { @Override public void write(@Nonnull Writer writer, @Nonnull Server server, @Nonnull Query query, @Nonnull Iterable<Result> results) throws IOException { for (Result result : results) { String key = KeyUtils.getKeyString(server, query, result, typeNames, rootPrefix); if (isNotValidValue(result.getValue())) { log.debug("Skipping message key[{}] with value: {}.", key, result.getValue()); continue; } String line = STATSD_INVALID.matcher(key).replaceAll(replacementForInvalidChar) + computeActualValue(result.getValue()) + "|" + bucketType + "\n"; writer.write(line); } } }
StatsDWriter2 implements WriterBasedOutputWriter { @Override public void write(@Nonnull Writer writer, @Nonnull Server server, @Nonnull Query query, @Nonnull Iterable<Result> results) throws IOException { for (Result result : results) { String key = KeyUtils.getKeyString(server, query, result, typeNames, rootPrefix); if (isNotValidValue(result.getValue())) { log.debug("Skipping message key[{}] with value: {}.", key, result.getValue()); continue; } String line = STATSD_INVALID.matcher(key).replaceAll(replacementForInvalidChar) + computeActualValue(result.getValue()) + "|" + bucketType + "\n"; writer.write(line); } } StatsDWriter2(
			@Nonnull List<String> typeNames,
			@Nonnull String rootPrefix,
			@Nonnull String bucketType,
			boolean stringsValuesAsKey,
			@Nonnull Long stringValueDefaultCount,
			@Nonnull String replacementForInvalidChar); }
StatsDWriter2 implements WriterBasedOutputWriter { @Override public void write(@Nonnull Writer writer, @Nonnull Server server, @Nonnull Query query, @Nonnull Iterable<Result> results) throws IOException { for (Result result : results) { String key = KeyUtils.getKeyString(server, query, result, typeNames, rootPrefix); if (isNotValidValue(result.getValue())) { log.debug("Skipping message key[{}] with value: {}.", key, result.getValue()); continue; } String line = STATSD_INVALID.matcher(key).replaceAll(replacementForInvalidChar) + computeActualValue(result.getValue()) + "|" + bucketType + "\n"; writer.write(line); } } StatsDWriter2(
			@Nonnull List<String> typeNames,
			@Nonnull String rootPrefix,
			@Nonnull String bucketType,
			boolean stringsValuesAsKey,
			@Nonnull Long stringValueDefaultCount,
			@Nonnull String replacementForInvalidChar); @Override void write(@Nonnull Writer writer, @Nonnull Server server, @Nonnull Query query, @Nonnull Iterable<Result> results); }
StatsDWriter2 implements WriterBasedOutputWriter { @Override public void write(@Nonnull Writer writer, @Nonnull Server server, @Nonnull Query query, @Nonnull Iterable<Result> results) throws IOException { for (Result result : results) { String key = KeyUtils.getKeyString(server, query, result, typeNames, rootPrefix); if (isNotValidValue(result.getValue())) { log.debug("Skipping message key[{}] with value: {}.", key, result.getValue()); continue; } String line = STATSD_INVALID.matcher(key).replaceAll(replacementForInvalidChar) + computeActualValue(result.getValue()) + "|" + bucketType + "\n"; writer.write(line); } } StatsDWriter2(
			@Nonnull List<String> typeNames,
			@Nonnull String rootPrefix,
			@Nonnull String bucketType,
			boolean stringsValuesAsKey,
			@Nonnull Long stringValueDefaultCount,
			@Nonnull String replacementForInvalidChar); @Override void write(@Nonnull Writer writer, @Nonnull Server server, @Nonnull Query query, @Nonnull Iterable<Result> results);  }