Search in sources :

Example 1 with MetricName

use of com.yammer.metrics.core.MetricName in project pinot by linkedin.

the class AbstractMetrics method addCallbackGauge.

/**
   * Adds a new gauge whose values are retrieved from a callback function.
   *
   * @param metricName The name of the metric
   * @param valueCallback The callback function used to retrieve the value of the gauge
   */
public void addCallbackGauge(final String metricName, final Callable<Long> valueCallback) {
    MetricsHelper.newGauge(_metricsRegistry, new MetricName(_clazz, _metricPrefix + metricName), new com.yammer.metrics.core.Gauge<Long>() {

        @Override
        public Long value() {
            try {
                return valueCallback.call();
            } catch (Exception e) {
                LOGGER.error("Caught exception", e);
                Utils.rethrowException(e);
                throw new AssertionError("Should not reach this");
            }
        }
    });
}
Also used : MetricName(com.yammer.metrics.core.MetricName) AtomicLong(java.util.concurrent.atomic.AtomicLong)

Example 2 with MetricName

use of com.yammer.metrics.core.MetricName in project pinot by linkedin.

the class AbstractMetrics method addMeteredTableValue.

/**
   * Logs a value to a table-level meter.
   *
   * @param tableName The table name
   * @param meter The meter to use
   * @param unitCount The number of units to add to the meter
   */
public void addMeteredTableValue(final String tableName, final M meter, final long unitCount) {
    final String fullMeterName;
    String meterName = meter.getMeterName();
    fullMeterName = _metricPrefix + getTableName(tableName) + "." + meterName;
    final MetricName metricName = new MetricName(_clazz, fullMeterName);
    MetricsHelper.newMeter(_metricsRegistry, metricName, meter.getUnit(), TimeUnit.SECONDS).mark(unitCount);
}
Also used : MetricName(com.yammer.metrics.core.MetricName)

Example 3 with MetricName

use of com.yammer.metrics.core.MetricName in project bagheera by mozilla-metrics.

the class HttpMetric method updateRequestMetrics.

public void updateRequestMetrics(String method, int contentSize) {
    requests.mark();
    throughput.mark(contentSize);
    if (methods.containsKey(method)) {
        methods.get(method).mark();
    } else {
        Meter methodMeter = Metrics.newMeter(new MetricName(DEFAULT_GROUP, DEFAULT_TYPE, this.id + ".method." + method), "requests", TimeUnit.SECONDS);
        methodMeter.mark();
        methods.put(method, methodMeter);
    }
}
Also used : MetricName(com.yammer.metrics.core.MetricName) Meter(com.yammer.metrics.core.Meter)

Example 4 with MetricName

use of com.yammer.metrics.core.MetricName in project bagheera by mozilla-metrics.

the class HttpMetric method updateResponseMetrics.

public void updateResponseMetrics(int status) {
    if (responseCodeCounts.containsKey(status)) {
        responseCodeCounts.get(status).inc();
    } else {
        Counter statusCounter = Metrics.newCounter(new MetricName(DEFAULT_GROUP, DEFAULT_TYPE, this.id + ".response." + status));
        statusCounter.inc();
        responseCodeCounts.put(status, statusCounter);
    }
}
Also used : MetricName(com.yammer.metrics.core.MetricName) Counter(com.yammer.metrics.core.Counter)

Example 5 with MetricName

use of com.yammer.metrics.core.MetricName in project platformlayer by platformlayer.

the class CodahaleMetricRegistry method getCounter.

@Override
public MetricMeter getCounter(MetricKey metricKey) {
    MetricName metricName = toMetricName(metricKey);
    String eventType = "events";
    return new MetricMeterAdapter(registry.newMeter(metricName, eventType, TimeUnit.SECONDS));
}
Also used : MetricName(com.yammer.metrics.core.MetricName)

Aggregations

MetricName (com.yammer.metrics.core.MetricName)12 ClusterId (com.nokia.dempsy.config.ClusterId)1 Destination (com.nokia.dempsy.messagetransport.Destination)1 Counter (com.yammer.metrics.core.Counter)1 Meter (com.yammer.metrics.core.Meter)1 Metric (com.yammer.metrics.core.Metric)1 MetricsRegistry (com.yammer.metrics.core.MetricsRegistry)1 DateFormat (java.text.DateFormat)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 SortedMap (java.util.SortedMap)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 Configuration (org.apache.commons.configuration.Configuration)1 MapConfiguration (org.apache.commons.configuration.MapConfiguration)1 Test (org.junit.Test)1 Test (org.testng.annotations.Test)1