
io.nflow.metrics.NflowMetricsContext Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nflow-metrics Show documentation
Show all versions of nflow-metrics Show documentation
Integrate https://metrics.dropwizard.io/ with nFlow
package io.nflow.metrics;
import static io.nflow.engine.config.Profiles.JMX;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Named;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.health.HealthCheckRegistry;
import com.codahale.metrics.jmx.JmxReporter;
import io.nflow.engine.internal.dao.ExecutorDao;
import io.nflow.engine.service.HealthCheckService;
/**
* Configures MetricsWorkflowExecutorListener.
*/
@Named("nflowMetrics/metricsContext")
@Configuration
public class NflowMetricsContext {
private static final Logger logger = LoggerFactory.getLogger(NflowMetricsContext.class);
@Inject
private HealthCheckService healthCheckService;
@Inject
private MetricRegistry metricRegistry;
@Inject
private HealthCheckRegistry healthCheckRegistry;
@Bean
public DatabaseConnectionHealthCheck databaseConnectionHealthCheck() {
return new DatabaseConnectionHealthCheck(healthCheckService);
}
@PostConstruct
public void registerHealthChecks() {
healthCheckRegistry.register("nflowDatabaseConnection", databaseConnectionHealthCheck());
}
@Bean
public MetricsWorkflowExecutorListener metricsWorkflowExecutorListener(ExecutorDao executors) {
logger.info("Enabling MetricsWorkflowExecutorListener");
return new MetricsWorkflowExecutorListener(metricRegistry, executors);
}
@Profile(JMX)
@Bean(destroyMethod="stop")
public JmxReporter jmxMetricsReporter() {
logger.info("Enabling Metrics JmxReporter");
JmxReporter jmxMetricsReporter = JmxReporter.forRegistry(metricRegistry).inDomain("nflow.metrics").build();
jmxMetricsReporter.start();
return jmxMetricsReporter;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy