Package com.yammer.metrics.core

Examples of com.yammer.metrics.core.MetricName


        private final Counter meter;
        private long reported = 0;

        public DifferencingCounter(InetAddress address)
        {
            this.meter = Metrics.newCounter(new MetricName(GROUP_NAME, TYPE_NAME, "Hints_not_stored-" + address.toString()));
        }
View Full Code Here


    /** Total number of bytes compacted since server [re]start */
    public final Counter bytesCompacted;

    public CompactionMetrics(final ThreadPoolExecutor... collectors)
    {
        pendingTasks = Metrics.newGauge(new MetricName(GROUP_NAME, TYPE_NAME, "PendingTasks"), new Gauge<Integer>()
        {
            public Integer value()
            {
                int n = 0;
                for (String tableName : Schema.instance.getTables())
                {
                    for (ColumnFamilyStore cfs : Table.open(tableName).getColumnFamilyStores())
                        n += cfs.getCompactionStrategy().getEstimatedRemainingTasks();
                }
                for (ThreadPoolExecutor collector : collectors)
                    n += collector.getTaskCount() - collector.getCompletedTaskCount();
                return n;
            }
        });
        completedTasks = Metrics.newGauge(new MetricName(GROUP_NAME, TYPE_NAME, "CompletedTasks"), new Gauge<Long>()
        {
            public Long value()
            {
                long completedTasks = 0;
                for (ThreadPoolExecutor collector : collectors)
                    completedTasks += collector.getCompletedTaskCount();
                return completedTasks;
            }
        });
        totalCompactionsCompleted = Metrics.newMeter(new MetricName(GROUP_NAME, TYPE_NAME, "TotalCompactionsCompleted"), "compaction completed", TimeUnit.SECONDS);
        bytesCompacted = Metrics.newCounter(new MetricName(GROUP_NAME, TYPE_NAME, "BytesCompacted"));
    }
View Full Code Here

     * @param jsonMetric A JSONMetric to make a Metric from
     * @return A Metric equivalent to the given JSONMetric
     */
    protected Metric createMetric(JSONMetric jsonMetric) {
        // Split the name from the JSON on dots for the metric group/type/name
        MetricName metricName;
        ArrayList<String> parts = new ArrayList<String>(Arrays.asList(jsonMetric.getName().split("\\.")));
        if (parts.size() >= 3)
            metricName = new MetricName(parts.remove(0), parts.remove(0), StringUtils.join(parts, "."));
        else
            metricName = new MetricName(jsonMetric.getName(), "", "");

        Class<?> metricType = jsonMetric.getMetricClass();
        if (metricType == GaugeMetric.class) {
            return Metrics.newGauge(metricName, new GaugeMetricImpl());
        } else if (metricType == CounterMetric.class) {
View Full Code Here

   * @param metricName name of the metric.
   * @param value to increment the metric by.
   */
  public void counter(Class<?> scope, String metricName, long value) {
    if (!counters.containsKey(metricName)) {
      MetricName name = getMetricName(scope, metricName);
      counters.put(metricName, Metrics.newCounter(name));
    }
    counters.get(metricName).inc(value);
  }
View Full Code Here

   * @param metricName  the name of the {@link Metric}
   * @param scope the scope of the {@link Metric}
   * @return instance of {@link MetricName}
   */
  protected MetricName getMetricName(Class<?> scope, String metricName) {
    return new MetricName(metricGroup, metricType.name(),
                                     metricName,
                                     scope == null ? null : getScope(scope));
  }
View Full Code Here

   * @param metricName name of the metric.
   * @param value to be associated with the metric.
   */
  public void set(String metricName, final float value) {
    if (!gauges.containsKey(metricName)) {
      MetricName name = getMetricName(null, metricName);
      gauges.put(metricName, Metrics.newGauge(name, new Gauge<Float>() {
        @Override
        public Float value() {
          return value;
        }
View Full Code Here

   * @param metricName name of the metric.
   * @param value to increment the meter by.
   */
  public void meter(Class<?> scope, String metricName, long value) {
    if (!meters.containsKey(metricName)) {
      MetricName name = getMetricName(scope, metricName);
      meters.put(metricName,
                 Metrics.newMeter(name, metricName, TimeUnit.SECONDS));
    }
    meters.get(metricName).mark(value);
  }
View Full Code Here

   * @param metricName name of the metric.
   * @param value to be used for histogram.
   */
  public void histogram(Class<?> scope, String metricName, long value) {
    if (!histograms.containsKey(metricName)) {
      MetricName name = getMetricName(scope, metricName);
      histograms.put(metricName, Metrics.newHistogram(name));
    }
    histograms.get(metricName).update(value);
  }
View Full Code Here

     * @param jsonMetric A JSONMetric to make a Metric from
     * @return A Metric equivalent to the given JSONMetric
     */
    protected Metric createMetric(JSONMetric jsonMetric) {
        // Split the name from the JSON on dots for the metric group/type/name
        MetricName metricName;
        ArrayList<String> parts = new ArrayList<String>(Arrays.asList(jsonMetric.getName().split("\\.")));
        if (parts.size() >= 3) {
            metricName = new MetricName(parts.remove(0), parts.remove(0), StringUtils.join(parts, "."));
        } else {
            metricName = new MetricName(jsonMetric.getName(), "", "");
        }

        Class<?> metricType = jsonMetric.getMetricClass();
        if (metricType == Gauge.class) {
            return Metrics.newGauge(metricName, new GaugeMetricImpl());
View Full Code Here

     * @param jsonMetric A JSONMetric to make a Metric from
     * @return A Metric equivalent to the given JSONMetric
     */
    protected Metric createMetric(JSONMetric jsonMetric) {
        // Split the name from the JSON on dots for the metric group/type/name
        MetricName metricName;
        ArrayList<String> parts = new ArrayList<String>(Arrays.asList(jsonMetric.getName().split("\\.")));
        if (parts.size() >= 3)
            metricName = new MetricName(parts.remove(0), parts.remove(0), StringUtils.join(parts, "."));
        else
            metricName = new MetricName(jsonMetric.getName(), "", "");

        Class<?> metricType = jsonMetric.getMetricClass();
        if (metricType == Gauge.class) {
            return Metrics.newGauge(metricName, new GaugeMetricImpl());
        } else if (metricType == Counter.class) {
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.