use of com.codahale.metrics.Histogram in project cassandra by apache.
the class ClientMetrics method init.
public synchronized void init(Collection<Server> servers) {
if (initialized)
return;
this.servers = servers;
// deprecated the lower-cased initial letter metric names in 4.0
registerGauge("ConnectedNativeClients", "connectedNativeClients", this::countConnectedClients);
registerGauge("ConnectedNativeClientsByUser", "connectedNativeClientsByUser", this::countConnectedClientsByUser);
registerGauge("Connections", "connections", this::connectedClients);
registerGauge("ClientsByProtocolVersion", "clientsByProtocolVersion", this::recentClientStats);
registerGauge("RequestsSize", ClientResourceLimits::getCurrentGlobalUsage);
Reservoir ipUsageReservoir = ClientResourceLimits.ipUsageReservoir();
Metrics.register(factory.createMetricName("RequestsSizeByIpDistribution"), new Histogram(ipUsageReservoir) {
public long getCount() {
return ipUsageReservoir.size();
}
});
authSuccess = registerMeter("AuthSuccess");
authFailure = registerMeter("AuthFailure");
pausedConnections = new AtomicInteger();
pausedConnectionsGauge = registerGauge("PausedConnections", pausedConnections::get);
requestDiscarded = registerMeter("RequestDiscarded");
protocolException = registerMeter("ProtocolException");
unknownException = registerMeter("UnknownException");
initialized = true;
}
use of com.codahale.metrics.Histogram in project storm by apache.
the class Executor method processHistograms.
private void processHistograms(int taskId, List<IMetricsConsumer.DataPoint> dataPoints) {
Map<String, Histogram> histograms = workerData.getMetricRegistry().getTaskHistograms(taskId);
for (Map.Entry<String, Histogram> entry : histograms.entrySet()) {
Snapshot snapshot = entry.getValue().getSnapshot();
addSnapshotDatapoints(entry.getKey(), snapshot, dataPoints);
IMetricsConsumer.DataPoint dataPoint = new IMetricsConsumer.DataPoint(entry.getKey() + ".count", entry.getValue().getCount());
dataPoints.add(dataPoint);
}
}
use of com.codahale.metrics.Histogram in project jstorm by alibaba.
the class TopologyMetricContext method mergeHistograms.
/**
* histograms are sampled, but we just update points
*/
public void mergeHistograms(MetricInfo metricInfo, String meta, Map<Integer, MetricSnapshot> data, Map<String, Integer> metaCounters, Map<String, Map<Integer, Histogram>> histograms) {
Map<Integer, MetricSnapshot> existing = metricInfo.get_metrics().get(meta);
if (existing == null) {
metricInfo.put_to_metrics(meta, data);
Map<Integer, Histogram> histogramMap = new HashMap<>();
for (Map.Entry<Integer, MetricSnapshot> dataEntry : data.entrySet()) {
Histogram histogram = MetricUtils.metricSnapshot2Histogram(dataEntry.getValue());
histogramMap.put(dataEntry.getKey(), histogram);
}
histograms.put(meta, histogramMap);
} else {
for (Map.Entry<Integer, MetricSnapshot> dataEntry : data.entrySet()) {
Integer win = dataEntry.getKey();
MetricSnapshot snapshot = dataEntry.getValue();
MetricSnapshot old = existing.get(win);
if (old == null) {
existing.put(win, snapshot);
histograms.get(meta).put(win, MetricUtils.metricSnapshot2Histogram(snapshot));
} else {
if (snapshot.get_ts() >= old.get_ts()) {
old.set_ts(snapshot.get_ts());
Histogram histogram = histograms.get(meta).get(win);
Snapshot updateSnapshot = histogram.getSnapshot();
if (updateSnapshot instanceof JAverageSnapshot) {
sumMetricSnapshot(((JAverageSnapshot) updateSnapshot).getMetricSnapshot(), snapshot);
} else {
// update points
MetricUtils.updateHistogramPoints(histogram, snapshot.get_points(), snapshot.get_pointSize());
}
}
}
}
}
updateMetricCounters(meta, metaCounters);
}
use of com.codahale.metrics.Histogram in project graylog2-server by Graylog2.
the class MetricUtilsTest method mapSupportsHistogram.
@Test
public void mapSupportsHistogram() {
final Histogram histogram = new Histogram(new UniformReservoir());
histogram.update(23);
final Map<String, Object> map = MetricUtils.map("metric", histogram);
assertThat(map).containsEntry("type", "histogram").extracting("metric").extracting("count").containsExactly(1L);
}
use of com.codahale.metrics.Histogram in project graylog2-server by Graylog2.
the class SearchesIT method fieldStatsRecordsMetrics.
@Test
public void fieldStatsRecordsMetrics() throws Exception {
importFixture("org/graylog2/indexer/searches/SearchesIT.json");
FieldStatsResult result = searches.fieldStats("n", "*", AbsoluteRange.create(new DateTime(2015, 1, 1, 0, 0, DateTimeZone.UTC), new DateTime(2015, 1, 2, 0, 0, DateTimeZone.UTC)));
assertThat(metricRegistry.getTimers()).containsKey(REQUEST_TIMER_NAME);
assertThat(metricRegistry.getHistograms()).containsKey(RANGES_HISTOGRAM_NAME);
Timer timer = metricRegistry.timer(REQUEST_TIMER_NAME);
assertThat(timer.getCount()).isEqualTo(1L);
Histogram histogram = metricRegistry.histogram(RANGES_HISTOGRAM_NAME);
assertThat(histogram.getCount()).isEqualTo(1L);
assertThat(histogram.getSnapshot().getValues()).containsExactly(86400L);
}
Aggregations