本文整理汇总了Scala中com.codahale.metrics.jvm.MemoryUsageGaugeSet类的典型用法代码示例。如果您正苦于以下问题:Scala MemoryUsageGaugeSet类的具体用法?Scala MemoryUsageGaugeSet怎么用?Scala MemoryUsageGaugeSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MemoryUsageGaugeSet类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
}
示例2: RemoraApp
//设置package包名称以及导入依赖的类
import java.io.IOException
import java.net.ConnectException
import java.util.concurrent.TimeoutException
import akka.actor.ActorSystem
import akka.stream.{ActorMaterializer, ActorMaterializerSettings, Supervision}
import com.codahale.metrics.jvm.{ThreadStatesGaugeSet, MemoryUsageGaugeSet, GarbageCollectorMetricSet}
import scala.util.control.NonFatal
object RemoraApp extends App with nl.grons.metrics.scala.DefaultInstrumented {
private val actorSystemName: String = "remora"
implicit val actorSystem = ActorSystem(actorSystemName)
metricRegistry.registerAll(new GarbageCollectorMetricSet)
metricRegistry.registerAll(new MemoryUsageGaugeSet)
metricRegistry.registerAll(new ThreadStatesGaugeSet)
lazy val decider: Supervision.Decider = {
case _: IOException | _: ConnectException | _: TimeoutException => Supervision.Restart
case NonFatal(err: Throwable) =>
actorSystem.log.error(err, "Unhandled Exception in Stream: {}", err.getMessage)
Supervision.Stop
}
implicit val materializer = ActorMaterializer(
ActorMaterializerSettings(actorSystem).withSupervisionStrategy(decider))(actorSystem)
implicit val executionContext = actorSystem.dispatchers.lookup("kafka-consumer-dispatcher")
val kafkaSettings = KafkaSettings(actorSystem.settings.config)
val consumer = new RemoraKafkaConsumerGroupService(kafkaSettings)
val kafkaClientActor = actorSystem.actorOf(KafkaClientActor.props(consumer), name = "kafka-client-actor")
Api(kafkaClientActor).start()
}
示例3: MetricsModule
//设置package包名称以及导入依赖的类
package dcos.metronome
import java.lang.management.ManagementFactory
import com.codahale.metrics.MetricRegistry
import com.codahale.metrics.health.HealthCheckRegistry
import com.codahale.metrics.jvm.{ BufferPoolMetricSet, GarbageCollectorMetricSet, MemoryUsageGaugeSet, ThreadStatesGaugeSet }
import mesosphere.marathon.metrics.Metrics
class MetricsModule {
lazy val healthCheckRegistry: HealthCheckRegistry = new HealthCheckRegistry()
lazy val metricsRegistry: MetricRegistry = {
val registry = new MetricRegistry
registry.register("jvm.gc", new GarbageCollectorMetricSet())
registry.register("jvm.buffers", new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer))
registry.register("jvm.memory", new MemoryUsageGaugeSet())
registry.register("jvm.threads", new ThreadStatesGaugeSet())
registry
}
lazy val metrics = new Metrics(metricsRegistry)
}