use of io.opencensus.metrics.DoubleGauge in project instrumentation-java by census-instrumentation.
the class MetricRegistryImplTest method getMetrics.
@Test
public void getMetrics() {
LongGauge longGauge = metricRegistry.addLongGauge(NAME, METRIC_OPTIONS);
LongPoint longPoint = longGauge.getOrCreateTimeSeries(LABEL_VALUES);
longPoint.set(200);
DoubleGauge doubleGauge = metricRegistry.addDoubleGauge(NAME_2, METRIC_OPTIONS);
DoublePoint doublePoint = doubleGauge.getOrCreateTimeSeries(LABEL_VALUES);
doublePoint.set(-300.13);
DerivedLongGauge derivedLongGauge = metricRegistry.addDerivedLongGauge(NAME_3, METRIC_OPTIONS);
derivedLongGauge.createTimeSeries(LABEL_VALUES, null, longFunction);
DerivedDoubleGauge derivedDoubleGauge = metricRegistry.addDerivedDoubleGauge(NAME_4, METRIC_OPTIONS);
derivedDoubleGauge.createTimeSeries(LABEL_VALUES, null, doubleFunction);
Collection<Metric> metricCollections = metricRegistry.getMetricProducer().getMetrics();
assertThat(metricCollections.size()).isEqualTo(4);
assertThat(metricCollections).containsExactly(Metric.createWithOneTimeSeries(LONG_METRIC_DESCRIPTOR, TimeSeries.createWithOnePoint(ALL_VALUES, Point.create(Value.longValue(200), TEST_TIME), null)), Metric.createWithOneTimeSeries(DOUBLE_METRIC_DESCRIPTOR, TimeSeries.createWithOnePoint(ALL_VALUES, Point.create(Value.doubleValue(-300.13), TEST_TIME), null)), Metric.createWithOneTimeSeries(DERIVED_LONG_METRIC_DESCRIPTOR, TimeSeries.createWithOnePoint(ALL_VALUES, Point.create(Value.longValue(5), TEST_TIME), null)), Metric.createWithOneTimeSeries(DERIVED_DOUBLE_METRIC_DESCRIPTOR, TimeSeries.createWithOnePoint(ALL_VALUES, Point.create(Value.doubleValue(5.0), TEST_TIME), null)));
}
use of io.opencensus.metrics.DoubleGauge in project instrumentation-java by census-instrumentation.
the class MetricRegistryImplTest method addDoubleGauge_GetMetrics.
@Test
public void addDoubleGauge_GetMetrics() {
DoubleGauge doubleGauge = metricRegistry.addDoubleGauge(NAME_2, METRIC_OPTIONS);
doubleGauge.getOrCreateTimeSeries(LABEL_VALUES);
Collection<Metric> metricCollections = metricRegistry.getMetricProducer().getMetrics();
assertThat(metricCollections.size()).isEqualTo(1);
assertThat(metricCollections).containsExactly(Metric.createWithOneTimeSeries(DOUBLE_METRIC_DESCRIPTOR, TimeSeries.createWithOnePoint(ALL_VALUES, Point.create(Value.doubleValue(0.0), TEST_TIME), null)));
}
Aggregations