use of com.googlecode.jmxtrans.model.ResultAttribute in project jmxtrans by jmxtrans.
the class InfluxDbWriterTests method onlyRequestedResultPropertiesAreAppliedAsTags.
@Test
public void onlyRequestedResultPropertiesAreAppliedAsTags() throws Exception {
for (ResultAttribute expectedResultTag : ResultAttribute.values()) {
ImmutableSet<ResultAttribute> expectedResultTags = ImmutableSet.of(expectedResultTag);
InfluxDbWriter writer = getTestInfluxDbWriterWithResultTags(expectedResultTags);
writer.doWrite(dummyServer(), dummyQuery(), results);
verify(influxDB, atLeastOnce()).write(messageCaptor.capture());
BatchPoints batchPoints = messageCaptor.getValue();
String lineProtocol = batchPoints.getPoints().get(0).lineProtocol();
assertThat(lineProtocol).contains(enumValueToAttribute(expectedResultTag));
EnumSet<ResultAttribute> unexpectedResultTags = EnumSet.complementOf(EnumSet.of(expectedResultTag));
for (ResultAttribute unexpectedResultTag : unexpectedResultTags) {
assertThat(lineProtocol).doesNotContain(enumValueToAttribute(unexpectedResultTag));
}
}
}
use of com.googlecode.jmxtrans.model.ResultAttribute in project jmxtrans by jmxtrans.
the class StatsDTelegrafWriterFactory method initResultAttributesToWriteAsTags.
/**
* Copied from InfluxDbWriterFactory
* @param resultTags
* @return
*/
private ImmutableSet<ResultAttribute> initResultAttributesToWriteAsTags(List<String> resultTags) {
EnumSet<ResultAttribute> resultAttributes = EnumSet.noneOf(ResultAttribute.class);
if (resultTags != null) {
for (String resultTag : resultTags) {
resultAttributes.add(ResultAttribute.fromAttribute(resultTag));
}
} else {
resultAttributes = EnumSet.allOf(ResultAttribute.class);
}
ImmutableSet<ResultAttribute> result = immutableEnumSet(resultAttributes);
LOG.debug("Result Tags to write set to: {}", result);
return result;
}
Aggregations