001package org.avaje.metric; 002 003import org.avaje.metric.statistics.MetricStatisticsVisitor; 004 005/** 006 * A Metric that collects statistics on events. 007 * <ul> 008 * <li>TimedMetric and BucketTimedMetric are used for monitoring execution time</li> 009 * <li>CounterMetric is for counting discrete events like 'user logged in'</li> 010 * <li>ValueMetric is used when events have a value like bytes sent, lines read</li> 011 * <li>Gauges measure the current value of a resource like 'used memory' or 'active threads'.</li> 012 * </ul> 013 */ 014public interface Metric { 015 016 /** 017 * Return the name of the metric. 018 */ 019 MetricName getName(); 020 021 /** 022 * Typically this is only called by the MetricManager and tells the metric to collect its underlying statistics for 023 * reporting purposes and in addition resetting and internal counters it has. 024 */ 025 void collect(MetricStatisticsVisitor collector); 026 027 /** 028 * Clear the statistics resetting any internal counters etc. 029 * <p> 030 * Typically the MetricManager takes care of resetting the statistic/counters for the metrics when 031 * it periodically collects and reports all the metrics and you are not expected to use this method. 032 * </p> 033 */ 034 void clear(); 035 036}