本文整理汇总了Scala中com.codahale.metrics.JmxReporter类的典型用法代码示例。如果您正苦于以下问题:Scala JmxReporter类的具体用法?Scala JmxReporter怎么用?Scala JmxReporter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JmxReporter类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: Metrics
//设置package包名称以及导入依赖的类
package com.onur.moviedb.metric
import java.lang.management.ManagementFactory
import java.util.concurrent.TimeUnit
import com.codahale.metrics.health.HealthCheckRegistry
import com.codahale.metrics.{JmxReporter, MetricRegistry, Slf4jReporter}
import com.codahale.metrics.jvm.{BufferPoolMetricSet, GarbageCollectorMetricSet, MemoryUsageGaugeSet, ThreadStatesGaugeSet}
import org.slf4j.LoggerFactory
object Metrics {
lazy val metricRegistry: MetricRegistry = {
val metricRegistry: MetricRegistry = new MetricRegistry
Slf4jReporter.forRegistry(metricRegistry)
.outputTo(LoggerFactory.getLogger("metrics"))
.convertRatesTo(TimeUnit.SECONDS)
.convertDurationsTo(TimeUnit.MILLISECONDS)
.build
.start(30, TimeUnit.SECONDS)
JmxReporter.forRegistry(metricRegistry).build.start()
metricRegistry.register("jvm-gc", new GarbageCollectorMetricSet)
metricRegistry.register("jvm-buffer", new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer))
metricRegistry.register("jvm-memory", new MemoryUsageGaugeSet)
metricRegistry.register("jvm-threads", new ThreadStatesGaugeSet)
metricRegistry
}
lazy val healthCheckRegistry = new HealthCheckRegistry
}