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


Scala MemoryUsageGaugeSet类代码示例

本文整理汇总了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
} 
开发者ID:onurzdg,项目名称:movie-db,代码行数:31,代码来源:Metrics.scala

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

} 
开发者ID:zalando-incubator,项目名称:remora,代码行数:38,代码来源:RemoraApp.scala

示例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)
} 
开发者ID:dcos,项目名称:metronome,代码行数:25,代码来源:MetricsModule.scala


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