当前位置: 首页>>代码示例>>Java>>正文


Java JmxReporter类代码示例

本文整理汇总了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);
    }
}
 
开发者ID:oktadeveloper,项目名称:jhipster-microservices-example,代码行数:24,代码来源:MetricsConfiguration.java

示例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);
}
 
开发者ID:linkedin,项目名称:cruise-control,代码行数:24,代码来源:KafkaCruiseControl.java

示例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());

}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:17,代码来源:CasMetricsConfiguration.java

示例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;
  }
}
 
开发者ID:HashDataInc,项目名称:bireme,代码行数:22,代码来源:Bireme.java

示例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);
    }
}
 
开发者ID:quanticc,项目名称:sentry,代码行数:25,代码来源:MetricsConfiguration.java

示例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);
}
 
开发者ID:oneops,项目名称:oneops,代码行数:25,代码来源:StatCollector.java

示例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();
}
 
开发者ID:vostok,项目名称:airlock.gate,代码行数:26,代码来源:Application.java

示例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;
	}
 
开发者ID:e-baloo,项目名称:it-keeps,代码行数:18,代码来源:MetricsFactory.java

示例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);
}
 
开发者ID:przodownikR1,项目名称:springJpaKata,代码行数:18,代码来源:MetricsConfig.java

示例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);
	}
}
 
开发者ID:alikemalocalan,项目名称:MicroBlog,代码行数:24,代码来源:MetricsConfiguration.java

示例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);
  }
}
 
开发者ID:uber,项目名称:chaperone,代码行数:17,代码来源:Metrics.java

示例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;
}
 
开发者ID:flipkart-incubator,项目名称:flux,代码行数:21,代码来源:ContainerModule.java

示例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);
    }
}
 
开发者ID:kalnee,项目名称:trivor,代码行数:27,代码来源:MetricsConfiguration.java

示例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 ) );
    }
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:19,代码来源:CodahaleMetricsMixin.java

示例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);
   }
 
开发者ID:PureSolTechnologies,项目名称:DuctileDB,代码行数:18,代码来源:Metrics.java


注:本文中的com.codahale.metrics.JmxReporter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。