use of io.opencensus.stats.MeasureMap in project instrumentation-java by census-instrumentation.
the class RecordBatchedBenchmark method recordBatchedLongDistribution.
/**
* Record batched ling distribution measures.
*/
@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public MeasureMap recordBatchedLongDistribution(Data data) {
MeasureMap map = data.recorder.newMeasureMap();
for (int i = 0; i < data.numValues; i++) {
map.put(StatsBenchmarksUtil.DOUBLE_DISTRIBUTION_MEASURES[i], i);
}
map.record(data.tags);
return map;
}
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.MeasureDouble measure, double value) {
MeasureMap map = data.recorder.newMeasureMap();
map.put(measure, value);
for (TagContext tags : data.contexts) {
map.record(tags);
}
return map;
}
use of io.opencensus.stats.MeasureMap in project instrumentation-java by census-instrumentation.
the class ZPagesTester method recordExampleData.
private static void recordExampleData() throws InterruptedException {
Tracing.getExportComponent().getSampledSpanStore().registerSpanNamesForCollection(Collections.singletonList(SPAN_NAME));
// Use old RPC constants to get interval stats.
RpcViews.registerAllViews();
SpanBuilder spanBuilder = tracer.spanBuilder(SPAN_NAME).setRecordEvents(true).setSampler(Samplers.alwaysSample());
try (Scope scope = spanBuilder.startScopedSpan()) {
tracer.getCurrentSpan().addAnnotation("Starts recording.");
MeasureMap measureMap = statsRecorder.newMeasureMap().put(RpcMeasureConstants.RPC_CLIENT_STARTED_COUNT, 1).put(RpcMeasureConstants.RPC_CLIENT_FINISHED_COUNT, 1).put(RpcMeasureConstants.RPC_CLIENT_ROUNDTRIP_LATENCY, 1.0).put(RpcMeasureConstants.RPC_CLIENT_REQUEST_COUNT, 1).put(RpcMeasureConstants.RPC_CLIENT_RESPONSE_COUNT, 1).put(RpcMeasureConstants.RPC_CLIENT_REQUEST_BYTES, 1e5).put(RpcMeasureConstants.RPC_CLIENT_RESPONSE_BYTES, 1e5).put(RpcMeasureConstants.RPC_CLIENT_UNCOMPRESSED_REQUEST_BYTES, 1e5).put(RpcMeasureConstants.RPC_CLIENT_UNCOMPRESSED_RESPONSE_BYTES, 1e5).put(RpcMeasureConstants.RPC_SERVER_STARTED_COUNT, 1).put(RpcMeasureConstants.RPC_SERVER_FINISHED_COUNT, 1).put(RpcMeasureConstants.RPC_SERVER_SERVER_LATENCY, 1.0).put(RpcMeasureConstants.RPC_SERVER_REQUEST_COUNT, 1).put(RpcMeasureConstants.RPC_SERVER_RESPONSE_COUNT, 1).put(RpcMeasureConstants.RPC_SERVER_REQUEST_BYTES, 1e5).put(RpcMeasureConstants.RPC_SERVER_RESPONSE_BYTES, 1e5).put(RpcMeasureConstants.RPC_SERVER_UNCOMPRESSED_REQUEST_BYTES, 1e5).put(RpcMeasureConstants.RPC_SERVER_UNCOMPRESSED_RESPONSE_BYTES, 1e5);
measureMap.record(tagger.currentBuilder().put(RpcMeasureConstants.RPC_STATUS, TagValue.create("OK")).put(RpcMeasureConstants.RPC_METHOD, METHOD).build());
MeasureMap measureMapErrors = statsRecorder.newMeasureMap().put(RpcMeasureConstants.RPC_CLIENT_ERROR_COUNT, 1).put(RpcMeasureConstants.RPC_SERVER_ERROR_COUNT, 1);
measureMapErrors.record(tagger.currentBuilder().put(RpcMeasureConstants.RPC_STATUS, TagValue.create("UNKNOWN")).put(RpcMeasureConstants.RPC_METHOD, METHOD).build());
// sleep for fake work.
Thread.sleep(200);
tracer.getCurrentSpan().addAnnotation("Finish recording.");
}
}
use of io.opencensus.stats.MeasureMap 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);
}
Aggregations