Replace metrics.CloseableMetric with a more generic utils.Closeable
[serviceutils.git] / metrics / api / src / main / java / org / opendaylight / infrautils / metrics / Meter.java
1 /*
2  * Copyright (c) 2017 Red Hat, Inc. and others. All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.infrautils.metrics;
9
10 import org.opendaylight.infrautils.utils.UncheckedCloseable;
11
12 /**
13  * Meter metric, which measures throughput.
14  *
15  * <p>Note that this with <tt>mark()</tt> measures the rate at which a set of events occur;
16  * whereas {@link Counter} is for things which will <tt>increase()</tt> - and can also <tt>decrease()</tt>.
17  */
18 public interface Meter extends UncheckedCloseable {
19
20     /**
21      * Mark the occurrence of an event.
22      */
23     default void mark() {
24         mark(1);
25     }
26
27     /**
28      * Mark the occurrence of a given number of events.
29      */
30     void mark(long howMany);
31
32     /**
33      * Gets the total number of events. Beware that this could have overflown.
34      * This is typically used in unit tests of metrics, more than to expose the metrics in production
35      * (because exposing metrics is really the role of the infrautils metrics implementation of this API).
36      */
37     long get();
38 }