當前位置: 首頁>>代碼示例>>Java>>正文


Java Slf4jReporter類代碼示例

本文整理匯總了Java中com.codahale.metrics.Slf4jReporter的典型用法代碼示例。如果您正苦於以下問題:Java Slf4jReporter類的具體用法?Java Slf4jReporter怎麽用?Java Slf4jReporter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Slf4jReporter類屬於com.codahale.metrics包,在下文中一共展示了Slf4jReporter類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: init

import com.codahale.metrics.Slf4jReporter; //導入依賴的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: configureReporters

import com.codahale.metrics.Slf4jReporter; //導入依賴的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

示例3: init

import com.codahale.metrics.Slf4jReporter; //導入依賴的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

示例4: startMetricReporters

import com.codahale.metrics.Slf4jReporter; //導入依賴的package包/類
protected void startMetricReporters(int metricsReportingInterval, int graphitePort, String graphiteHostname, MetricRegistry metricRegistry) {
    if (shouldCreateLoggingMetricsReporter()) {
        registerReporter(Slf4jReporter.forRegistry(metricRegistry)
                .convertDurationsTo(MILLISECONDS)
                .convertRatesTo(SECONDS)
                .withLoggingLevel(TRACE)
                .outputTo(getLogger(ReverseProxyFilter.class))
                .build()
        ).start(metricsReportingInterval, SECONDS);
    }
    if (shouldCreateGraphiteMetricsReporter()) {
        Graphite graphite = new Graphite(graphiteHostname, graphitePort);
        registerReporter(GraphiteReporter.forRegistry(metricRegistry)
                .convertDurationsTo(MILLISECONDS)
                .convertRatesTo(SECONDS)
                .build(graphite)
        ).start(metricsReportingInterval, SECONDS);
    }
}
 
開發者ID:mkopylec,項目名稱:charon-spring-boot-starter,代碼行數:20,代碼來源:CharonConfiguration.java

示例5: createSlf4jReporter

import com.codahale.metrics.Slf4jReporter; //導入依賴的package包/類
/**
 * Creates a {@link DropwizardMetricRegistry} with an {@link Slf4jReporter}.  Only non-zero metrics
 * will be logged to the {@link Slf4jReporter}.
 * 
 * @param registry The registry on which to add the reporter.
 * @param logger The {@link Logger} to report to
 * @param period the amount of time between polls
 * @param unit   the unit for {@code period}
 */
public static void createSlf4jReporter(DropwizardMetricRegistry registry, Logger logger,
    long period, TimeUnit unit) {
  MetricFilter nonZeroMatcher =
      new MetricFilter() {
        @Override
        public boolean matches(String name, Metric metric) {
          if (metric instanceof Counting) {
            Counting counter = (Counting) metric;
            return counter.getCount() > 0;
          }
          return true;
        }
      };
  Slf4jReporter.forRegistry(registry.getRegistry())
      .outputTo(logger)
      .convertRatesTo(TimeUnit.SECONDS)
      .convertDurationsTo(TimeUnit.MILLISECONDS)
      .filter(nonZeroMatcher)
      .build()
      .start(period, unit);
}
 
開發者ID:benson-git,項目名稱:ibole-microservice,代碼行數:31,代碼來源:DropwizardMetricRegistry.java

示例6: run

import com.codahale.metrics.Slf4jReporter; //導入依賴的package包/類
@Override
public void run(DemoConfiguration config, Environment env) throws Exception {
  DemoProducer producer = new DemoProducer(config.getKafkaConfig(), env.metrics());
  DemoConsumer consumer = new DemoConsumer(config.getKafkaConfig(), env.metrics());

  env.lifecycle().manage(producer);
  env.lifecycle().manage(consumer);

  env.jersey().register(DeclarativeLinkingFeature.class);
  env.jersey().register(new DemoResource(producer, consumer));

  final Slf4jReporter reporter = Slf4jReporter.forRegistry(env.metrics())
          .outputTo(LOG)
          .convertRatesTo(TimeUnit.SECONDS)
          .convertDurationsTo(TimeUnit.MILLISECONDS)
          .build();

  reporter.start(1, TimeUnit.MINUTES);
}
 
開發者ID:herokumx,項目名稱:kafka-rest,代碼行數:20,代碼來源:DemoApplication.java

示例7: configureReporters

