use of com.yammer.metrics.core.Histogram in project java by wavefrontHQ.
the class JsonMetricsGeneratorTest method testWavefrontHistogramNoClear.
@Test
public void testWavefrontHistogramNoClear() throws IOException {
Histogram wh = WavefrontHistogram.get(testRegistry, new MetricName("test", "", "metric"), time::get);
wh.update(10);
generate(false, false, false, null);
wh.update(100);
// Simulate the 1 minute has passed and we are ready to flush the histogram
// (i.e. all the values prior to the current minute) over the wire...
time.addAndGet(60001L);
String json = generate(false, false, true, null);
assertThat(json).isEqualTo("{\"test.metric\":{\"bins\":[{\"count\":2,\"startMillis\":0,\"durationMillis\":60000,\"means\":[10.0,100.0],\"counts\":[1,1]}]}}");
}
use of com.yammer.metrics.core.Histogram in project java by wavefrontHQ.
the class JsonMetricsGeneratorTest method testYammerHistogram.
@Test
public void testYammerHistogram() throws IOException {
Histogram wh = testRegistry.newHistogram(new MetricName("test", "", "metric"), false);
wh.update(10);
wh.update(100);
wh.update(1000);
String json = generate(false, false, false, null);
assertThat(json).isEqualTo("{\"test.metric\":{\"count\":3,\"min\":10.0,\"max\":1000.0,\"mean\":370.0,\"sum\":1110.0,\"stddev\":547.4486277268397,\"median\":100.0,\"p75\":1000.0,\"p95\":1000.0,\"p99\":1000.0,\"p999\":1000.0}}");
}
use of com.yammer.metrics.core.Histogram in project kafka by apache.
the class QuorumControllerMetricsTest method assertMetricHistogram.
private static void assertMetricHistogram(MetricsRegistry registry, MetricName metricName, long count, double sum) {
Histogram histogram = (Histogram) registry.allMetrics().get(metricName);
assertEquals(count, histogram.count());
assertEquals(sum, histogram.sum(), .1);
}
use of com.yammer.metrics.core.Histogram in project pinot by linkedin.
the class ScatterGatherPerfTester method run.
public void run() throws Exception {
List<ScatterGatherPerfServer> servers = null;
// Run Servers when mode is RUN_SERVER or RUN_BOTH
if (_mode != ExecutionMode.RUN_CLIENT) {
servers = runServer();
}
if (_mode != ExecutionMode.RUN_SERVER) {
int port = _startPortNum;
// Setup Routing config for clients
RoutingTableConfig config = new RoutingTableConfig();
Map<String, PerTableRoutingConfig> cfg = config.getPerTableRoutingCfg();
PerTableRoutingConfig c = new PerTableRoutingConfig(null);
Map<Integer, List<ServerInstance>> instanceMap = c.getNodeToInstancesMap();
port = _startPortNum;
int numUniqueServers = _remoteServerHosts.size();
for (int i = 0; i < _numServers; i++) {
List<ServerInstance> instances = new ArrayList<ServerInstance>();
String server = null;
if (_mode == ExecutionMode.RUN_BOTH)
server = "localhost";
else
server = _remoteServerHosts.get(i % numUniqueServers);
ServerInstance instance = new ServerInstance(server, port++);
instances.add(instance);
instanceMap.put(i, instances);
}
String server = null;
if (_mode == ExecutionMode.RUN_BOTH)
server = "localhost";
else
server = _remoteServerHosts.get(0);
c.getDefaultServers().add(new ServerInstance(server, port - 1));
cfg.put(_resourceName, c);
System.out.println("Routing Config is :" + cfg);
// Build Clients
List<Thread> clientThreads = new ArrayList<Thread>();
List<ScatterGatherPerfClient> clients = new ArrayList<ScatterGatherPerfClient>();
AggregatedHistogram<Histogram> latencyHistogram = new AggregatedHistogram<Histogram>();
for (int i = 0; i < _numClients; i++) {
ScatterGatherPerfClient c2 = new ScatterGatherPerfClient(config, _requestSize, _resourceName, _asyncRequestDispatch, _numRequests, _maxActiveConnectionsPerClientServerPair, _numResponseReaderThreads);
Thread t = new Thread(c2);
clients.add(c2);
latencyHistogram.add(c2.getLatencyHistogram());
clientThreads.add(t);
}
System.out.println("Starting the clients !!");
long startTimeMs = 0;
// Start Clients
for (Thread t2 : clientThreads) t2.start();
System.out.println("Waiting for clients to finish");
// Wait for clients to finish
for (Thread t2 : clientThreads) t2.join();
Thread.sleep(3000);
System.out.println("Client threads done !!");
int totalRequestsMeasured = 0;
long beginRequestTime = Long.MAX_VALUE;
long endResponseTime = Long.MIN_VALUE;
for (ScatterGatherPerfClient c3 : clients) {
int numRequestsMeasured = c3.getNumRequestsMeasured();
totalRequestsMeasured += numRequestsMeasured;
beginRequestTime = Math.min(beginRequestTime, c3.getBeginFirstRequestTime());
endResponseTime = Math.max(endResponseTime, c3.getEndLastResponseTime());
//System.out.println("2 Num Requests :" + numRequestsMeasured);
//System.out.println("2 time :" + timeTakenMs );
//System.out.println("2 Throughput (Requests/Second) :" + ((numRequestsMeasured* 1.0 * 1000)/timeTakenMs));
}
long totalTimeTakenMs = endResponseTime - beginRequestTime;
System.out.println("Overall Total Num Requests :" + totalRequestsMeasured);
System.out.println("Overall Total time :" + totalTimeTakenMs);
System.out.println("Overall Throughput (Requests/Second) :" + ((totalRequestsMeasured * 1.0 * 1000) / totalTimeTakenMs));
latencyHistogram.refresh();
System.out.println("Latency :" + new LatencyMetric<AggregatedHistogram<Histogram>>(latencyHistogram));
}
if (_mode == ExecutionMode.RUN_BOTH) {
// Shutdown Servers
for (ScatterGatherPerfServer s : servers) {
s.shutdown();
}
}
}
use of com.yammer.metrics.core.Histogram in project pinot by linkedin.
the class AggregatedHistogram method refresh.
/**
* update all stats using underlying histograms
*/
public void refresh() {
List<Double> values = new ArrayList<Double>();
_min = Double.MAX_VALUE;
_max = Double.MIN_VALUE;
_sum = 0;
double meanSum = 0.0;
for (T hist : _histograms) {
if (hist instanceof Histogram) {
Histogram h = (Histogram) hist;
_min = Math.min(_min, h.min());
_max = Math.max(_max, h.max());
_sum += h.sum();
meanSum += h.mean();
} else {
AggregatedHistogram<Sampling> h = (AggregatedHistogram<Sampling>) hist;
_min = Math.min(_min, h.min());
_max = Math.max(_max, h.max());
_sum += h.sum();
meanSum += h.mean();
}
double[] val = hist.getSnapshot().getValues();
for (double d : val) {
values.add(d);
}
}
if (!_histograms.isEmpty()) {
_mean = meanSum / _histograms.size();
}
if (!values.isEmpty()) {
double[] vals = new double[values.size()];
int i = 0;
for (Double d : values) {
vals[i++] = d;
}
_snapshot = new Snapshot(vals);
}
}
Aggregations