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