use of io.opencensus.implcore.stats.StatsTestUtil.SimpleTagContext in project instrumentation-java by census-instrumentation.
the class StatsRecorderImplTest method record_StatsDisabled.
@Test
@SuppressWarnings("deprecation")
public void record_StatsDisabled() {
View view = View.create(VIEW_NAME, "description", MEASURE_DOUBLE, Sum.create(), Arrays.asList(KEY), Cumulative.create());
viewManager.registerView(view);
statsComponent.setState(StatsCollectionState.DISABLED);
statsRecorder.newMeasureMap().put(MEASURE_DOUBLE, 1.0).record(new SimpleTagContext(Tag.create(KEY, VALUE)));
assertThat(viewManager.getView(VIEW_NAME)).isEqualTo(createEmptyViewData(view));
}
use of io.opencensus.implcore.stats.StatsTestUtil.SimpleTagContext in project instrumentation-java by census-instrumentation.
the class StatsRecorderImplTest method record_CurrentContextSet.
@Test
public void record_CurrentContextSet() {
View view = View.create(VIEW_NAME, "description", MEASURE_DOUBLE, Sum.create(), Arrays.asList(KEY), Cumulative.create());
viewManager.registerView(view);
TagContext tags = new SimpleTagContext(Tag.create(KEY, VALUE));
Context orig = ContextUtils.withValue(Context.current(), tags).attach();
try {
statsRecorder.newMeasureMap().put(MEASURE_DOUBLE, 1.0).record();
} finally {
Context.current().detach(orig);
}
ViewData viewData = viewManager.getView(VIEW_NAME);
// record() should have used the given TagContext.
assertThat(viewData.getAggregationMap().keySet()).containsExactly(Arrays.asList(VALUE));
}
Aggregations