Search in sources :

Example 1 with Dimension

use of com.signalfx.metrics.protobuf.SignalFxProtocolBuffers.Dimension in project instrumentation-java by census-instrumentation.

the class SignalFxSessionAdaptor method createDimensions.

@VisibleForTesting
static Iterable<Dimension> createDimensions(List<LabelKey> keys, List<LabelValue> values) {
    List<Dimension> dimensions = new ArrayList<>(keys.size());
    for (int i = 0; i < values.size(); i++) {
        LabelValue value = values.get(i);
        if (Strings.isNullOrEmpty(value.getValue())) {
            continue;
        }
        dimensions.add(createDimension(keys.get(i), value));
    }
    return dimensions;
}
Also used : LabelValue(io.opencensus.metrics.LabelValue) ArrayList(java.util.ArrayList) Dimension(com.signalfx.metrics.protobuf.SignalFxProtocolBuffers.Dimension) Point(io.opencensus.metrics.export.Point) DataPoint(com.signalfx.metrics.protobuf.SignalFxProtocolBuffers.DataPoint) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 2 with Dimension

use of com.signalfx.metrics.protobuf.SignalFxProtocolBuffers.Dimension in project instrumentation-java by census-instrumentation.

the class SignalFxSessionAdaptorTest method adaptMetricIntoDatapoints.

@Test
public void adaptMetricIntoDatapoints() {
    List<DataPoint> datapoints = SignalFxSessionAdaptor.adapt(METRIC);
    assertEquals(2, datapoints.size());
    for (DataPoint dp : datapoints) {
        assertEquals(METRIC_NAME, dp.getMetric());
        assertEquals(MetricType.CUMULATIVE_COUNTER, dp.getMetricType());
        assertEquals(1, dp.getDimensionsCount());
        assertTrue(dp.hasValue());
        assertFalse(dp.hasSource());
        Datum datum = dp.getValue();
        assertTrue(datum.hasIntValue());
        assertFalse(datum.hasDoubleValue());
        assertFalse(datum.hasStrValue());
        Dimension dimension = dp.getDimensions(0);
        assertEquals(LABEL_KEY_1.getKey(), dimension.getKey());
        switch(dimension.getValue()) {
            case "value1":
                assertEquals(2L, datum.getIntValue());
                break;
            case "value2":
                assertEquals(3L, datum.getIntValue());
                break;
            default:
                fail("unexpected dimension value");
        }
    }
}
Also used : Datum(com.signalfx.metrics.protobuf.SignalFxProtocolBuffers.Datum) DataPoint(com.signalfx.metrics.protobuf.SignalFxProtocolBuffers.DataPoint) Dimension(com.signalfx.metrics.protobuf.SignalFxProtocolBuffers.Dimension) Test(org.junit.Test)

Example 3 with Dimension

use of com.signalfx.metrics.protobuf.SignalFxProtocolBuffers.Dimension in project instrumentation-java by census-instrumentation.

the class SignalFxSessionAdaptorTest method createDimension.

@Test
public void createDimension() {
    Dimension dimension = SignalFxSessionAdaptor.createDimension(LABEL_KEY_1, LABEL_VALUE_1);
    assertEquals(LABEL_KEY_1.getKey(), dimension.getKey());
    assertEquals(LABEL_VALUE_1.getValue(), dimension.getValue());
}
Also used : Dimension(com.signalfx.metrics.protobuf.SignalFxProtocolBuffers.Dimension) Test(org.junit.Test)

Example 4 with Dimension

use of com.signalfx.metrics.protobuf.SignalFxProtocolBuffers.Dimension in project instrumentation-java by census-instrumentation.

the class SignalFxSessionAdaptorTest method adaptMetricWithEmptyLabelValueIntoDatapoints.

@Test
public void adaptMetricWithEmptyLabelValueIntoDatapoints() {
    List<DataPoint> datapoints = SignalFxSessionAdaptor.adapt(METRIC_1);
    assertEquals(2, datapoints.size());
    for (DataPoint dp : datapoints) {
        assertEquals(METRIC_NAME, dp.getMetric());
        assertEquals(MetricType.CUMULATIVE_COUNTER, dp.getMetricType());
        assertTrue(dp.hasValue());
        assertFalse(dp.hasSource());
        Datum datum = dp.getValue();
        assertTrue(datum.hasIntValue());
        assertFalse(datum.hasDoubleValue());
        assertFalse(datum.hasStrValue());
        switch(dp.getDimensionsCount()) {
            case 0:
                assertEquals(3L, datum.getIntValue());
                break;
            case 1:
                Dimension dimension = dp.getDimensions(0);
                assertEquals(LABEL_KEY_1.getKey(), dimension.getKey());
                assertEquals(LABEL_VALUE_1.getValue(), dimension.getValue());
                assertEquals(2L, datum.getIntValue());
                break;
            default:
                fail("Unexpected number of dimensions on the created datapoint");
                break;
        }
    }
}
Also used : Datum(com.signalfx.metrics.protobuf.SignalFxProtocolBuffers.Datum) DataPoint(com.signalfx.metrics.protobuf.SignalFxProtocolBuffers.DataPoint) Dimension(com.signalfx.metrics.protobuf.SignalFxProtocolBuffers.Dimension) Test(org.junit.Test)

Aggregations

Dimension (com.signalfx.metrics.protobuf.SignalFxProtocolBuffers.Dimension)4 DataPoint (com.signalfx.metrics.protobuf.SignalFxProtocolBuffers.DataPoint)3 Test (org.junit.Test)3 Datum (com.signalfx.metrics.protobuf.SignalFxProtocolBuffers.Datum)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 LabelValue (io.opencensus.metrics.LabelValue)1 Point (io.opencensus.metrics.export.Point)1 ArrayList (java.util.ArrayList)1