001package org.avaje.metric; 002 003/** 004 * Metric that collects long values (e.g. total bytes sent). 005 * <p> 006 * Used when events have a value such as bytes sent, bytes received, lines read etc. 007 * <pre> 008 * <code> 009 * // Declare the metric (typically as a static field) 010 * static final ValueMetric totalBytesSentMetric = MetricManager.getValueMetric(MyService.class, "totalBytesSent"); 011 * ... 012 * 013 * public void performSomeIO() { 014 * 015 * long bytesSent = ... 016 * 017 * totalBytesSentMetric.addEvent(bytesSent); 018 * ... 019 * } 020 * 021 * </code> 022 * </pre> 023 */ 024public interface ValueMetric extends Metric { 025 026 /** 027 * Add a value (bytes, time, rows etc). 028 */ 029 void addEvent(long value); 030 031 /** 032 * Return the count of values collected (since the last reset/collection). 033 */ 034 long getCount(); 035 036 /** 037 * Return the total of all the values (since the last reset/collection). 038 */ 039 long getTotal(); 040 041 /** 042 * Return the Max value collected (since the last reset/collection). 043 */ 044 long getMax(); 045 046 /** 047 * Return the mean value rounded up for the values collected since the last reset/collection. 048 */ 049 long getMean(); 050 051}