use of io.opencensus.metrics.LabelValue in project instrumentation-java by census-instrumentation.
the class StackdriverExportUtilsTest method createMetricDescriptor_WithCustomConstantLabels.
@Test
public void createMetricDescriptor_WithCustomConstantLabels() {
Map<LabelKey, LabelValue> constantLabels = Collections.singletonMap(LabelKey.create("my_key", "desc"), LabelValue.create("value"));
MetricDescriptor metricDescriptor = StackdriverExportUtils.createMetricDescriptor(METRIC_DESCRIPTOR, PROJECT_ID, "custom.googleapis.com/myorg/", "myorg/", constantLabels);
assertThat(metricDescriptor.getLabelsList()).containsExactly(LabelDescriptor.newBuilder().setKey(LABEL_KEY.get(0).getKey()).setDescription(LABEL_KEY.get(0).getDescription()).setValueType(ValueType.STRING).build(), LabelDescriptor.newBuilder().setKey("my_key").setDescription("desc").setValueType(ValueType.STRING).build());
}
use of io.opencensus.metrics.LabelValue in project instrumentation-java by census-instrumentation.
the class LongGaugeImplTest method testEquals.
@Test
public void testEquals() {
List<LabelKey> labelKeys = Arrays.asList(LabelKey.create("key1", "desc"), LabelKey.create("key2", "desc"));
List<LabelValue> labelValues = Arrays.asList(LabelValue.create("value1"), LabelValue.create("value2"));
LongGaugeImpl longGauge = new LongGaugeImpl(METRIC_NAME, METRIC_DESCRIPTION, METRIC_UNIT, labelKeys, EMPTY_CONSTANT_LABELS);
LongPoint defaultPoint1 = longGauge.getDefaultTimeSeries();
LongPoint defaultPoint2 = longGauge.getDefaultTimeSeries();
LongPoint longPoint1 = longGauge.getOrCreateTimeSeries(labelValues);
LongPoint longPoint2 = longGauge.getOrCreateTimeSeries(labelValues);
new EqualsTester().addEqualityGroup(defaultPoint1, defaultPoint2).addEqualityGroup(longPoint1, longPoint2).testEquals();
longGauge.clear();
LongPoint newDefaultPointAfterClear = longGauge.getDefaultTimeSeries();
LongPoint newLongPointAfterClear = longGauge.getOrCreateTimeSeries(labelValues);
longGauge.removeTimeSeries(labelValues);
LongPoint newLongPointAfterRemove = longGauge.getOrCreateTimeSeries(labelValues);
new EqualsTester().addEqualityGroup(defaultPoint1, defaultPoint2).addEqualityGroup(longPoint1, longPoint2).addEqualityGroup(newDefaultPointAfterClear).addEqualityGroup(newLongPointAfterClear).addEqualityGroup(newLongPointAfterRemove).testEquals();
}
Aggregations