Package com.yammer.metrics.core

Examples of com.yammer.metrics.core.MetricName


     * @param metric name of the metric
     * @param indexerName name of the indexer
     * @return {@code MetricName} instance scoped to the given indexer name
     */
    public static MetricName metricName(Class<?> producerClass, String metric, String indexerName) {
        return new MetricName("hbaseindexer", producerClass.getSimpleName(), metric, indexerName);
    }
View Full Code Here


        SortedMap<String, SortedMap<MetricName, Metric>> groupedMetrics = Metrics.defaultRegistry().groupedMetrics(
                new IndexerMetricsUtil.IndexerMetricPredicate());
        for (Entry<String, SortedMap<MetricName, Metric>> metricsGroupEntry : groupedMetrics.entrySet()) {
            SortedMap<MetricName, Metric> metricsGroupMap = metricsGroupEntry.getValue();
            for (Entry<MetricName, Metric> metricEntry : metricsGroupMap.entrySet()) {
                MetricName metricName = metricEntry.getKey();
                Metric metric = metricEntry.getValue();
                String counterName = metricName.getType() + ": " + metricName.getName();
                if (metric instanceof Counter) {
                    Counter counter = (Counter) metric;
                    context.getCounter(COUNTER_GROUP, counterName).increment(counter.count());
                } else if (metric instanceof Meter) {
                    Meter meter = (Meter) metric;
View Full Code Here

    @Test
    public void testMetricName() {
        String metric = "_metric_";
        String indexerName = "_index_name_";
        MetricName metricName = IndexerMetricsUtil.metricName(getClass(), metric, indexerName);
       
        assertEquals("hbaseindexer", metricName.getGroup());
        assertEquals("IndexerMetricsUtilTest", metricName.getType());
        assertEquals(metric, metricName.getName());
        assertEquals(indexerName, metricName.getScope());
    }
View Full Code Here

    public void onMetricRemoved(MetricName name) {
        super.onMetricRemoved(newMetricName(name));
    }

    private MetricName newMetricName(MetricName name) {
        return new MetricName(name.getGroup(), name.getType(), name.getName(), name.getScope(), webappName+"."+name.getMBeanName());
    }
View Full Code Here

            mbeanName.append("type=").append(type);
            mbeanName.append(",keyspace=").append(keyspaceName);
            mbeanName.append(",scope=").append(columnFamilyName);
            mbeanName.append(",name=").append(metricName);

            return new MetricName(groupName, type, metricName, keyspaceName + "." + columnFamilyName, mbeanName.toString());
        }
View Full Code Here

     * @param type Type of Cache to identify metrics.
     * @param cache Cache to measure metrics
     */
    public CacheMetrics(String type, final ICache cache)
    {
        capacityInBytes = Metrics.newGauge(new MetricName(GROUP_NAME, TYPE_NAME, "CapacityInBytes", type), new Gauge<Long>()
        {
            public Long value()
            {
                return cache.capacity();
            }
        });
        hits = Metrics.newMeter(new MetricName(GROUP_NAME, TYPE_NAME, "Hits", type), "hits", TimeUnit.SECONDS);
        requests = Metrics.newMeter(new MetricName(GROUP_NAME, TYPE_NAME, "Requests", type), "requests", TimeUnit.SECONDS);
        hitRate = Metrics.newGauge(new MetricName(GROUP_NAME, TYPE_NAME, "HitRate", type), new RatioGauge()
        {
            protected double getNumerator()
            {
                return hits.count();
            }

            protected double getDenominator()
            {
                return requests.count();
            }
        });
        size = Metrics.newGauge(new MetricName(GROUP_NAME, TYPE_NAME, "Size", type), new Gauge<Long>()
        {
            public Long value()
            {
                return cache.weightedSize();
            }
View Full Code Here

        if (config.getProvider() != null) {
            resourceConfig.register(config.getProvider());
        }

        final com.yammer.metrics.core.Timer postTimer =
                Metrics.newTimer(new MetricName(MBEAN_GROUP_NAME, config.getMetricName(), "posts"),
                        TimeUnit.MILLISECONDS, TimeUnit.SECONDS);
        final com.yammer.metrics.core.Timer getTimer =
                Metrics.newTimer(new MetricName(MBEAN_GROUP_NAME, config.getMetricName(), "gets"),
                        TimeUnit.MILLISECONDS, TimeUnit.SECONDS);
        final com.yammer.metrics.core.Timer putTimer =
                Metrics.newTimer(new MetricName(MBEAN_GROUP_NAME, config.getMetricName(), "puts"),
                        TimeUnit.MILLISECONDS, TimeUnit.SECONDS);


        final boolean isText = config.getType().equals(MediaType.TEXT_PLAIN_TYPE);
        final Resource.Builder builder = Resource.builder("/" + ROOT_PATH);
View Full Code Here

            this.scope = scope;
        }

        public MetricName createMetricName(String metricName)
        {
            return new MetricName(group, type, metricName, scope);
        }
View Full Code Here

            mbeanName.append("type=").append(type);
            mbeanName.append(",keyspace=").append(keyspaceName);
            mbeanName.append(",scope=").append(columnFamilyName);
            mbeanName.append(",name=").append(metricName);

            return new MetricName(groupName, type, metricName, keyspaceName + "." + columnFamilyName, mbeanName.toString());
        }
View Full Code Here

     * @param type Type of Cache to identify metrics.
     * @param cache Cache to measure metrics
     */
    public CacheMetrics(String type, final ICache cache)
    {
        capacity = Metrics.newGauge(new MetricName(GROUP_NAME, TYPE_NAME, "Capacity", type), new Gauge<Long>()
        {
            public Long value()
            {
                return cache.capacity();
            }
        });
        hits = Metrics.newMeter(new MetricName(GROUP_NAME, TYPE_NAME, "Hits", type), "hits", TimeUnit.SECONDS);
        requests = Metrics.newMeter(new MetricName(GROUP_NAME, TYPE_NAME, "Requests", type), "requests", TimeUnit.SECONDS);
        hitRate = Metrics.newGauge(new MetricName(GROUP_NAME, TYPE_NAME, "HitRate", type), new RatioGauge()
        {
            protected double getNumerator()
            {
                return hits.count();
            }

            protected double getDenominator()
            {
                return requests.count();
            }
        });
        size = Metrics.newGauge(new MetricName(GROUP_NAME, TYPE_NAME, "Size", type), new Gauge<Long>()
        {
            public Long value()
            {
                return cache.weightedSize();
            }
        });
        entries = Metrics.newGauge(new MetricName(GROUP_NAME, TYPE_NAME, "Entries", type), new Gauge<Integer>()
        {
            public Integer value()
            {
                return cache.size();
            }
View Full Code Here

TOP

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

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.