Java Code Examples for org.slf4j.MarkerFactory#getMarker()

The following examples show how to use org.slf4j.MarkerFactory#getMarker() . 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: MetricsConfiguration.java    From flair-registry with Apache License 2.0 6 votes vote down vote up
@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()));
    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);
    }
}
 
Example 2
Source File: AbstractRestExceptionHandler.java    From spring-rest-exception-handler with Apache License 2.0 6 votes vote down vote up
/**
 * Logs the exception; on ERROR level when status is 5xx, otherwise on INFO level without stack
 * trace, or DEBUG level with stack trace. The logger name is
 * {@code cz.jirutka.spring.exhandler.handlers.RestExceptionHandler}.
 *
 * @param ex The exception to log.
 * @param req The current web request.
 */
protected void logException(E ex, HttpServletRequest req) {

    if (LOG.isErrorEnabled() && getStatus().value() >= 500 || LOG.isInfoEnabled()) {
        Marker marker = MarkerFactory.getMarker(ex.getClass().getName());

        String uri = req.getRequestURI();
        if (req.getQueryString() != null) {
            uri += '?' + req.getQueryString();
        }
        String msg = String.format("%s %s ~> %s", req.getMethod(), uri, getStatus());

        if (getStatus().value() >= 500) {
            LOG.error(marker, msg, ex);

        } else if (LOG.isDebugEnabled()) {
            LOG.debug(marker, msg, ex);

        } else {
            LOG.info(marker, msg);
        }
    }
}
 
Example 3
Source File: LogLevelInfoFilterTest.java    From api-layer with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void filtersLevelTestWithMarker() {
    Marker marker = MarkerFactory.getMarker(APIML_MARKER);
    Map<Level, Boolean> filteringMap = new HashMap<>();
    filteringMap.put(Level.TRACE, false);
    filteringMap.put(Level.DEBUG, false);
    filteringMap.put(Level.INFO, false);
    filteringMap.put(Level.WARN, false);
    filteringMap.put(Level.ERROR, false);

    filteringMap.forEach((level, shouldFilter) -> {
        FilterReply reply = filterInstance.decide(marker, (ch.qos.logback.classic.Logger) log, level, "", null,
                null);
        assertEquals("Logging level with apiml marker " + level.toString() + " not filtered correctly",
                shouldFilter ? FilterReply.DENY : FilterReply.NEUTRAL, reply);
    });
}
 
Example 4
Source File: CassandraScheduler.java    From cassandra-mesos-deprecated with Apache License 2.0 6 votes vote down vote up
@Override
public void resourceOffers(final SchedulerDriver driver, final List<Offer> offers) {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("> resourceOffers(driver : {}, offers : {})", driver, protoToString(offers));
    }

    for (final Offer offer : offers) {
        final Marker marker = MarkerFactory.getMarker("offerId:" + offer.getId().getValue() + ",hostname:" + offer.getHostname());
        final boolean offerUsed = evaluateOffer(driver, marker, offer);
        if (!offerUsed) {
            LOGGER.trace(marker, "Declining Offer: {}", offer.getId().getValue());
            driver.declineOffer(offer.getId());
        }
    }
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("< resourceOffers(driver : {}, offers : {})", driver, protoToString(offers));
    }
}
 
Example 5
Source File: MetricsConfiguration.java    From cubeai with Apache License 2.0 6 votes vote down vote up
@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 (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);
    }
}
 
Example 6
Source File: MetricsConfiguration.java    From cubeai with Apache License 2.0 6 votes vote down vote up
@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 (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);
    }
}
 
Example 7
Source File: TestAppLog.java    From cf-java-logging-support with Apache License 2.0 6 votes vote down vote up
@Test
public void testCategorties() {
    logMsg = "Running testCategories()";
    Marker cat0 = MarkerFactory.getMarker("cat0");

    LOGGER.info(cat0, logMsg);
    assertThat(getMessage(), is(logMsg));
    assertThat(getField(Fields.COMPONENT_ID), is("-"));
    assertThat(getField(Fields.COMPONENT_NAME), is("-"));
    assertThat(getField(Fields.COMPONENT_INSTANCE), is("0"));
    assertThat(getField(Fields.WRITTEN_TS), is(notNullValue()));
    assertThat(getList(Fields.CATEGORIES), contains(cat0.getName()));

    Marker cat1 = MarkerFactory.getMarker("cat1");
    cat1.add(cat0);

    LOGGER.info(cat1, logMsg);
    assertThat(getMessage(), is(logMsg));
    assertThat(getField(Fields.COMPONENT_ID), is("-"));
    assertThat(getField(Fields.COMPONENT_NAME), is("-"));
    assertThat(getField(Fields.COMPONENT_INSTANCE), is("0"));
    assertThat(getField(Fields.WRITTEN_TS), is(notNullValue()));
    assertThat(getList(Fields.CATEGORIES), contains(cat1.getName(), cat0.getName()));
}
 
