use of io.opencensus.stats.View in project instrumentation-java by census-instrumentation.
the class ViewManagerImplTest method testGetCumulativeViewDataWithoutBucketBoundaries.
@Test
public void testGetCumulativeViewDataWithoutBucketBoundaries() {
View view = createCumulativeView(VIEW_NAME, MEASURE_DOUBLE, MEAN, 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(MEAN, MEASURE_DOUBLE, 1.1)), EPSILON);
}
use of io.opencensus.stats.View in project instrumentation-java by census-instrumentation.
the class ViewManagerImplTest method testRegisterAndGetIntervalView.
@Test
public void testRegisterAndGetIntervalView() {
View intervalView = View.create(VIEW_NAME, VIEW_DESCRIPTION, MEASURE_DOUBLE, DISTRIBUTION, Arrays.asList(KEY), INTERVAL);
viewManager.registerView(intervalView);
assertThat(viewManager.getView(VIEW_NAME).getView()).isEqualTo(intervalView);
assertThat(viewManager.getView(VIEW_NAME).getAggregationMap()).isEmpty();
assertThat(viewManager.getView(VIEW_NAME).getWindowData()).isInstanceOf(IntervalData.class);
}
use of io.opencensus.stats.View in project instrumentation-java by census-instrumentation.
the class ViewManagerImplTest method testMultipleViews_DifferentMeasures.
private void testMultipleViews_DifferentMeasures(Measure measure1, Measure measure2, double value1, double value2) {
final View view1 = createCumulativeView(VIEW_NAME, measure1, DISTRIBUTION, Arrays.asList(KEY));
final View view2 = createCumulativeView(VIEW_NAME_2, measure2, DISTRIBUTION, Arrays.asList(KEY));
clock.setTime(Timestamp.create(1, 0));
viewManager.registerView(view1);
clock.setTime(Timestamp.create(2, 0));
viewManager.registerView(view2);
TagContext tags = tagger.emptyBuilder().put(KEY, VALUE).build();
MeasureMap measureMap = statsRecorder.newMeasureMap();
putToMeasureMap(measureMap, measure1, value1);
putToMeasureMap(measureMap, measure2, value2);
measureMap.record(tags);
clock.setTime(Timestamp.create(3, 0));
ViewData viewData1 = viewManager.getView(VIEW_NAME);
clock.setTime(Timestamp.create(4, 0));
ViewData viewData2 = viewManager.getView(VIEW_NAME_2);
assertThat(viewData1.getWindowData()).isEqualTo(CumulativeData.create(Timestamp.create(1, 0), Timestamp.create(3, 0)));
StatsTestUtil.assertAggregationMapEquals(viewData1.getAggregationMap(), ImmutableMap.of(Arrays.asList(VALUE), StatsTestUtil.createAggregationData(DISTRIBUTION, measure1, value1)), EPSILON);
assertThat(viewData2.getWindowData()).isEqualTo(CumulativeData.create(Timestamp.create(2, 0), Timestamp.create(4, 0)));
StatsTestUtil.assertAggregationMapEquals(viewData2.getAggregationMap(), ImmutableMap.of(Arrays.asList(VALUE), StatsTestUtil.createAggregationData(DISTRIBUTION, measure2, value2)), EPSILON);
}
use of io.opencensus.stats.View in project instrumentation-java by census-instrumentation.
the class ViewManagerImplTest method registerDifferentViewWithSameNameWithStatsDisabled.
@Test
@SuppressWarnings("deprecation")
public void registerDifferentViewWithSameNameWithStatsDisabled() {
statsComponent.setState(StatsCollectionState.DISABLED);
View view1 = View.create(VIEW_NAME, "View description.", MEASURE_DOUBLE, DISTRIBUTION, Arrays.asList(KEY), CUMULATIVE);
View view2 = View.create(VIEW_NAME, "This is a different description.", MEASURE_DOUBLE, DISTRIBUTION, Arrays.asList(KEY), CUMULATIVE);
testFailedToRegisterView(view1, view2, "A different view with the same name is already registered");
}
use of io.opencensus.stats.View in project instrumentation-java by census-instrumentation.
the class ViewManagerImplTest method settingStateToDisabledWillClearStats_Cumulative.
@Test
public void settingStateToDisabledWillClearStats_Cumulative() {
View cumulativeView = createCumulativeView(VIEW_NAME, MEASURE_DOUBLE, MEAN, Arrays.asList(KEY));
settingStateToDisabledWillClearStats(cumulativeView);
}
Aggregations