blob: b0c7901e11f317cdb1466ca9d2c98a1ed6dd73ee [file] [log] [blame]
pankaj390abbc2014-10-01 17:01:05 -07001package org.onlab.metrics;
2
3import java.util.Map;
4
5import com.codahale.metrics.Counter;
6import com.codahale.metrics.Gauge;
7import com.codahale.metrics.Histogram;
8import com.codahale.metrics.Meter;
9import com.codahale.metrics.Metric;
10import com.codahale.metrics.MetricFilter;
11import com.codahale.metrics.Timer;
12
13/**
14 * Metrics Service to collect metrics.
15 */
16interface MetricsService {
17
18 /**
19 * Registers a component.
20 *
21 * @param name name of the Component to register
22 * @return MetricsComponent object that can be used to create Metrics.
23 */
24 MetricsComponent registerComponent(String name);
25
26 /**
27 * Creates a Counter metric.
28 *
29 * @param component component the Counter is defined in
30 * @param feature feature the Counter is defined in
31 * @param metricName local name of the metric
32 * @return the created Counter Meteric
33 */
34 Counter createCounter(MetricsComponent component,
35 MetricsFeature feature,
36 String metricName);
37
38 /**
39 * Creates a Histogram metric.
40 *
41 * @param component component the Histogram is defined in
42 * @param feature feature the Histogram is defined in
43 * @param metricName local name of the metric
44 * @return the created Histogram Metric
45 */
46 Histogram createHistogram(MetricsComponent component,
47 MetricsFeature feature,
48 String metricName);
49
50 /**
51 * Creates a Timer metric.
52 *
53 * @param component component the Timer is defined in
54 * @param feature feature the Timer is defined in
55 * @param metricName local name of the metric
56 * @return the created Timer Metric
57 */
58 Timer createTimer(MetricsComponent component,
59 MetricsFeature feature,
60 String metricName);
61
pankaj3855bcb2014-10-01 18:17:31 -070062 Meter createMeter(MetricsComponent component,
63 MetricsFeature feature,
64 String metricName);
65
pankaj390abbc2014-10-01 17:01:05 -070066 /**
67 * Registers an already created Metric. This is used for situation where a
68 * caller needs to allocate its own Metric, but still register it with the
69 * system.
70 *
71 * @param <T> Metric type
72 * @param component component the Metric is defined in
73 * @param feature feature the Metric is defined in
74 * @param metricName local name of the metric
75 * @param metric Metric to register
76 * @return the registered Metric
77 */
78 <T extends Metric> T registerMetric(
79 MetricsComponent component,
80 MetricsFeature feature,
81 String metricName,
82 T metric);
83
84 /**
85 * Fetches the existing Timers.
86 *
87 * @param filter filter to use to select Timers
88 * @return a map of the Timers that match the filter, with the key as the
89 * name String to the Timer.
90 */
91 Map<String, Timer> getTimers(MetricFilter filter);
92
93 /**
94 * Fetches the existing Gauges.
95 *
96 * @param filter filter to use to select Gauges
97 * @return a map of the Gauges that match the filter, with the key as the
98 * name String to the Gauge.
99 */
100 Map<String, Gauge> getGauges(MetricFilter filter);
101
102 /**
103 * Fetches the existing Counters.
104 *
105 * @param filter filter to use to select Counters
106 * @return a map of the Counters that match the filter, with the key as the
107 * name String to the Counter.
108 */
109 Map<String, Counter> getCounters(MetricFilter filter);
110
111 /**
112 * Fetches the existing Meters.
113 *
114 * @param filter filter to use to select Meters
115 * @return a map of the Meters that match the filter, with the key as the
116 * name String to the Meter.
117 */
118 Map<String, Meter> getMeters(MetricFilter filter);
119
120 /**
121 * Fetches the existing Histograms.
122 *
123 * @param filter filter to use to select Histograms
124 * @return a map of the Histograms that match the filter, with the key as the
125 * name String to the Histogram.
126 */
127 Map<String, Histogram> getHistograms(MetricFilter filter);
128 /**
129 * Removes all Metrics that match a given filter.
130 *
131 * @param filter filter to use to select the Metrics to remove.
132 */
133 void removeMatching(MetricFilter filter);
134
135}