@Override public String getName() { return delegate.getKey().getName(); } }
@Override public boolean equals(final Object o) { if (this == o) { return true; } if (!Counter.class.isInstance(o)) { return false; } final Counter that = Counter.class.cast(o); return key.equals(that.getKey()); }
public boolean equals(final Object o) { if (this == o) { return true; } if (!Counter.class.isInstance(o)) { return false; } final Counter that = Counter.class.cast(o); return key.equals(that.getKey()); }
@Override public String toString() { final StringBuilder stb = new StringBuilder(); if (counter != null) { stb.append("Execution for ").append(counter.getKey().toString()).append(" "); } if (stoped) { stb.append("stoped after ").append(getElapsedTime()).append("ns"); } else { stb.append("running for ").append(getElapsedTime()).append("ns"); } return stb.toString(); } }
@Override public String getRole() { return delegate.getKey().getRole().getName(); }
@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; }