Search in sources :

Example 6 with MeasureMap

use of io.opencensus.stats.MeasureMap in project instrumentation-java by census-instrumentation.

the class RecordMultipleViewsBenchmark method record.

private static MeasureMap record(Data data, Measure.MeasureLong measure, int value) {
    MeasureMap map = data.recorder.newMeasureMap();
    map.put(measure, value).record(data.tagContext);
    return map;
}
Also used : MeasureMap(io.opencensus.stats.MeasureMap)

Example 7 with MeasureMap

use of io.opencensus.stats.MeasureMap in project instrumentation-java by census-instrumentation.

the class RecordMultipleViewsBenchmark method record.

private static MeasureMap record(Data data, Measure.MeasureDouble measure, double value) {
    MeasureMap map = data.recorder.newMeasureMap();
    map.put(measure, value).record(data.tagContext);
    return map;
}
Also used : MeasureMap(io.opencensus.stats.MeasureMap)

Example 8 with MeasureMap

use of io.opencensus.stats.MeasureMap in project instrumentation-java by census-instrumentation.

the class RecordDifferentTagValuesBenchmark method record.

private static MeasureMap record(Data data, Measure.MeasureLong measure, int value) {
    MeasureMap map = data.recorder.newMeasureMap();
    map.put(measure, value);
    for (TagContext tags : data.contexts) {
        map.record(tags);
    }
    return map;
}
Also used : TagContext(io.opencensus.tags.TagContext) MeasureMap(io.opencensus.stats.MeasureMap)

Example 9 with MeasureMap

use of io.opencensus.stats.MeasureMap in project instrumentation-java by census-instrumentation.

the class StatsRecorderImplTest method record_MapDeprecatedRpcConstants.

@Test
public void record_MapDeprecatedRpcConstants() {
    View view = View.create(VIEW_NAME, "description", MEASURE_DOUBLE, Sum.create(), Arrays.asList(RecordUtils.RPC_METHOD));
    viewManager.registerView(view);
    MeasureMap statsRecord = statsRecorder.newMeasureMap().put(MEASURE_DOUBLE, 1.0);
    statsRecord.record(new SimpleTagContext(Tag.create(RecordUtils.GRPC_CLIENT_METHOD, VALUE)));
    ViewData viewData = viewManager.getView(VIEW_NAME);
    // There should be two entries.
    StatsTestUtil.assertAggregationMapEquals(viewData.getAggregationMap(), ImmutableMap.of(Arrays.asList(VALUE), StatsTestUtil.createAggregationData(Sum.create(), MEASURE_DOUBLE, 1.0)), 1e-6);
}
Also used : SimpleTagContext(io.opencensus.implcore.stats.StatsTestUtil.SimpleTagContext) StatsTestUtil.createEmptyViewData(io.opencensus.implcore.stats.StatsTestUtil.createEmptyViewData) ViewData(io.opencensus.stats.ViewData) View(io.opencensus.stats.View) MeasureMap(io.opencensus.stats.MeasureMap) Test(org.junit.Test)

Example 10 with MeasureMap

use of io.opencensus.stats.MeasureMap in project instrumentation-java by census-instrumentation.

the class StatsRecorderImplTest method recordTwice.

@Test
public void recordTwice() {
    View view = View.create(VIEW_NAME, "description", MEASURE_DOUBLE, Sum.create(), Arrays.asList(KEY), Cumulative.create());
    viewManager.registerView(view);
    MeasureMap statsRecord = statsRecorder.newMeasureMap().put(MEASURE_DOUBLE, 1.0);
    statsRecord.record(new SimpleTagContext(Tag.create(KEY, VALUE)));
    statsRecord.record(new SimpleTagContext(Tag.create(KEY, VALUE_2)));
    ViewData viewData = viewManager.getView(VIEW_NAME);
    // There should be two entries.
    StatsTestUtil.assertAggregationMapEquals(viewData.getAggregationMap(), ImmutableMap.of(Arrays.asList(VALUE), StatsTestUtil.createAggregationData(Sum.create(), MEASURE_DOUBLE, 1.0), Arrays.asList(VALUE_2), StatsTestUtil.createAggregationData(Sum.create(), MEASURE_DOUBLE, 1.0)), 1e-6);
}
Also used : SimpleTagContext(io.opencensus.implcore.stats.StatsTestUtil.SimpleTagContext) StatsTestUtil.createEmptyViewData(io.opencensus.implcore.stats.StatsTestUtil.createEmptyViewData) ViewData(io.opencensus.stats.ViewData) View(io.opencensus.stats.View) MeasureMap(io.opencensus.stats.MeasureMap) Test(org.junit.Test)

Aggregations

MeasureMap (io.opencensus.stats.MeasureMap)19 Benchmark (org.openjdk.jmh.annotations.Benchmark)8 BenchmarkMode (org.openjdk.jmh.annotations.BenchmarkMode)8 OutputTimeUnit (org.openjdk.jmh.annotations.OutputTimeUnit)8 View (io.opencensus.stats.View)4 StatsTestUtil.createEmptyViewData (io.opencensus.implcore.stats.StatsTestUtil.createEmptyViewData)3 ViewData (io.opencensus.stats.ViewData)3 TagContext (io.opencensus.tags.TagContext)3 Scope (io.opencensus.common.Scope)2 SimpleTagContext (io.opencensus.implcore.stats.StatsTestUtil.SimpleTagContext)2 Test (org.junit.Test)2 LastValue (io.opencensus.stats.Aggregation.LastValue)1 Measure (io.opencensus.stats.Measure)1 MeasureDouble (io.opencensus.stats.Measure.MeasureDouble)1 MeasureLong (io.opencensus.stats.Measure.MeasureLong)1 Stats (io.opencensus.stats.Stats)1 StatsRecorder (io.opencensus.stats.StatsRecorder)1 Name (io.opencensus.stats.View.Name)1 TagContextBuilder (io.opencensus.tags.TagContextBuilder)1 TagKey (io.opencensus.tags.TagKey)1