Example 8
Source File: CassandraScheduler.java    From cassandra-mesos-deprecated with Apache License 2.0 5 votes vote down vote up
@Override
public void executorLost(final SchedulerDriver driver, final ExecutorID executorId, final SlaveID slaveId, final int status) {
    final Marker executorIdMarker = MarkerFactory.getMarker("executorId:" + executorId.getValue());
    // this method will never be called by mesos until MESOS-313 is fixed
    // https://issues.apache.org/jira/browse/MESOS-313
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug(executorIdMarker, "executorLost(driver : {}, executorId : {}, slaveId : {}, status : {})", driver, protoToString(executorId), protoToString(slaveId), protoToString(status));
    }
    cassandraCluster.removeExecutor(executorId.getValue());
}
 
Example 9
Source File: MetricsConfiguration.java    From cubeai with Apache License 2.0 5 votes vote down vote up
@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);
    }
}
 
Example 10
Source File: MetricsConfiguration.java    From tutorials with MIT License 5 votes vote down vote up
@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");
        // remove the factory created by HikariDataSourceMetricsPostProcessor until JHipster migrate to Micrometer
        hikariDataSource.setMetricsTrackerFactory(null);
        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);
    }
}
 
Example 11
Source File: MetricsConfiguration.java    From okta-jhipster-microservices-oauth-example with Apache License 2.0 5 votes vote down vote up
@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");
        // remove the factory created by HikariDataSourceMetricsPostProcessor until JHipster migrate to Micrometer
        hikariDataSource.setMetricsTrackerFactory(null);
        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);
    }
}
 
Example 12
Source File: MetricsConfiguration.java    From Spring-5.0-Projects with MIT License 5 votes vote down vote up
@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");
        // remove the factory created by HikariDataSourceMetricsPostProcessor until JHipster migrate to Micrometer
        hikariDataSource.setMetricsTrackerFactory(null);
        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);
    }
}
 
Example 13
Source File: MetricsConfiguration.java    From tutorials with MIT License 5 votes vote down vote up
@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");
        // remove the factory created by HikariDataSourceMetricsPostProcessor until JHipster migrate to Micrometer
        hikariDataSource.setMetricsTrackerFactory(null);
        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);
    }
}
 
Example 14
Source File: MarkerFilterBenchmark.java    From logging-log4j2 with Apache License 2.0 5 votes vote down vote up
@Setup
public void setUp() {
    System.setProperty("log4j.configurationFile", "log4j2-markerFilter-perf.xml");
    System.setProperty("logback.configurationFile", "logback-markerFilter-perf.xml");
    LOGBACK_FLOW_MARKER = MarkerFactory.getMarker("FLOW");
    LOGBACK_ENTRY_MARKER = MarkerFactory.getMarker("ENTRY");
    LOG4J_FLOW_MARKER = MarkerManager.getMarker("FLOW");
    LOG4J_ENTRY_MARKER = MarkerManager.getMarker("ENTRY");
    LOGBACK_ENTRY_MARKER.add(LOGBACK_FLOW_MARKER);
    LOG4J_ENTRY_MARKER.addParents(LOG4J_FLOW_MARKER);
    log4jLogger = LogManager.getLogger(MarkerFilterBenchmark.class);
    slf4jLogger = LoggerFactory.getLogger(MarkerFilterBenchmark.class);
}
 
Example 15
Source File: MetricsConfiguration.java    From e-commerce-microservice with Apache License 2.0 5 votes vote down vote up
@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");
        // remove the factory created by HikariDataSourceMetricsPostProcessor until JHipster migrate to Micrometer
        hikariDataSource.setMetricsTrackerFactory(null);
        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);
    }
}
 
Example 16
Source File: MetricsConfiguration.java    From Full-Stack-Development-with-JHipster with MIT License 5 votes vote down vote up
@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);
    }
}
 
