@Override public double value(final Counter counter) { return counter.currentConcurrency().get(); }
public CounterStopWatch(final Counter counter) { this.counter = counter; startedAt = nanotime(); concurrencyCounter = counter.currentConcurrency(); final int concurrency = concurrencyCounter.incrementAndGet(); counter.updateConcurrency(concurrency); }
@Override protected void pushCountersByBatch(final Collection<Counter> instances) { for (final Counter counter : instances) { delegate.getOrCreateCounter(counter.getKey(), marker) .update(new M2AwareStatisticalSummary( counter.getMean(), counter.getVariance(), counter.getHits(), counter.getMax(), counter.getMin(), counter.getSum(), counter.getSecondMoment()), counter.currentConcurrency().get()); } }
public StringBuilder counterSnapshot(final Collection<Counter> instances) { final long ts = System.currentTimeMillis(); final StringBuilder events = newEventStream(); for (final Counter counter : instances) { buildEvent(events, COUNTER_TYPE, ts, new MapBuilder() .add(NAME, counter.getKey().getName()) .add(ROLE, counter.getKey().getRole().getName()) .add(UNIT, counter.getKey().getRole().getUnit().getName()) // minimum metrics to be able to aggregate counters later .add(CONCURRENCY, counter.currentConcurrency().intValue()) .add(MEAN, counter.getMean()) .add(VARIANCE, counter.getVariance()) .add(HITS, counter.getHits()) .add(MAX, counter.getMax()) .add(MIN, counter.getMin()) .add(SUM, counter.getSum()) .add(M_2, counter.getSecondMoment()) .map()); } return events; }