Search in sources :

Example 1 with Count

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

the class StatszZPageHandler method emitViewDataTableHeader.

private static void emitViewDataTableHeader(View view, PrintWriter out, Formatter formatter) {
    out.write("<thead>");
    out.write("<tr>");
    for (TagKey tagKey : view.getColumns()) {
        formatter.format("<th class=\"borderRL\">TagKey: %s (string)</th>", tagKey.getName());
    }
    String unit = view.getMeasure().getUnit();
    view.getAggregation().match(new Function<Sum, Void>() {

        @Override
        public Void apply(Sum arg) {
            formatter.format("<th class=\"borderL\">%s, %s</th>", TABLE_HEADER_SUM, unit);
            return null;
        }
    }, new Function<Count, Void>() {

        @Override
        public Void apply(Count arg) {
            formatter.format("<th class=\"borderL\">%s</th>", TABLE_HEADER_COUNT);
            return null;
        }
    }, new Function<Distribution, Void>() {

        @Override
        public Void apply(Distribution arg) {
            formatter.format("<th>%s, %s</th>", TABLE_HEADER_MEAN, unit);
            formatter.format("<th class=\"borderL\">%s</th>", TABLE_HEADER_COUNT);
            formatter.format("<th class=\"borderL\">%s, %s</th>", TABLE_HEADER_MAX, unit);
            formatter.format("<th class=\"borderL\">%s, %s</th>", TABLE_HEADER_MIN, unit);
            formatter.format("<th class=\"borderL\">%s</th>", TABLE_HEADER_DEV);
            formatter.format("<th class=\"borderL\">%s</th>", TABLE_HEADER_HISTOGRAM);
            return null;
        }
    }, new Function<LastValue, Void>() {

        @Override
        public Void apply(LastValue arg) {
            formatter.format("<th class=\"borderL\">%s, %s</th>", TABLE_HEADER_LAST_VALUE, unit);
            return null;
        }
    }, new Function<Aggregation, Void>() {

        @Override
        public Void apply(Aggregation arg) {
            // deprecated RPC views.
            if (arg instanceof Aggregation.Mean) {
                formatter.format("<th>%s, %s</th>", TABLE_HEADER_MEAN, unit);
                formatter.format("<th class=\"borderL\">%s</th>", TABLE_HEADER_COUNT);
                return null;
            }
            throw new IllegalArgumentException("Unknown Aggregation.");
        }
    });
    out.write("</tr>");
    out.write("</thead>");
}
Also used : Sum(io.opencensus.stats.Aggregation.Sum) Count(io.opencensus.stats.Aggregation.Count) LastValue(io.opencensus.stats.Aggregation.LastValue) Aggregation(io.opencensus.stats.Aggregation) Distribution(io.opencensus.stats.Aggregation.Distribution) TagKey(io.opencensus.tags.TagKey)

Aggregations

Aggregation (io.opencensus.stats.Aggregation)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 TagKey (io.opencensus.tags.TagKey)1