Search in sources :

Example 6 with Aggregation

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);
    }
}
Also used : Aggregation(io.opencensus.stats.Aggregation) TagKey(io.opencensus.tags.TagKey) ArrayList(java.util.ArrayList) ViewManager(io.opencensus.stats.ViewManager) View(io.opencensus.stats.View)

Aggregations

Aggregation (io.opencensus.stats.Aggregation)6 View (io.opencensus.stats.View)5 TagKey (io.opencensus.tags.TagKey)4 ViewData (io.opencensus.stats.ViewData)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 Timestamp (io.opencensus.common.Timestamp)1 CurrentState (io.opencensus.implcore.internal.CurrentState)1 StatsTestUtil.createEmptyViewData (io.opencensus.implcore.stats.StatsTestUtil.createEmptyViewData)1 LabelKey (io.opencensus.metrics.LabelKey)1 Count (io.opencensus.stats.Aggregation.Count)1 Distribution (io.opencensus.stats.Aggregation.Distribution)1 LastValue (io.opencensus.stats.Aggregation.LastValue)1 Sum (io.opencensus.stats.Aggregation.Sum)1 AggregationData (io.opencensus.stats.AggregationData)1 LastValueDataDouble (io.opencensus.stats.AggregationData.LastValueDataDouble)1 MeanData (io.opencensus.stats.AggregationData.MeanData)1 SumDataDouble (io.opencensus.stats.AggregationData.SumDataDouble)1 Measure (io.opencensus.stats.Measure)1