use of io.opencensus.stats.View in project instrumentation-java by census-instrumentation.
the class ViewManagerImplTest method testRegisterAndGetCumulativeView.
@Test
public void testRegisterAndGetCumulativeView() {
View view = createCumulativeView();
viewManager.registerView(view);
assertThat(viewManager.getView(VIEW_NAME).getView()).isEqualTo(view);
assertThat(viewManager.getView(VIEW_NAME).getAggregationMap()).isEmpty();
assertThat(viewManager.getView(VIEW_NAME).getWindowData()).isInstanceOf(CumulativeData.class);
}
use of io.opencensus.stats.View in project instrumentation-java by census-instrumentation.
the class ViewManagerImplTest method testGetCumulativeViewDataWithEmptyBucketBoundaries.
@Test
public void testGetCumulativeViewDataWithEmptyBucketBoundaries() {
Aggregation noHistogram = Distribution.create(BucketBoundaries.create(Collections.<Double>emptyList()));
View view = createCumulativeView(VIEW_NAME, MEASURE_DOUBLE, noHistogram, Arrays.asList(KEY));
clock.setTime(Timestamp.create(1, 0));
viewManager.registerView(view);
statsRecorder.newMeasureMap().put(MEASURE_DOUBLE, 1.1).record(tagger.emptyBuilder().put(KEY, VALUE).build());
clock.setTime(Timestamp.create(3, 0));
ViewData viewData = viewManager.getView(VIEW_NAME);
assertThat(viewData.getWindowData()).isEqualTo(CumulativeData.create(Timestamp.create(1, 0), Timestamp.create(3, 0)));
StatsTestUtil.assertAggregationMapEquals(viewData.getAggregationMap(), ImmutableMap.of(Arrays.asList(VALUE), StatsTestUtil.createAggregationData(noHistogram, MEASURE_DOUBLE, 1.1)), EPSILON);
}
use of io.opencensus.stats.View in project instrumentation-java by census-instrumentation.
the class ViewManagerImplTest method registerRecordAndGetView_StatsReenabled.
@Test
@SuppressWarnings("deprecation")
public void registerRecordAndGetView_StatsReenabled() {
statsComponent.setState(StatsCollectionState.DISABLED);
statsComponent.setState(StatsCollectionState.ENABLED);
View view = createCumulativeView(VIEW_NAME, MEASURE_DOUBLE, MEAN, Arrays.asList(KEY));
viewManager.registerView(view);
statsRecorder.newMeasureMap().put(MEASURE_DOUBLE, 1.1).record(tagger.emptyBuilder().put(KEY, VALUE).build());
StatsTestUtil.assertAggregationMapEquals(viewManager.getView(VIEW_NAME).getAggregationMap(), ImmutableMap.of(Arrays.asList(VALUE), StatsTestUtil.createAggregationData(MEAN, MEASURE_DOUBLE, 1.1)), EPSILON);
}
use of io.opencensus.stats.View in project instrumentation-java by census-instrumentation.
the class ViewManagerImplTest method allowRegisteringSameViewTwice.
@Test
public void allowRegisteringSameViewTwice() {
View view = createCumulativeView();
viewManager.registerView(view);
viewManager.registerView(view);
assertThat(viewManager.getView(VIEW_NAME).getView()).isEqualTo(view);
}
use of io.opencensus.stats.View in project instrumentation-java by census-instrumentation.
the class ViewManagerImplTest method registerViewWithStatsDisabled_RecordAndGetViewWithStatsEnabled.
@Test
@SuppressWarnings("deprecation")
public void registerViewWithStatsDisabled_RecordAndGetViewWithStatsEnabled() {
statsComponent.setState(StatsCollectionState.DISABLED);
View view = createCumulativeView(VIEW_NAME, MEASURE_DOUBLE, MEAN, Arrays.asList(KEY));
// view will still be registered.
viewManager.registerView(view);
statsComponent.setState(StatsCollectionState.ENABLED);
statsRecorder.newMeasureMap().put(MEASURE_DOUBLE, 1.1).record(tagger.emptyBuilder().put(KEY, VALUE).build());
StatsTestUtil.assertAggregationMapEquals(viewManager.getView(VIEW_NAME).getAggregationMap(), ImmutableMap.of(Arrays.asList(VALUE), StatsTestUtil.createAggregationData(MEAN, MEASURE_DOUBLE, 1.1)), EPSILON);
}
Aggregations