blob: 1c4baead5a5cd3ccea4a032dc1577644f5091c67 [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
pankaja17630a2014-10-01 18:19:37 -070062 /**
63 * Creates a Meter metric.
64 *
65 * @param component component the Meter is defined in
66 * @param feature feature the Meter is defined in
67 * @param metricName local name of the metric
68 * @return the created Meter Metric
69 */
pankaj3855bcb2014-10-01 18:17:31 -070070 Meter createMeter(MetricsComponent component,
71 MetricsFeature feature,
72 String metricName);
73
pankaj390abbc2014-10-01 17:01:05 -070074 /**
75 * Registers an already created Metric. This is used for situation where a
76 * caller needs to allocate its own Metric, but still register it with the
77 * system.
78 *
79 * @param <T> Metric type
80 * @param component component the Metric is defined in
81 * @param feature feature the Metric is defined in
82 * @param metricName local name of the metric
83 * @param metric Metric to register
84 * @return the registered Metric
85 */
86 <T extends Metric> T registerMetric(
87 MetricsComponent component,
88 MetricsFeature feature,
89 String metricName,
90 T metric);
91
92 /**
93 * Fetches the existing Timers.
94 *
95 * @param filter filter to use to select Timers
96 * @return a map of the Timers that match the filter, with the key as the
97 * name String to the Timer.
98 */
99 Map<String, Timer> getTimers(MetricFilter filter);
100
101 /**
102 * Fetches the existing Gauges.
103 *
104 * @param filter filter to use to select Gauges
105 * @return a map of the Gauges that match the filter, with the key as the
106 * name String to the Gauge.
107 */
108 Map<String, Gauge> getGauges(MetricFilter filter);
109
110 /**
111 * Fetches the existing Counters.
112 *
113 * @param filter filter to use to select Counters
114 * @return a map of the Counters that match the filter, with the key as the
115 * name String to the Counter.
116 */
117 Map<String, Counter> getCounters(MetricFilter filter);
118
119 /**
120 * Fetches the existing Meters.
121 *
122 * @param filter filter to use to select Meters
123 * @return a map of the Meters that match the filter, with the key as the
124 * name String to the Meter.
125 */
126 Map<String, Meter> getMeters(MetricFilter filter);
127
128 /**
129 * Fetches the existing Histograms.
130 *
131 * @param filter filter to use to select Histograms
132 * @return a map of the Histograms that match the filter, with the key as the
133 * name String to the Histogram.
134 */
135 Map<String, Histogram> getHistograms(MetricFilter filter);
136 /**
137 * Removes all Metrics that match a given filter.
138 *
139 * @param filter filter to use to select the Metrics to remove.
140 */
141 void removeMatching(MetricFilter filter);
142
143}