本文整理汇总了Scala中com.codahale.metrics.Slf4jReporter类的典型用法代码示例。如果您正苦于以下问题:Scala Slf4jReporter类的具体用法?Scala Slf4jReporter怎么用?Scala Slf4jReporter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Slf4jReporter类的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: ScrapingKitReactorTest
//设置package包名称以及导入依赖的类
package ru.fediq.scrapingkit
import java.util.concurrent.TimeUnit
import akka.actor.ActorSystem
import akka.http.scaladsl.model.{HttpMethods, Uri}
import com.codahale.metrics.Slf4jReporter
import com.codahale.metrics.Slf4jReporter.LoggingLevel
import com.typesafe.config.ConfigFactory
import org.scalatest.FlatSpec
import org.slf4j.LoggerFactory
import ru.fediq.scrapingkit.backend.{InMemoryFifoLinksQueue, InMemoryLinksHistory, NoOpFeedExporter, NoOpPageCache}
import ru.fediq.scrapingkit.model.PageRef
import ru.fediq.scrapingkit.scraper.HtmlCrawlingScraper
import ru.fediq.scrapingkit.util.Metrics
class ScrapingKitReactorTest extends FlatSpec {
"Reactor" should "crawl something" in {
val scraperName = "crawl"
val scrapers = Map(scraperName -> new HtmlCrawlingScraper(scraperName))
val config = ConfigFactory.load()
implicit val system = ActorSystem("reactor-test", config)
val linksQueue = new InMemoryFifoLinksQueue()
val linksHistory = new InMemoryLinksHistory()
val pageCache = new NoOpPageCache()
val exporter = new NoOpFeedExporter()
val reactor = new ScrapingKitReactor(linksQueue, linksHistory, pageCache, exporter, scrapers)
linksQueue.enqueue(PageRef(Uri("http://quotes.toscrape.com/"), HttpMethods.GET, scraperName))
Slf4jReporter
.forRegistry(Metrics.metricRegistry)
.withLoggingLevel(LoggingLevel.INFO)
.outputTo(LoggerFactory.getLogger("METRICS"))
.convertDurationsTo(TimeUnit.MILLISECONDS)
.convertRatesTo(TimeUnit.SECONDS)
.build()
.start(10, TimeUnit.SECONDS)
Thread.sleep(10000)
reactor.close()
}
}
开发者ID:fediq,项目名称:scraping-kit,代码行数:48,代码来源:ScrapingKitReactorTest.scala
示例3: Slf4jReporterLoader
//设置package包名称以及导入依赖的类
package eu.inn.metrics.loaders
import java.util.concurrent.TimeUnit
import com.codahale.metrics.{MetricRegistry, Slf4jReporter}
import scaldi.{Injectable, Injector}
import scala.concurrent.duration.Duration
class Slf4jReporterLoader(period: Duration)(implicit injector: Injector) extends MetricsReporterLoader with Injectable {
lazy val slf4jReporter = {
Slf4jReporter.forRegistry(inject[MetricRegistry]).build()
}
override def run(): Unit = {
if (period.isFinite) {
slf4jReporter.start(period.toMillis, TimeUnit.MILLISECONDS)
} else {
slf4jReporter.hashCode() //instantiate lazy val
}
}
}
开发者ID:InnovaCo,项目名称:service-metrics,代码行数:23,代码来源:Slf4jReporterLoader.scala
注:本文中的com.codahale.metrics.Slf4jReporter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论