Package com.yammer.metrics.core

Examples of com.yammer.metrics.core.Metric


    }

    private void sendRegularMetrics(Date timestamp) {
        for (Map.Entry<String, SortedMap<MetricName, Metric>> entry : getMetricsRegistry().groupedMetrics(predicate).entrySet()) {
            for (Map.Entry<MetricName, Metric> subEntry : entry.getValue().entrySet()) {
                final Metric metric = subEntry.getValue();
                if (metric != null) {
                    try {
                        metric.processWith(this, subEntry.getKey(), timestamp);
                    } catch (Exception ignored) {
                        LOG.error("Error printing regular metrics:", ignored);
                    }
                }
            }
View Full Code Here


   * @param name String name of Gauge
   * @param <T> value type Gauge returns
   * @return Gauge<T> from MetricsRegistry
   */
  public <T> Gauge<T> getExistingGauge(String name) {
    Metric metric = registry.allMetrics().get(makeMetricName(name));
    return metric instanceof Gauge ? (Gauge<T>) metric : null;
  }
View Full Code Here

                // Parse all of the metrics in the message
                for (JSONMetric jsonMetric : jsonMetrics) {
                    if (!metricCache.containsKey(jsonMetric.getName())) {
                        logger.info("Creating new " + jsonMetric.getType().name() + " metric for '" + jsonMetric.getName() + "'");
                        Metric newMetric = createMetric(jsonMetric);
                        metricCache.put(jsonMetric.getName(), newMetric);
                    }

                    // Record the update
                    logger.debug("Updating " + jsonMetric.getType() + " '" + jsonMetric.getName() + "' with <" + jsonMetric.getValue() + ">");
View Full Code Here

    testHandler.consumer.start();

    final long start = System.currentTimeMillis();

    Metric metric = null;
    String name = "eventCount";
    metric = Metrics.newGauge(ZoiePerf.class, name, new GaugeMetric<Long>() {

      @Override
      public Long value() {
View Full Code Here

                // Parse all of the metrics in the message
                for (JSONMetric jsonMetric : jsonMetrics) {
                    if (!metricCache.containsKey(jsonMetric.getName())) {
                        logger.info("Creating new " + jsonMetric.getType().name() + " metric for '" + jsonMetric.getName() + "'");
                        Metric newMetric = createMetric(jsonMetric);
                        metricCache.put(jsonMetric.getName(), newMetric);
                    }

                    // Record the update
                    logger.debug("Updating '" + jsonMetric.getName() + "' with <" + jsonMetric.getValue() + ">");
View Full Code Here

    final Set<Entry<MetricName, Metric>> entrySet = metricMap.entrySet();

    for (final Entry<MetricName, Metric> entry : entrySet) {

      final MetricName name = entry.getKey();
      final Metric metric = entry.getValue();

      if (metric instanceof Counter) {
        ((Counter) metric).clear();
      }
View Full Code Here

    @Test
    public void testCreateMetric_ShortName() {
        String name = "test" + Math.random();
        jsonMetric.setName(name);
        Metric metric = metricCatcher.createMetric(jsonMetric);
        Map<MetricName, Metric> allMetrics = Metrics.defaultRegistry().allMetrics();

        MetricName metricName = new MetricName(name, "", "");
        assertTrue(allMetrics.containsKey(metricName));

        Metric actual = allMetrics.get(metricName);
        assertEquals(metric, actual);
    }
View Full Code Here

    public void tearDown() throws Exception {
    }

    @Test
    public void testCreateMetric() {
        Metric metric = metricCatcher.createMetric(jsonMetric);

        assertEquals(Meter.class, metric.getClass());

        Meter meterMetric = ((Meter) metric);
        // All metrics are in minutes :-( plz2fix
        assertEquals(TimeUnit.MINUTES, meterMetric.rateUnit());
    }
View Full Code Here

TOP

Related Classes of com.yammer.metrics.core.Metric

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.