Example 17
Source File: CassandraScheduler.java    From cassandra-mesos-deprecated with Apache License 2.0 4 votes vote down vote up
@Override
public void statusUpdate(final SchedulerDriver driver, final TaskStatus status) {
    final Marker taskIdMarker = MarkerFactory.getMarker("taskId:" + status.getTaskId().getValue());
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug(taskIdMarker, "> statusUpdate(driver : {}, status : {})", driver, protoToString(status));
    }
    try {
        final ExecutorID executorId = status.getExecutorId();
        final TaskID taskId = status.getTaskId();
        final SlaveStatusDetails statusDetails;
        if (!status.getData().isEmpty()) {
            statusDetails = SlaveStatusDetails.parseFrom(status.getData());
        } else {
            statusDetails = SlaveStatusDetails.getDefaultInstance();
        }
        switch (status.getState()) {
            case TASK_STAGING:
                // TODO really interested in staging state?
                break;
            case TASK_STARTING:
                // TODO really interested in starting state?
                break;
            case TASK_RUNNING:
                switch (statusDetails.getStatusDetailsType()) {
                    case NULL_DETAILS:
                        break;
                    case EXECUTOR_METADATA:
                        final ExecutorMetadata executorMetadata = statusDetails.getExecutorMetadata();
                        cassandraCluster.addExecutorMetadata(executorMetadata);
                        break;
                    case CASSANDRA_SERVER_RUN:
                        cassandraCluster.updateCassandraProcess(executorId, statusDetails.getCassandraServerRunMetadata());
                        break;
                    case HEALTH_CHECK_DETAILS:
                        break;
                    case ERROR_DETAILS:
                        break;
                }
                break;
            case TASK_FAILED:
            case TASK_KILLED:
            case TASK_LOST:
            case TASK_ERROR:
                LOGGER.error(taskIdMarker, "Got status {} for task {}, executor {} ({}, healthy={}): {}",
                        status.getState(),
                        status.getTaskId().getValue(),
                        status.getExecutorId().getValue(),
                        protoToString(status.getReason()),
                        status.getHealthy(),
                        status.getMessage());
            case TASK_FINISHED:
                if (status.getSource() == TaskStatus.Source.SOURCE_SLAVE && status.getReason() == TaskStatus.Reason.REASON_EXECUTOR_TERMINATED) {
                    // this code should really be handled by executorLost, but it can't due to the fact that
                    // executorLost will never be called.

                    // there is the possibility that the executorId we get in the task status is empty,
                    // so here we use the taskId to lookup the executorId based on the tasks we're tracking
                    // to try and have a more accurate value.
                    final Optional<String> opt = cassandraCluster.getExecutorIdForTask(taskId.getValue());
                    final ExecutorID executorIdForTask;
                    if (opt.isPresent()) {
                        executorIdForTask = executorId(opt.get());
                    } else {
                        executorIdForTask = executorId;
                    }
                    executorLost(driver, executorIdForTask, status.getSlaveId(), status.getState().ordinal());
                } else {
                    switch (statusDetails.getStatusDetailsType()) {
                        case NULL_DETAILS:
                            break;
                        case EXECUTOR_METADATA:
                            break;
                        case ERROR_DETAILS:
                            LOGGER.error(taskIdMarker, protoToString(statusDetails.getSlaveErrorDetails()));
                            break;
                        case HEALTH_CHECK_DETAILS:
                            cassandraCluster.recordHealthCheck(executorId.getValue(), statusDetails.getHealthCheckDetails());
                            break;
                        case NODE_JOB_STATUS:
                            cassandraCluster.onNodeJobStatus(statusDetails);
                            break;
                    }
                    cassandraCluster.removeTask(taskId.getValue(), status);
                }
                break;
        }
    } catch (final InvalidProtocolBufferException e) {
        final String msg = "Error deserializing task status data to type: " + SlaveStatusDetails.class.getName();
        LOGGER.error(msg, e);
    }
    if (LOGGER.isTraceEnabled()) {
        LOGGER.trace(taskIdMarker, "< statusUpdate(driver : {}, status : {})", driver, protoToString(status));
    }
}
 
Example 18
Source File: DolphinLogger.java    From dolphin-platform with Apache License 2.0 4 votes vote down vote up
public static Marker createMarker(final String name) {
    return MarkerFactory.getMarker(name);
}
 
Example 19
Source File: Markers.java    From yes-cart with Apache License 2.0 2 votes vote down vote up
/**
 * Marker for event that has to be emailed.
 *
 * @return email marker
 */
public static Marker email() {
    return MarkerFactory.getMarker("email");
}
 
Example 20
Source File: SLF4JLoggingCallback.java    From javasimon with BSD 3-Clause "New" or "Revised" License 2 votes vote down vote up
/**
 * Sets the marker via marker name - used by the configure facility to configure the callback.
 *
 * @param marker name of the marker
 */
public void setMarker(String marker) {
	this.marker = MarkerFactory.getMarker(marker);
}