001package org.avaje.metric; 002 003/** 004 * Metric based on a counter (long value) typically used to count discrete events. 005 * <p> 006 * Can be used to count discrete events like 'user login'. {@link ValueMetric} would typically 007 * be used when the event has a value (bytes sent, bytes received, lines read etc). 008 * <pre> 009 * <code> 010 * // Declare the counter (typically as a static field) 011 * static final CounterMetric userLoginCounter = MetricManager.getCounterMetric(MyService.class, "userLogin"); 012 * ... 013 * 014 * void performUserLogin() { 015 * 016 * // increment the counter 017 * userLoginCounter.markEvent(); 018 * ... 019 * } 020 * 021 * </code> 022 * </pre> 023 */ 024public interface CounterMetric extends Metric { 025 026 /** 027 * Mark that 1 event has occurred. 028 */ 029 void markEvent(); 030 031 /** 032 * Mark that numberOfEventsOccurred events have occurred. 033 */ 034 void markEvents(long numberOfEventsOccurred); 035 036 /** 037 * Return the current count. 038 */ 039 long getCount(); 040 041}