|
1 | 1 | package com.codahale.metrics.ehcache;
|
2 | 2 |
|
3 |
| -import com.codahale.metrics.Gauge; |
4 | 3 | import com.codahale.metrics.MetricRegistry;
|
5 | 4 | import com.codahale.metrics.Timer;
|
6 | 5 | import net.sf.ehcache.CacheException;
|
@@ -118,56 +117,56 @@ public class InstrumentedEhcache extends EhcacheDecoratorAdapter {
|
118 | 117 | public static Ehcache instrument(MetricRegistry registry, final Ehcache cache) {
|
119 | 118 |
|
120 | 119 | final String prefix = name(cache.getClass(), cache.getName());
|
121 |
| - registry.register(name(prefix, "hits"), |
122 |
| - (Gauge<Long>) () -> cache.getStatistics().cacheHitCount()); |
| 120 | + registry.registerGauge(name(prefix, "hits"), |
| 121 | + () -> cache.getStatistics().cacheHitCount()); |
123 | 122 |
|
124 |
| - registry.register(name(prefix, "in-memory-hits"), |
125 |
| - (Gauge<Long>) () -> cache.getStatistics().localHeapHitCount()); |
| 123 | + registry.registerGauge(name(prefix, "in-memory-hits"), |
| 124 | + () -> cache.getStatistics().localHeapHitCount()); |
126 | 125 |
|
127 |
| - registry.register(name(prefix, "off-heap-hits"), |
128 |
| - (Gauge<Long>) () -> cache.getStatistics().localOffHeapHitCount()); |
| 126 | + registry.registerGauge(name(prefix, "off-heap-hits"), |
| 127 | + () -> cache.getStatistics().localOffHeapHitCount()); |
129 | 128 |
|
130 |
| - registry.register(name(prefix, "on-disk-hits"), |
131 |
| - (Gauge<Long>) () -> cache.getStatistics().localDiskHitCount()); |
| 129 | + registry.registerGauge(name(prefix, "on-disk-hits"), |
| 130 | + () -> cache.getStatistics().localDiskHitCount()); |
132 | 131 |
|
133 |
| - registry.register(name(prefix, "misses"), |
134 |
| - (Gauge<Long>) () -> cache.getStatistics().cacheMissCount()); |
| 132 | + registry.registerGauge(name(prefix, "misses"), |
| 133 | + () -> cache.getStatistics().cacheMissCount()); |
135 | 134 |
|
136 |
| - registry.register(name(prefix, "in-memory-misses"), |
137 |
| - (Gauge<Long>) () -> cache.getStatistics().localHeapMissCount()); |
| 135 | + registry.registerGauge(name(prefix, "in-memory-misses"), |
| 136 | + () -> cache.getStatistics().localHeapMissCount()); |
138 | 137 |
|
139 |
| - registry.register(name(prefix, "off-heap-misses"), |
140 |
| - (Gauge<Long>) () -> cache.getStatistics().localOffHeapMissCount()); |
| 138 | + registry.registerGauge(name(prefix, "off-heap-misses"), |
| 139 | + () -> cache.getStatistics().localOffHeapMissCount()); |
141 | 140 |
|
142 |
| - registry.register(name(prefix, "on-disk-misses"), |
143 |
| - (Gauge<Long>) () -> cache.getStatistics().localDiskMissCount()); |
| 141 | + registry.registerGauge(name(prefix, "on-disk-misses"), |
| 142 | + () -> cache.getStatistics().localDiskMissCount()); |
144 | 143 |
|
145 |
| - registry.register(name(prefix, "objects"), |
146 |
| - (Gauge<Long>) () -> cache.getStatistics().getSize()); |
| 144 | + registry.registerGauge(name(prefix, "objects"), |
| 145 | + () -> cache.getStatistics().getSize()); |
147 | 146 |
|
148 |
| - registry.register(name(prefix, "in-memory-objects"), |
149 |
| - (Gauge<Long>) () -> cache.getStatistics().getLocalHeapSize()); |
| 147 | + registry.registerGauge(name(prefix, "in-memory-objects"), |
| 148 | + () -> cache.getStatistics().getLocalHeapSize()); |
150 | 149 |
|
151 |
| - registry.register(name(prefix, "off-heap-objects"), |
152 |
| - (Gauge<Long>) () -> cache.getStatistics().getLocalOffHeapSize()); |
| 150 | + registry.registerGauge(name(prefix, "off-heap-objects"), |
| 151 | + () -> cache.getStatistics().getLocalOffHeapSize()); |
153 | 152 |
|
154 |
| - registry.register(name(prefix, "on-disk-objects"), |
155 |
| - (Gauge<Long>) () -> cache.getStatistics().getLocalDiskSize()); |
| 153 | + registry.registerGauge(name(prefix, "on-disk-objects"), |
| 154 | + () -> cache.getStatistics().getLocalDiskSize()); |
156 | 155 |
|
157 |
| - registry.register(name(prefix, "mean-get-time"), |
158 |
| - (Gauge<Double>) () -> cache.getStatistics().cacheGetOperation().latency().average().value()); |
| 156 | + registry.registerGauge(name(prefix, "mean-get-time"), |
| 157 | + () -> cache.getStatistics().cacheGetOperation().latency().average().value()); |
159 | 158 |
|
160 |
| - registry.register(name(prefix, "mean-search-time"), |
161 |
| - (Gauge<Double>) () -> cache.getStatistics().cacheSearchOperation().latency().average().value()); |
| 159 | + registry.registerGauge(name(prefix, "mean-search-time"), |
| 160 | + () -> cache.getStatistics().cacheSearchOperation().latency().average().value()); |
162 | 161 |
|
163 |
| - registry.register(name(prefix, "eviction-count"), |
164 |
| - (Gauge<Long>) () -> cache.getStatistics().cacheEvictionOperation().count().value()); |
| 162 | + registry.registerGauge(name(prefix, "eviction-count"), |
| 163 | + () -> cache.getStatistics().cacheEvictionOperation().count().value()); |
165 | 164 |
|
166 |
| - registry.register(name(prefix, "searches-per-second"), |
167 |
| - (Gauge<Double>) () -> cache.getStatistics().cacheSearchOperation().rate().value()); |
| 165 | + registry.registerGauge(name(prefix, "searches-per-second"), |
| 166 | + () -> cache.getStatistics().cacheSearchOperation().rate().value()); |
168 | 167 |
|
169 |
| - registry.register(name(prefix, "writer-queue-size"), |
170 |
| - (Gauge<Long>) () -> cache.getStatistics().getWriterQueueLength()); |
| 168 | + registry.registerGauge(name(prefix, "writer-queue-size"), |
| 169 | + () -> cache.getStatistics().getWriterQueueLength()); |
171 | 170 |
|
172 | 171 | return new InstrumentedEhcache(registry, cache);
|
173 | 172 | }
|
|
0 commit comments