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 with the number of loaded beans or rows.
017   */
018  void add(long micros, long beans);
019
020  /**
021   * Add a time event given the start nanos.
022   */
023  void addSinceNanos(long startNanos);
024
025  /**
026   * Add a time event given the start nanos and bean count.
027   */
028  void addSinceNanos(long startNanos, long beans);
029
030  /**
031   * Return true if there are no metrics collected since the last collection.
032   */
033  boolean isEmpty();
034
035  /**
036   * Reset the statistics.
037   */
038  void reset();
039
040  /**
041   * Collect and return a snapshot of the metrics.
042   */
043  TimedMetricStats collect(boolean reset);
044
045  /**
046   * Visit non empty metrics.
047   */
048  void visit(MetricVisitor visitor);
049}