001package io.ebean.metric;
002
003import io.ebean.meta.MetricVisitor;
004
005/**
006 * Metric for timed events like transaction execution times.
007 */
008public interface TimedMetric {
009
010  /**
011   * Add a time event (usually in microseconds).
012   */
013  void add(long micros);
014
015  /**
016   * Add a time event for a batch of beans.
017   */
018  void addBatchSince(long startNanos, int batch);
019
020  /**
021   * Add a time event given the start nanos.
022   */
023  void addSinceNanos(long startNanos);
024
025  /**
026   * Return true if there are no metrics collected since the last collection.
027   */
028  boolean isEmpty();
029
030  /**
031   * Reset the statistics.
032   */
033  void reset();
034
035  /**
036   * Collect and return a snapshot of the metrics.
037   */
038  TimedMetricStats collect(boolean reset);
039
040  /**
041   * Visit non empty metrics.
042   */
043  void visit(MetricVisitor visitor);
044}