Search in sources :

Example 1 with ResultAttribute

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));
        }
    }
}
Also used : BatchPoints(org.influxdb.dto.BatchPoints) Matchers.anyString(org.mockito.Matchers.anyString) ResultAttribute(com.googlecode.jmxtrans.model.ResultAttribute) Test(org.junit.Test)

Example 2 with ResultAttribute

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;
}
Also used : ToString(lombok.ToString) ResultAttribute(com.googlecode.jmxtrans.model.ResultAttribute)

Aggregations

ResultAttribute (com.googlecode.jmxtrans.model.ResultAttribute)2 ToString (lombok.ToString)1 BatchPoints (org.influxdb.dto.BatchPoints)1 Test (org.junit.Test)1 Matchers.anyString (org.mockito.Matchers.anyString)1