com.codahale.metrics.Reporter Java Examples

The following examples show how to use com.codahale.metrics.Reporter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CodahaleMetricsMixin.java    From attic-polygene-java with Apache License 2.0 6 votes vote down vote up
@Override
public void activateService() {
    metricRegistry = new MetricRegistry();
    healthCheckRegistry = new HealthCheckRegistry();
    CodahaleMetricsDeclaration declaration = descriptor.metaInfo( CodahaleMetricsDeclaration.class );
    prefix = declaration.prefix() != null ? declaration.prefix() : app.name();
    fqcn = declaration.fqcn();
    if( declaration.jmx() )
    {
        JmxReporter jmxReporter = JmxReporter.forRegistry( metricRegistry ).build();
        jmxReporter.start();
        reporters.add( jmxReporter );
    }
    for( Function<MetricRegistry, Reporter> reporterFactory : declaration.reportersFactories())
    {
        reporters.add( reporterFactory.apply( metricRegistry ) );
    }
}
 
Example #2
Source File: DefaultGraphiteReporterFactory.java    From riposte with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized Reporter getReporter(MetricRegistry registry) {
    if (null == reporter) {
        Graphite graphite = new Graphite(new InetSocketAddress(graphiteURL, graphitePort));
        reporter = GraphiteReporter.forRegistry(registry)
                                   .prefixedWith(prefix)
                                   .convertRatesTo(TimeUnit.SECONDS)
                                   .convertDurationsTo(TimeUnit.MILLISECONDS)
                                   .filter(MetricFilter.ALL)
                                   .build(graphite);
    }
    return reporter;
}
 
Example #3
Source File: DefaultSLF4jReporterFactory.java    From riposte with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized Reporter getReporter(MetricRegistry registry) {
    if (null == reporter) {
        reporter = Slf4jReporter.forRegistry(registry)
                                .outputTo(LoggerFactory.getLogger(prefix))
                                .convertRatesTo(TimeUnit.SECONDS)
                                .convertDurationsTo(TimeUnit.MILLISECONDS)
                                .build();
    }
    return reporter;
}
 
Example #4
Source File: DefaultJMXReporterFactory.java    From riposte with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized Reporter getReporter(MetricRegistry registry) {
    if (null == reporter) {
        reporter = JmxReporter.forRegistry(registry).build();
    }
    return reporter;
}
 
Example #5
Source File: DefaultConsoleReporterFactory.java    From riposte with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized Reporter getReporter(MetricRegistry registry) {
    if (null == reporter) {
        reporter = ConsoleReporter.forRegistry(registry)
                                  .convertRatesTo(TimeUnit.SECONDS)
                                  .convertDurationsTo(TimeUnit.MILLISECONDS)
                                  .build();
    }
    return reporter;
}
 
Example #6
Source File: ReporterFactoryInstanceTest.java    From riposte with Apache License 2.0 5 votes vote down vote up
@Test
public void test() {
    MetricRegistry registry = new MetricRegistry();
    Reporter r = new DefaultConsoleReporterFactory().getReporter(registry);
    assertNotNull(r);
    r = new DefaultJMXReporterFactory().getReporter(registry);
    assertNotNull(r);
    r = new DefaultSLF4jReporterFactory().getReporter(registry);
    assertNotNull(r);
    r = new DefaultGraphiteReporterFactory("test", "fakeurl.com", 4242).getReporter(registry);
    assertNotNull(r);
    r = new RiposteGraphiteReporterFactory("test", "fakeurl.com", 4242).getReporter(registry);
}
 
Example #7
Source File: CodahaleMetricsEngineTest.java    From riposte with Apache License 2.0 4 votes vote down vote up
@Override
public Reporter getReporter(MetricRegistry registry) {
    return this;
}
 
Example #8
Source File: CodahaleMetricsEngineTest.java    From riposte with Apache License 2.0 4 votes vote down vote up
@Override
public Reporter getReporter(MetricRegistry registry) {
    return this;
}
 
Example #9
Source File: CodahaleMetricsEngineTest.java    From riposte with Apache License 2.0 4 votes vote down vote up
@Override
public Reporter getReporter(MetricRegistry registry) {
    return this;
}
 
Example #10
Source File: CodahaleMetricsEngineTest.java    From riposte with Apache License 2.0 4 votes vote down vote up
@Override
public Reporter getReporter(MetricRegistry registry) {
    return this;
}
 
Example #11
Source File: CodahaleMetricsDeclaration.java    From attic-polygene-java with Apache License 2.0 4 votes vote down vote up
public List<Function<MetricRegistry, Reporter>> reportersFactories()
{
    return reportersFactories;
}
 
Example #12
Source File: CodahaleMetricsAssembler.java    From attic-polygene-java with Apache License 2.0 4 votes vote down vote up
public CodahaleMetricsAssembler withReporter( Function<MetricRegistry, Reporter> factory )
{
    declaration.reportersFactories.add( factory );
    return this;
}
 
Example #13
Source File: ReporterFactory.java    From riposte with Apache License 2.0 2 votes vote down vote up
/**
 * Get the singleton instance of the Reporter wrapped by this ReporterFactory
 *
 * @param registry
 *     The MetricRegistry that the Reporter will be reporting on
 */
Reporter getReporter(MetricRegistry registry);