本文整理汇总了Java中com.codahale.metrics.JmxReporter类的典型用法代码示例。如果您正苦于以下问题:Java JmxReporter类的具体用法?Java JmxReporter怎么用?Java JmxReporter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JmxReporter类属于com.codahale.metrics包,在下文中一共展示了JmxReporter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import com.codahale.metrics.JmxReporter; //导入依赖的package包/类
@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");
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);
}
}
示例2: KafkaCruiseControl
import com.codahale.metrics.JmxReporter; //导入依赖的package包/类
/**
* Construct the Cruise Control
*
* @param config the configuration of Cruise Control.
*/
public KafkaCruiseControl(KafkaCruiseControlConfig config) {
_config = config;
_time = new SystemTime();
// initialize some of the static state of Kafka Cruise Control;
Load.init(config);
ModelUtils.init(config);
ModelParameters.init(config);
_dropwizardMetricRegistry = new MetricRegistry();
_reporter = JmxReporter.forRegistry(_dropwizardMetricRegistry).inDomain(_metricsPrefix).build();
// Instantiate the components.
_loadMonitor = new LoadMonitor(config, _time, _dropwizardMetricRegistry);
_goalOptimizerExecutor =
Executors.newSingleThreadExecutor(new KafkaCruiseControlThreadFactory("GoalOptimizerExecutor", true, null));
_goalOptimizer = new GoalOptimizer(config, _loadMonitor, _time, _dropwizardMetricRegistry);
_executor = new Executor(config, _time, _dropwizardMetricRegistry);
_anomalyDetector = new AnomalyDetector(config, _loadMonitor, this, _time, _dropwizardMetricRegistry);
}
示例3: configureReporters
import com.codahale.metrics.JmxReporter; //导入依赖的package包/类
@Override
public void configureReporters(final MetricRegistry metricRegistry) {
final Logger perfStatsLogger = LoggerFactory.getLogger(casProperties.getMetrics().getLoggerName());
registerReporter(Slf4jReporter
.forRegistry(metricRegistry)
.outputTo(perfStatsLogger)
.convertRatesTo(TimeUnit.MILLISECONDS)
.convertDurationsTo(TimeUnit.MILLISECONDS)
.build())
.start(casProperties.getMetrics().getRefreshInterval(), TimeUnit.SECONDS);
registerReporter(JmxReporter
.forRegistry(metricRegistry)
.build());
}
示例4: startReporter
import com.codahale.metrics.JmxReporter; //导入依赖的package包/类
/**
* Start metrics reporter.
*
*/
protected void startReporter() {
switch (cxt.conf.reporter) {
case "console":
consoleReporter = ConsoleReporter.forRegistry(cxt.register)
.convertRatesTo(TimeUnit.SECONDS)
.convertDurationsTo(TimeUnit.MILLISECONDS)
.build();
consoleReporter.start(cxt.conf.report_interval, TimeUnit.SECONDS);
break;
case "jmx":
jmxReporter = JmxReporter.forRegistry(cxt.register).build();
jmxReporter.start();
break;
default:
break;
}
}
示例5: init
import com.codahale.metrics.JmxReporter; //导入依赖的package包/类
@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");
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);
}
}
示例6: init
import com.codahale.metrics.JmxReporter; //导入依赖的package包/类
public void init() {
try {
if (config.isJMXEnabled()) {
jmxReporter = JmxReporter.forRegistry(metrics).build();
jmxReporter.start();
}
if (config.isAutoShutDown()) {
autoShutDownScheduler
.scheduleWithFixedDelay(this::shutDown, delayInSecs, delayInSecs, SECONDS);
}
logger.info("Initializing StatCollector file : " + statFileName);
statChannel = FileChannel.open(Paths.get(statFileName), CREATE, WRITE);
} catch (IOException e) {
logger.error("Error while creating stat file " + statFileName, e);
}
rsyncFailed = metrics.meter(name(INDUCTOR, "rsyncFailure"));
woFailed = metrics.meter(name(INDUCTOR, "woFailure"));
format = new DecimalFormat();
format.setMaximumFractionDigits(2);
statScheduler
.scheduleWithFixedDelay(this::writeStat, delayInSecs, delayInSecs, SECONDS);
}
示例7: main
import com.codahale.metrics.JmxReporter; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
try {
Log.info("Starting application");
org.apache.log4j.PropertyConfigurator.configure(getProperties("log4j.properties"));
org.apache.log4j.BasicConfigurator.configure();
JmxReporter.forRegistry(metricRegistry).build().start();
Properties producerProps = getProperties("producer.properties");
Properties appProperties = getProperties("app.properties");
int port = Integer.parseInt(appProperties.getProperty("port", "6306"));
boolean useInternalMeter = Integer.parseInt(appProperties.getProperty("useInternalMeter", "0")) > 0;
eventSender = new EventSender(producerProps);
httpServer = new HttpServer(eventSender, getValidatorFactory(), useInternalMeter).listen(port);
Log.info("Application started");
} catch (Exception ex) {
Log.error("Main error", ex);
}
Runtime.getRuntime().addShutdownHook(new Thread(Application::shutdown));
new BufferedReader(new InputStreamReader(System.in)).readLine();
}
示例8: enableJvm
import com.codahale.metrics.JmxReporter; //导入依赖的package包/类
public static void enableJvm() {
if (bEnableJvm)
return;
METRIC_REGISTRY.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet());
METRIC_REGISTRY.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet());
METRIC_REGISTRY.register(PROP_METRIC_REG_JVM_THREADS, new ThreadStatesGaugeSet());
METRIC_REGISTRY.register(PROP_METRIC_REG_JVM_FILES, new FileDescriptorRatioGauge());
METRIC_REGISTRY.register(PROP_METRIC_REG_JVM_BUFFERS,
new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
final JmxReporter jmxReporter = JmxReporter.forRegistry(METRIC_REGISTRY).build();
jmxReporter.start();
bEnableJvm = true;
}
示例9: configureReporters
import com.codahale.metrics.JmxReporter; //导入依赖的package包/类
@Override
public void configureReporters(MetricRegistry metricRegistry) {
final LoggerContext factory = (LoggerContext) LoggerFactory.getILoggerFactory();
final Logger root = factory.getLogger(Logger.ROOT_LOGGER_NAME);
final InstrumentedAppender metrics = new InstrumentedAppender(metricRegistry);
metrics.setContext(root.getLoggerContext());
metrics.start();
root.addAppender(metrics);
JmxReporter.forRegistry(metricRegistry).build().start();
Slf4jReporter reporter = Slf4jReporter.forRegistry(metricRegistry)
.outputTo(LoggerFactory.getLogger("metrics"))
.convertRatesTo(TimeUnit.SECONDS)
.convertDurationsTo(TimeUnit.MILLISECONDS)
.build();
reporter.start(1, TimeUnit.MINUTES);
}
示例10: init
import com.codahale.metrics.JmxReporter; //导入依赖的package包/类
@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");
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);
}
}
示例11: init
import com.codahale.metrics.JmxReporter; //导入依赖的package包/类
private static void init() {
// Init JMX reporter
reporter = JmxReporter.forRegistry(registry).build();
reporter.start();
// Init graphite reporter
Graphite graphite = getGraphite();
GraphiteReporter graphiteReporter;
if (graphite == null) {
graphiteReporter = null;
} else {
graphiteReporter =
GraphiteReporter.forRegistry(registry).prefixedWith(PREFIX).convertRatesTo(TimeUnit.SECONDS)
.convertDurationsTo(TimeUnit.MILLISECONDS).filter(MetricFilter.ALL).build(graphite);
graphiteReporter.start(AuditConfig.GRAPHITE_REPORT_PERIOD_SEC, TimeUnit.SECONDS);
}
}
示例12: getAPIResourceConfig
import com.codahale.metrics.JmxReporter; //导入依赖的package包/类
@Named("APIResourceConfig")
@Singleton
@Provides
public ResourceConfig getAPIResourceConfig(StateMachineResource stateMachineResource, DeploymentUnitResource deploymentUnitResource,
StatusResource statusResource, MetricRegistry metricRegistry) {
ResourceConfig resourceConfig = new ResourceConfig();
//Register codahale metrics and publish to jmx
resourceConfig.register(new InstrumentedResourceMethodApplicationListener(metricRegistry));
JmxReporter jmxReporter = JmxReporter.forRegistry(metricRegistry).build();
//register resources
resourceConfig.register(stateMachineResource);
resourceConfig.register(deploymentUnitResource);
resourceConfig.register(statusResource);
resourceConfig.register(CORSFilter.class);
jmxReporter.start();
return resourceConfig;
}
示例13: init
import com.codahale.metrics.JmxReporter; //导入依赖的package包/类
@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);
}
}
示例14: activateService
import com.codahale.metrics.JmxReporter; //导入依赖的package包/类
@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 ) );
}
}
示例15: initialize
import com.codahale.metrics.JmxReporter; //导入依赖的package包/类
public static void initialize(MetricRegistry registry) {
if (Metrics.registry != null) {
throw new IllegalStateException("Metrics were already initialized.");
}
Metrics.registry = registry;
registry.register("memory_usage", new MemoryUsageGaugeSet());
registry.register("garbage_collector", new GarbageCollectorMetricSet());
registry.register("jvm_attributes", new JvmAttributeGaugeSet());
final JmxReporter jmxReporter = JmxReporter.forRegistry(registry).build();
jmxReporter.start();
final Slf4jReporter slf4jReporter = Slf4jReporter.forRegistry(registry)
.outputTo(LoggerFactory.getLogger("com.puresoltechnologies.famility.server.metrics"))
.convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS).build();
slf4jReporter.start(1, TimeUnit.MINUTES);
}