use of io.opencensus.stats.Aggregation in project instrumentation-java by census-instrumentation.
the class Repl method registerAllViews.
private static void registerAllViews() {
// Defining the distribution aggregations
Aggregation latencyDistribution = Distribution.create(BucketBoundaries.create(Arrays.asList(// >=1s, >=2s, >=4s, >=6s]
0.0, 25.0, 50.0, 75.0, 100.0, 200.0, 400.0, 600.0, 800.0, 1000.0, 2000.0, 4000.0, 6000.0)));
Aggregation lengthsDistribution = Distribution.create(BucketBoundaries.create(Arrays.asList(// >=800B, >=1000B]
0.0, 5.0, 10.0, 20.0, 40.0, 60.0, 80.0, 100.0, 200.0, 400.0, 600.0, 800.0, 1000.0)));
// Define the count aggregation
Aggregation countAggregation = Aggregation.Count.create();
// So tagKeys
List<TagKey> noKeys = new ArrayList<TagKey>();
// Define the views
View[] views = new View[] { View.create(Name.create("ocjavametrics/latency"), "The distribution of latencies", M_LATENCY_MS, latencyDistribution, Collections.singletonList(KEY_METHOD)), View.create(Name.create("ocjavametrics/lines_in"), "The number of lines read in from standard input", M_LINES_IN, countAggregation, noKeys), View.create(Name.create("ocjavametrics/errors"), "The number of errors encountered", M_ERRORS, countAggregation, Collections.singletonList(KEY_METHOD)), View.create(Name.create("ocjavametrics/line_lengths"), "The distribution of line lengths", M_LINE_LENGTHS, lengthsDistribution, noKeys) };
// Create the view manager
ViewManager vmgr = Stats.getViewManager();
// Then finally register the views
for (View view : views) {
vmgr.registerView(view);
}
}
Aggregations