Search in sources :

Example 16 with Slf4jReporter

use of com.codahale.metrics.Slf4jReporter in project jhipster-sample-app-oauth2 by jhipster.

the class MetricsConfiguration method init.

@PostConstruct
public void init() {
    log.debug("Registering JVM gauges");
    metricRegistry.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_THREADS, new ThreadStatesGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_FILES, new FileDescriptorRatioGauge());
    metricRegistry.register(PROP_METRIC_REG_JVM_BUFFERS, new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
    metricRegistry.register(PROP_METRIC_REG_JVM_ATTRIBUTE_SET, new JvmAttributeGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JCACHE_STATISTICS, new JCacheGaugeSet());
    if (hikariDataSource != null) {
        log.debug("Monitoring the datasource");
        hikariDataSource.setMetricRegistry(metricRegistry);
    }
    if (jHipsterProperties.getMetrics().getJmx().isEnabled()) {
        log.debug("Initializing Metrics JMX reporting");
        JmxReporter jmxReporter = JmxReporter.forRegistry(metricRegistry).build();
        jmxReporter.start();
    }
    if (jHipsterProperties.getMetrics().getLogs().isEnabled()) {
        log.info("Initializing Metrics Log reporting");
        Marker metricsMarker = MarkerFactory.getMarker("metrics");
        final Slf4jReporter reporter = Slf4jReporter.forRegistry(metricRegistry).outputTo(LoggerFactory.getLogger("metrics")).markWith(metricsMarker).convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS).build();
        reporter.start(jHipsterProperties.getMetrics().getLogs().getReportFrequency(), TimeUnit.SECONDS);
    }
}
Also used : JvmAttributeGaugeSet(com.codahale.metrics.JvmAttributeGaugeSet) Slf4jReporter(com.codahale.metrics.Slf4jReporter) Marker(org.slf4j.Marker) JmxReporter(com.codahale.metrics.JmxReporter) JCacheGaugeSet(com.codahale.metrics.jcache.JCacheGaugeSet) PostConstruct(javax.annotation.PostConstruct)

Example 17 with Slf4jReporter

use of com.codahale.metrics.Slf4jReporter in project uplace.es by Uplace.

the class MetricsConfiguration method init.

@PostConstruct
public void init() {
    log.debug("Registering JVM gauges");
    metricRegistry.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_THREADS, new ThreadStatesGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_FILES, new FileDescriptorRatioGauge());
    metricRegistry.register(PROP_METRIC_REG_JVM_BUFFERS, new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
    metricRegistry.register(PROP_METRIC_REG_JVM_ATTRIBUTE_SET, new JvmAttributeGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JCACHE_STATISTICS, new JCacheGaugeSet());
    if (hikariDataSource != null) {
        log.debug("Monitoring the datasource");
        hikariDataSource.setMetricRegistry(metricRegistry);
    }
    if (jHipsterProperties.getMetrics().getJmx().isEnabled()) {
        log.debug("Initializing Metrics JMX reporting");
        JmxReporter jmxReporter = JmxReporter.forRegistry(metricRegistry).build();
        jmxReporter.start();
    }
    if (jHipsterProperties.getMetrics().getLogs().isEnabled()) {
        log.info("Initializing Metrics Log reporting");
        Marker metricsMarker = MarkerFactory.getMarker("metrics");
        final Slf4jReporter reporter = Slf4jReporter.forRegistry(metricRegistry).outputTo(LoggerFactory.getLogger("metrics")).markWith(metricsMarker).convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS).build();
        reporter.start(jHipsterProperties.getMetrics().getLogs().getReportFrequency(), TimeUnit.SECONDS);
    }
}
Also used : JvmAttributeGaugeSet(com.codahale.metrics.JvmAttributeGaugeSet) Slf4jReporter(com.codahale.metrics.Slf4jReporter) Marker(org.slf4j.Marker) JmxReporter(com.codahale.metrics.JmxReporter) JCacheGaugeSet(com.codahale.metrics.jcache.JCacheGaugeSet) PostConstruct(javax.annotation.PostConstruct)

Example 18 with Slf4jReporter

use of com.codahale.metrics.Slf4jReporter in project engineblock by engineblock.

the class ScenarioResult method reportToLog.

public void reportToLog() {
    logger.info("-- BEGIN METRICS DETAIL --");
    Slf4jReporter reporter = Slf4jReporter.forRegistry(ActivityMetrics.getMetricRegistry()).convertDurationsTo(TimeUnit.MICROSECONDS).convertRatesTo(TimeUnit.SECONDS).filter(MetricFilter.ALL).outputTo(logger).build();
    reporter.report();
    logger.info("-- END METRICS DETAIL --");
// if (this.exception!=null && !(this.exception instanceof UserException)) {
// logger.error("Scenario error: " + this.exception.getMessage(),this.exception);
// }
}
Also used : Slf4jReporter(com.codahale.metrics.Slf4jReporter)

