All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.firefly.db.DefaultMetricReporterFactory Maven / Gradle / Ivy

There is a newer version: 5.0.0-dev6
Show newest version
package com.firefly.db;

import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.ScheduledReporter;
import com.codahale.metrics.Slf4jReporter;
import org.slf4j.LoggerFactory;

import java.util.concurrent.TimeUnit;

/**
 * @author Pengtao Qiu
 */
public class DefaultMetricReporterFactory implements MetricReporterFactory {

    private ScheduledReporter scheduledReporter;
    private MetricRegistry metricRegistry;

    public DefaultMetricReporterFactory() {
        this.metricRegistry = new MetricRegistry();
        this.scheduledReporter = Slf4jReporter.forRegistry(metricRegistry)
                                              .outputTo(LoggerFactory.getLogger("firefly-monitor"))
                                              .convertRatesTo(TimeUnit.SECONDS)
                                              .convertDurationsTo(TimeUnit.MILLISECONDS)
                                              .build();
    }

    @Override
    public ScheduledReporter getScheduledReporter() {
        return scheduledReporter;
    }

    @Override
    public MetricRegistry getMetricRegistry() {
        return metricRegistry;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy