Search in sources :

Example 6 with Histogram

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]}]}}");
}
Also used : MetricName(com.yammer.metrics.core.MetricName) Histogram(com.yammer.metrics.core.Histogram) WavefrontHistogram(com.yammer.metrics.core.WavefrontHistogram) Test(org.junit.Test)

Example 7 with Histogram

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}}");
}
Also used : MetricName(com.yammer.metrics.core.MetricName) Histogram(com.yammer.metrics.core.Histogram) WavefrontHistogram(com.yammer.metrics.core.WavefrontHistogram) Test(org.junit.Test)

Example 8 with Histogram

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);
}
Also used : Histogram(com.yammer.metrics.core.Histogram)

Example 9 with Histogram

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();
        }
    }
}
Also used : AggregatedHistogram(com.linkedin.pinot.common.metrics.AggregatedHistogram) Histogram(com.yammer.metrics.core.Histogram) LatencyMetric(com.linkedin.pinot.common.metrics.LatencyMetric) ArrayList(java.util.ArrayList) RoutingTableConfig(com.linkedin.pinot.transport.config.RoutingTableConfig) PerTableRoutingConfig(com.linkedin.pinot.transport.config.PerTableRoutingConfig) ArrayList(java.util.ArrayList) List(java.util.List) AggregatedHistogram(com.linkedin.pinot.common.metrics.AggregatedHistogram) ServerInstance(com.linkedin.pinot.common.response.ServerInstance)

Example 10 with Histogram

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);
    }
}
Also used : Snapshot(com.yammer.metrics.stats.Snapshot) Histogram(com.yammer.metrics.core.Histogram) ArrayList(java.util.ArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) Sampling(com.yammer.metrics.core.Sampling)

Aggregations

Histogram (com.yammer.metrics.core.Histogram)15 WavefrontHistogram (com.yammer.metrics.core.WavefrontHistogram)11 Test (org.junit.Test)10 MetricName (com.yammer.metrics.core.MetricName)7 TaggedMetricName (com.wavefront.common.TaggedMetricName)2 Counter (com.yammer.metrics.core.Counter)2 ArrayList (java.util.ArrayList)2 AggregatedHistogram (com.linkedin.pinot.common.metrics.AggregatedHistogram)1 LatencyMetric (com.linkedin.pinot.common.metrics.LatencyMetric)1 ServerInstance (com.linkedin.pinot.common.response.ServerInstance)1 PerTableRoutingConfig (com.linkedin.pinot.transport.config.PerTableRoutingConfig)1 RoutingTableConfig (com.linkedin.pinot.transport.config.RoutingTableConfig)1 ClusterId (com.nokia.dempsy.config.ClusterId)1 Destination (com.nokia.dempsy.messagetransport.Destination)1 Sender (com.nokia.dempsy.messagetransport.Sender)1 SenderFactory (com.nokia.dempsy.messagetransport.SenderFactory)1 StatsCollector (com.nokia.dempsy.monitoring.StatsCollector)1 BasicStatsCollector (com.nokia.dempsy.monitoring.basic.BasicStatsCollector)1 StatsCollectorFactoryCoda (com.nokia.dempsy.monitoring.coda.StatsCollectorFactoryCoda)1 MetricsRegistry (com.yammer.metrics.core.MetricsRegistry)1