Example 19 with Slf4jReporter

use of com.codahale.metrics.Slf4jReporter in project tutorials by eugenp.

the class MetricsConfiguration method init.

@PostConstruct
public void init() {
    log.debug("Registering JVM gauges");
    metricRegistry.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_THREADS, new ThreadStatesGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_FILES, new FileDescriptorRatioGauge());
    metricRegistry.register(PROP_METRIC_REG_JVM_BUFFERS, new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
    metricRegistry.register(PROP_METRIC_REG_JCACHE_STATISTICS, new JCacheGaugeSet());
    if (hikariDataSource != null) {
        log.debug("Monitoring the datasource");
        hikariDataSource.setMetricRegistry(metricRegistry);
    }
    if (jHipsterProperties.getMetrics().getJmx().isEnabled()) {
        log.debug("Initializing Metrics JMX reporting");
        JmxReporter jmxReporter = JmxReporter.forRegistry(metricRegistry).build();
        jmxReporter.start();
    }
    if (jHipsterProperties.getMetrics().getLogs().isEnabled()) {
        log.info("Initializing Metrics Log reporting");
        final Slf4jReporter reporter = Slf4jReporter.forRegistry(metricRegistry).outputTo(LoggerFactory.getLogger("metrics")).convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS).build();
        reporter.start(jHipsterProperties.getMetrics().getLogs().getReportFrequency(), TimeUnit.SECONDS);
    }
}
Also used : Slf4jReporter(com.codahale.metrics.Slf4jReporter) JmxReporter(com.codahale.metrics.JmxReporter) JCacheGaugeSet(io.github.jhipster.config.jcache.JCacheGaugeSet) PostConstruct(javax.annotation.PostConstruct)

Example 20 with Slf4jReporter

use of com.codahale.metrics.Slf4jReporter in project cetc by DiscoverForever.

the class MetricsConfiguration method init.

@PostConstruct
public void init() {
    log.debug("Registering JVM gauges");
    metricRegistry.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_THREADS, new ThreadStatesGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_FILES, new FileDescriptorRatioGauge());
    metricRegistry.register(PROP_METRIC_REG_JVM_BUFFERS, new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
    metricRegistry.register(PROP_METRIC_REG_JVM_ATTRIBUTE_SET, new JvmAttributeGaugeSet());
    if (hikariDataSource != null) {
        log.debug("Monitoring the datasource");
        hikariDataSource.setMetricRegistry(metricRegistry);
    }
    if (jHipsterProperties.getMetrics().getJmx().isEnabled()) {
        log.debug("Initializing Metrics JMX reporting");
        JmxReporter jmxReporter = JmxReporter.forRegistry(metricRegistry).build();
        jmxReporter.start();
    }
    if (jHipsterProperties.getMetrics().getLogs().isEnabled()) {
        log.info("Initializing Metrics Log reporting");
        Marker metricsMarker = MarkerFactory.getMarker("metrics");
        final Slf4jReporter reporter = Slf4jReporter.forRegistry(metricRegistry).outputTo(LoggerFactory.getLogger("metrics")).markWith(metricsMarker).convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS).build();
        reporter.start(jHipsterProperties.getMetrics().getLogs().getReportFrequency(), TimeUnit.SECONDS);
    }
}
Also used : JvmAttributeGaugeSet(com.codahale.metrics.JvmAttributeGaugeSet) Slf4jReporter(com.codahale.metrics.Slf4jReporter) Marker(org.slf4j.Marker) JmxReporter(com.codahale.metrics.JmxReporter) PostConstruct(javax.annotation.PostConstruct)

Aggregations

Slf4jReporter (com.codahale.metrics.Slf4jReporter)25 JmxReporter (com.codahale.metrics.JmxReporter)20 PostConstruct (javax.annotation.PostConstruct)19 JvmAttributeGaugeSet (com.codahale.metrics.JvmAttributeGaugeSet)13 Marker (org.slf4j.Marker)13 JCacheGaugeSet (com.codahale.metrics.jcache.JCacheGaugeSet)8 MetricRegistry (com.codahale.metrics.MetricRegistry)1 Builder (com.codahale.metrics.Slf4jReporter.Builder)1 JCacheGaugeSet (io.github.jhipster.config.jcache.JCacheGaugeSet)1 Log4jLoggerFactory (org.apache.logging.slf4j.Log4jLoggerFactory)1