當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。