import com.codahale.metrics.Slf4jReporter; //導入依賴的package包/類
@Override
public void configureReporters(MetricRegistry metricRegistry) {

    registerReporter(Slf4jReporter.forRegistry(metricRegistry)
            .outputTo(LoggerFactory.getLogger("metrics"))
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .build()).start(1, TimeUnit.MINUTES);

    // set DNS ttl to 60 per Hosted Graphite documentation
    java.security.Security.setProperty("networkaddress.cache.ttl", "60");
    Graphite graphite = new Graphite(new InetSocketAddress(graphiteHost, graphitePort));

    registerReporter(GraphiteReporter.forRegistry(metricRegistry)
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .prefixedWith(graphiteApiKey)
            .build(graphite)).start(1, TimeUnit.MINUTES);
}
 
開發者ID:rpmartz,項目名稱:booktrackr,代碼行數:20,代碼來源:MetricsConfig.java

示例8: configureReporters

import com.codahale.metrics.Slf4jReporter; //導入依賴的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

示例9: init

import com.codahale.metrics.Slf4jReporter; //導入依賴的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

示例10: init

import com.codahale.metrics.Slf4jReporter; //導入依賴的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

示例11: initialize

import com.codahale.metrics.Slf4jReporter; //導入依賴的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

示例12: main

import com.codahale.metrics.Slf4jReporter; //導入依賴的package包/類
public static void main(String[] args)
{
    PipelineContext context = new PipelineContext(new BasicPacketFactory());

    DirectPipeline pipeline = new DirectPipeline(context);

    pipeline
        .addSource(new RandomIntGenerator(0, 10))
        .setReceiver(new FilterTransformation<>(new MinMaxFilter<>(3, 7)))
        .setReceiver(new PrintSink());

    pipeline
        .addSource(new StdInSource())
        .setReceiver(new FilterTransformation<>(new StringContainsFilter("foo")))
        .setReceiver(new UpperCaseTransformation())
        .setReceiver(new PrintSink());

    pipeline.start();

    final Slf4jReporter reporter = Slf4jReporter.forRegistry(context.getMetrics())
        .outputTo(LoggerFactory.getLogger("io.humbird.metrics"))
        .convertRatesTo(TimeUnit.SECONDS)
        .convertDurationsTo(TimeUnit.MILLISECONDS)
        .build();
    reporter.start(5, TimeUnit.SECONDS);
}
 
開發者ID:bandesz,項目名稱:humbird.io,代碼行數:27,代碼來源:DirectPipelineDemo.java

示例13: doNotify

import com.codahale.metrics.Slf4jReporter; //導入依賴的package包/類
@Override
protected void doNotify(Record notification) {
  for (Object event : Notifications.getLifecycleEvents(notification)) {
    if (event == Notifications.LifecycleEvent.SHUTDOWN) {
      synchronized (REGISTRIES) {
        Map<String, Slf4jReporter> reporters = REGISTRIES.get(getContext().getMetricRegistry());
        if (reporters != null) {
          Slf4jReporter reporter = reporters.remove(logger);
          if (reporter != null) {
            reporter.stop();
          }
        }
      }
    }
  }
  super.doNotify(notification);
}
 
開發者ID:cloudera,項目名稱:cdk,代碼行數:18,代碼來源:StartReportingMetricsToSLF4JBuilder.java

示例14: start

import com.codahale.metrics.Slf4jReporter; //導入依賴的package包/類
@Override
public List<AutoCloseable> start(Params params) {
  SimpleConfiguration config =
      new FluoConfiguration(params.getConfiguration()).getReporterConfiguration("slf4j");

  if (!config.getBoolean("enable", false)) {
    return Collections.emptyList();
  }

  TimeUnit rateUnit = TimeUnit.valueOf(config.getString("rateUnit", "seconds").toUpperCase());
  TimeUnit durationUnit =
      TimeUnit.valueOf(config.getString("durationUnit", "milliseconds").toUpperCase());
  Logger logger = LoggerFactory.getLogger(config.getString("logger", "metrics"));

  Slf4jReporter reporter = Slf4jReporter.forRegistry(params.getMetricRegistry())
      .convertDurationsTo(durationUnit).convertRatesTo(rateUnit).outputTo(logger).build();
  reporter.start(config.getInt("frequency", 60), TimeUnit.SECONDS);

  log.info("Reporting metrics using slf4j");

  return Collections.singletonList((AutoCloseable) reporter);
}
 
開發者ID:apache,項目名稱:fluo,代碼行數:23,代碼來源:Slf4jReporterStarter.java

示例15: init

import com.codahale.metrics.Slf4jReporter; //導入依賴的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 (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");
        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:xm-online,項目名稱:xm-uaa,代碼行數:28,代碼來源:MetricsConfiguration.java


注:本文中的com.codahale.metrics.Slf4jReporter類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。