Search in sources :

Example 1 with Metric

use of com.yammer.metrics.core.Metric in project pinot by linkedin.

the class AggregatedCounter method refresh.

/**
   * Update counter from underlying counters.
   */
public void refresh() {
    long count = 0;
    for (Metric m : _counters) {
        if (m instanceof Counter) {
            count += ((Counter) m).count();
        } else if (m instanceof AggregatedCounter) {
            count += ((AggregatedCounter) m).count();
        }
    }
    _count = count;
}
Also used : Counter(com.yammer.metrics.core.Counter) Metric(com.yammer.metrics.core.Metric)

Example 2 with Metric

use of com.yammer.metrics.core.Metric in project netty by netty.

the class CustomReporter method run.

@Override
public void run() {
    try {
        final DateFormat format = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM, locale);
        format.setTimeZone(timeZone);
        final String dateTime = format.format(new Date(clock.time()));
        out.print(dateTime);
        out.print(' ');
        for (int i = 0; i < CONSOLE_WIDTH - dateTime.length() - 1; i++) {
            out.print('=');
        }
        out.println();
        for (final Entry<String, SortedMap<MetricName, Metric>> entry : getMetricsRegistry().groupedMetrics(predicate).entrySet()) {
            out.print(entry.getKey());
            out.println(':');
            for (final Entry<MetricName, Metric> subEntry : entry.getValue().entrySet()) {
                out.print("  ");
                out.print(subEntry.getKey().getName());
                out.println(':');
                subEntry.getValue().processWith(this, subEntry.getKey(), out);
                out.println();
            }
            out.println();
        }
        out.println();
        out.flush();
    } catch (final Exception e) {
        e.printStackTrace(out);
    }
}
Also used : MetricName(com.yammer.metrics.core.MetricName) DateFormat(java.text.DateFormat) SortedMap(java.util.SortedMap) Metric(com.yammer.metrics.core.Metric) Date(java.util.Date)

Aggregations

Metric (com.yammer.metrics.core.Metric)2 Counter (com.yammer.metrics.core.Counter)1 MetricName (com.yammer.metrics.core.MetricName)1 DateFormat (java.text.DateFormat)1 Date (java.util.Date)1 SortedMap (java.util.SortedMap)1