Search in sources :

Example 1 with DoubleGauge

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)));
}
Also used : DerivedDoubleGauge(io.opencensus.metrics.DerivedDoubleGauge) DerivedLongGauge(io.opencensus.metrics.DerivedLongGauge) LongGauge(io.opencensus.metrics.LongGauge) DoublePoint(io.opencensus.metrics.DoubleGauge.DoublePoint) DerivedLongGauge(io.opencensus.metrics.DerivedLongGauge) DoubleGauge(io.opencensus.metrics.DoubleGauge) DerivedDoubleGauge(io.opencensus.metrics.DerivedDoubleGauge) Metric(io.opencensus.metrics.export.Metric) LongPoint(io.opencensus.metrics.LongGauge.LongPoint) Test(org.junit.Test)

Example 2 with DoubleGauge

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)));
}
Also used : DoubleGauge(io.opencensus.metrics.DoubleGauge) DerivedDoubleGauge(io.opencensus.metrics.DerivedDoubleGauge) Metric(io.opencensus.metrics.export.Metric) Test(org.junit.Test)

Aggregations

DerivedDoubleGauge (io.opencensus.metrics.DerivedDoubleGauge)2 DoubleGauge (io.opencensus.metrics.DoubleGauge)2 Metric (io.opencensus.metrics.export.Metric)2 Test (org.junit.Test)2 DerivedLongGauge (io.opencensus.metrics.DerivedLongGauge)1 DoublePoint (io.opencensus.metrics.DoubleGauge.DoublePoint)1 LongGauge (io.opencensus.metrics.LongGauge)1 LongPoint (io.opencensus.metrics.LongGauge.LongPoint)1