Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.yammer.metrics;
  
  
A set of factory methods for creating centrally registered metric instances.
 
 public class Metrics {
     private static final MetricsRegistry DEFAULT_REGISTRY = new MetricsRegistry();
     private static final Thread SHUTDOWN_HOOK = new Thread() {
         public void run() {
             JmxReporter.shutdownDefault();
         }
     };
 
     static {
         JmxReporter.startDefault();
         Runtime.getRuntime().addShutdownHook();
     }
 
     private Metrics() { /* unused */ }

    
Given a new com.yammer.metrics.core.Gauge, registers it under the given class and name.

Parameters:
klass the class which owns the metric
name the name of the metric
metric the metric
<T> the type of the value returned by the metric
Returns:
metric
 
     public static <T> Gauge<T> newGauge(Class<?> klass,
                                         String name,
                                         Gauge<T> metric) {
         return .newGauge(klassnamemetric);
     }

    
Given a new com.yammer.metrics.core.Gauge, registers it under the given class and name.

Parameters:
klass the class which owns the metric
name the name of the metric
scope the scope of the metric
metric the metric
<T> the type of the value returned by the metric
Returns:
metric
 
     public static <T> Gauge<T> newGauge(Class<?> klass,
                                         String name,
                                         String scope,
                                         Gauge<T> metric) {
         return .newGauge(klassnamescopemetric);
     }

    
Given a new com.yammer.metrics.core.Gauge, registers it under the given metric name.

Parameters:
metricName the name of the metric
metric the metric
<T> the type of the value returned by the metric
Returns:
metric
 
     public static <T> Gauge<T> newGauge(MetricName metricName,
                                         Gauge<T> metric) {
         return .newGauge(metricNamemetric);
     }

    
Creates a new com.yammer.metrics.core.Counter and registers it under the given class and name.

Parameters:
klass the class which owns the metric
name the name of the metric
Returns:
a new com.yammer.metrics.core.Counter
 
     public static Counter newCounter(Class<?> klassString name) {
         return .newCounter(klassname);
     }

    
Creates a new com.yammer.metrics.core.Counter and registers it under the given class and name.

Parameters:
klass the class which owns the metric
name the name of the metric
scope the scope of the metric
Returns:
a new com.yammer.metrics.core.Counter
 
     public static Counter newCounter(Class<?> klass,
                                      String name,
                                      String scope) {
         return .newCounter(klassnamescope);
     }

    
Creates a new com.yammer.metrics.core.Counter and registers it under the given metric name.

Parameters:
metricName the name of the metric
Returns:
a new com.yammer.metrics.core.Counter
    public static Counter newCounter(MetricName metricName) {
        return .newCounter(metricName);
    }

    
Creates a new com.yammer.metrics.core.Histogram and registers it under the given class and name.

Parameters:
klass the class which owns the metric
name the name of the metric
biased whether or not the histogram should be biased
Returns:
a new com.yammer.metrics.core.Histogram
    public static Histogram newHistogram(Class<?> klass,
                                         String name,
                                         boolean biased) {
        return .newHistogram(klassnamebiased);
    }

    
Creates a new com.yammer.metrics.core.Histogram and registers it under the given class, name, and scope.

Parameters:
klass the class which owns the metric
name the name of the metric
scope the scope of the metric
biased whether or not the histogram should be biased
Returns:
a new com.yammer.metrics.core.Histogram
    public static Histogram newHistogram(Class<?> klass,
                                         String name,
                                         String scope,
                                         boolean biased) {
        return .newHistogram(klassnamescopebiased);
    }

    
Creates a new com.yammer.metrics.core.Histogram and registers it under the given metric name.

Parameters:
metricName the name of the metric
biased whether or not the histogram should be biased
Returns:
a new com.yammer.metrics.core.Histogram
    public static Histogram newHistogram(MetricName metricName,
                                         boolean biased) {
        return .newHistogram(metricNamebiased);
    }

    
Creates a new non-biased com.yammer.metrics.core.Histogram and registers it under the given class and name.

Parameters:
klass the class which owns the metric
name the name of the metric
Returns:
a new com.yammer.metrics.core.Histogram
    public static Histogram newHistogram(Class<?> klassString name) {
        return .newHistogram(klassname);
    }

    
Creates a new non-biased com.yammer.metrics.core.Histogram and registers it under the given class, name, and scope.

Parameters:
klass the class which owns the metric
name the name of the metric
scope the scope of the metric
Returns:
a new com.yammer.metrics.core.Histogram
    public static Histogram newHistogram(Class<?> klass,
                                         String name,
                                         String scope) {
        return .newHistogram(klassnamescope);
    }

    
Creates a new non-biased com.yammer.metrics.core.Histogram and registers it under the given metric name.

Parameters:
metricName the name of the metric
Returns:
a new com.yammer.metrics.core.Histogram
    public static Histogram newHistogram(MetricName metricName) {
        return newHistogram(metricNamefalse);
    }

    
Creates a new com.yammer.metrics.core.Meter and registers it under the given class and name.

Parameters:
klass the class which owns the metric
name the name of the metric
eventType the plural name of the type of events the meter is measuring (e.g., "requests")
unit the rate unit of the new meter
Returns:
a new com.yammer.metrics.core.Meter
    public static Meter newMeter(Class<?> klass,
                                 String name,
                                 String eventType,
                                 TimeUnit unit) {
        return .newMeter(klassnameeventTypeunit);
    }

    
Creates a new com.yammer.metrics.core.Meter and registers it under the given class, name, and scope.

Parameters:
klass the class which owns the metric
name the name of the metric
scope the scope of the metric
eventType the plural name of the type of events the meter is measuring (e.g., "requests")
unit the rate unit of the new meter
Returns:
a new com.yammer.metrics.core.Meter
    public static Meter newMeter(Class<?> klass,
                                 String name,
                                 String scope,
                                 String eventType,
                                 TimeUnit unit) {
        return .newMeter(klassnamescopeeventTypeunit);
    }

    
Creates a new com.yammer.metrics.core.Meter and registers it under the given metric name.

Parameters:
metricName the name of the metric
eventType the plural name of the type of events the meter is measuring (e.g., "requests")
unit the rate unit of the new meter
Returns:
a new com.yammer.metrics.core.Meter
    public static Meter newMeter(MetricName metricName,
                                 String eventType,
                                 TimeUnit unit) {
        return .newMeter(metricNameeventTypeunit);
    }

    
Creates a new com.yammer.metrics.core.Timer and registers it under the given class and name.

Parameters:
klass the class which owns the metric
name the name of the metric
durationUnit the duration scale unit of the new timer
rateUnit the rate scale unit of the new timer
Returns:
a new com.yammer.metrics.core.Timer
    public static Timer newTimer(Class<?> klass,
                                 String name,
                                 TimeUnit durationUnit,
                                 TimeUnit rateUnit) {
        return .newTimer(klassnamedurationUnitrateUnit);
    }

    
Creates a new com.yammer.metrics.core.Timer and registers it under the given class and name, measuring elapsed time in milliseconds and invocations per second.

Parameters:
klass the class which owns the metric
name the name of the metric
Returns:
a new com.yammer.metrics.core.Timer
    public static Timer newTimer(Class<?> klass,
                                 String name) {
        return .newTimer(klassname);
    }

    
Creates a new com.yammer.metrics.core.Timer and registers it under the given class, name, and scope.

Parameters:
klass the class which owns the metric
name the name of the metric
scope the scope of the metric
durationUnit the duration scale unit of the new timer
rateUnit the rate scale unit of the new timer
Returns:
a new com.yammer.metrics.core.Timer
    public static Timer newTimer(Class<?> klass,
                                 String name,
                                 String scope,
                                 TimeUnit durationUnit,
                                 TimeUnit rateUnit) {
        return .newTimer(klassnamescopedurationUnitrateUnit);
    }

    
Creates a new com.yammer.metrics.core.Timer and registers it under the given class, name, and scope, measuring elapsed time in milliseconds and invocations per second.

Parameters:
klass the class which owns the metric
name the name of the metric
scope the scope of the metric
Returns:
a new com.yammer.metrics.core.Timer
    public static Timer newTimer(Class<?> klass,
                                 String name,
                                 String scope) {
        return .newTimer(klassnamescope);
    }

    
Creates a new com.yammer.metrics.core.Timer and registers it under the given metric name.

Parameters:
metricName the name of the metric
durationUnit the duration scale unit of the new timer
rateUnit the rate scale unit of the new timer
Returns:
a new com.yammer.metrics.core.Timer
    public static Timer newTimer(MetricName metricName,
                                 TimeUnit durationUnit,
                                 TimeUnit rateUnit) {
        return .newTimer(metricNamedurationUnitrateUnit);
    }

    
Returns the (static) default registry.

Returns:
the metrics registry
    public static MetricsRegistry defaultRegistry() {
        return ;
    }

    
Shuts down all thread pools for the default registry.
    public static void shutdown() {
        .shutdown();
        JmxReporter.shutdownDefault();
        Runtime.getRuntime().removeShutdownHook();
    }
New to GrepCode? Check out our FAQ X