• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Scala MetricFilter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Scala中com.codahale.metrics.MetricFilter的典型用法代码示例。如果您正苦于以下问题:Scala MetricFilter类的具体用法?Scala MetricFilter怎么用?Scala MetricFilter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了MetricFilter类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。

示例1: Config

//设置package包名称以及导入依赖的类
package config

import java.net.InetSocketAddress
import java.util.concurrent.TimeUnit._
import com.codahale.metrics.graphite.{Graphite, GraphiteReporter}
import com.codahale.metrics.{MetricFilter, SharedMetricRegistries}
import play.api._

object Config extends GlobalSettings {

  override def onStart(app: Application) {
      val metricsEnabled = app.configuration.getString("metrics.enabled").getOrElse("false").toBoolean
      if (metricsEnabled) {
        setupGraphite(app)
      }
      Logger.info("Application has started")

   }


 private def setupGraphite(app: Application)  = {

//  val graphite = new PickledGraphite(new InetSocketAddress("graphite.example.com", 2004));


  val metricsPrefix = app.configuration.getString("metrics.prefix").getOrElse("NO-PREFIX")
  val metricsHost = app.configuration.getString("metrics.server.address").getOrElse("localhost")
  val metricsPort = app.configuration.getInt("metrics.server.port").getOrElse(2003)

  val graphite = new Graphite(new InetSocketAddress(metricsHost, metricsPort));

  val registry = SharedMetricRegistries.getOrCreate("default")
  val reporter : GraphiteReporter =  GraphiteReporter.forRegistry(registry)
                                          .prefixedWith(s"$metricsPrefix.${java.net.InetAddress.getLocalHost.getHostName}")
                                          .convertRatesTo(SECONDS)
                                          .convertDurationsTo(MILLISECONDS)
                                          .filter(MetricFilter.ALL)
                                          .build(graphite);
  reporter.start(1, SECONDS);

 }
} 
开发者ID:RobTaylor76,项目名称:play-scala-metrics,代码行数:43,代码来源:config.scala


示例2: SystemResource

//设置package包名称以及导入依赖的类
package mesosphere.marathon.api

import java.io.StringWriter
import java.util.concurrent.TimeUnit
import javax.servlet.http.HttpServletRequest
import javax.ws.rs._
import javax.ws.rs.core.{ Context, MediaType, Response }

import com.codahale.metrics.{ MetricFilter, MetricRegistry }
import com.codahale.metrics.annotation.Timed
import com.codahale.metrics.json.MetricsModule
import com.fasterxml.jackson.databind.ObjectMapper
import com.google.inject.Inject
import mesosphere.marathon.MarathonConf
import mesosphere.marathon.io.IO
import mesosphere.marathon.plugin.auth.AuthorizedResource.SystemConfig
import mesosphere.marathon.plugin.auth.{ Authenticator, Authorizer, ViewResource }


@Path("")
@Consumes(Array(MediaType.APPLICATION_JSON))
@Produces(Array(MarathonMediaType.PREFERRED_APPLICATION_JSON))
class SystemResource @Inject() (metrics: MetricRegistry, val config: MarathonConf)(implicit
  val authenticator: Authenticator,
    val authorizer: Authorizer) extends RestResource with AuthResource {

  private[this] lazy val mapper = new ObjectMapper().registerModule(
    new MetricsModule(TimeUnit.SECONDS, TimeUnit.SECONDS, false, MetricFilter.ALL)
  )

  @GET
  @Path("ping")
  @Timed
  def ping(@Context req: HttpServletRequest): Response = authenticated(req) { implicit identity =>
    withAuthorization(ViewResource, SystemConfig){
      ok("pong")
    }
  }

  @GET
  @Path("metrics")
  @Timed
  def metrics(@Context req: HttpServletRequest): Response = authenticated(req) { implicit identity =>
    withAuthorization(ViewResource, SystemConfig){
      IO.using(new StringWriter()) { writer =>
        mapper.writer().writeValue(writer, metrics)
        ok(writer.toString)
      }
    }
  }
} 
开发者ID:xiaozai512,项目名称:marathon,代码行数:52,代码来源:SystemResource.scala


示例3: InfluxDbReporter

//设置package包名称以及导入依赖的类
package com.jgrier.flinkstuff.metrics

import java.util.concurrent.TimeUnit

import com.codahale.metrics.{MetricFilter, ScheduledReporter}
import metrics_influxdb.{HttpInfluxdbProtocol, InfluxdbReporter}
import metrics_influxdb.api.measurements.CategoriesMetricMeasurementTransformer
import org.apache.flink.dropwizard.ScheduledDropwizardReporter
import org.apache.flink.metrics.MetricConfig


class InfluxDbReporter extends ScheduledDropwizardReporter {
  override def getReporter(metricConfig: MetricConfig): ScheduledReporter = {

    val server = metricConfig.getString("server", "localhost")
    val port = metricConfig.getInteger("port", 8086)
    val user = metricConfig.getString("user", "admin")
    val password = metricConfig.getString("password", "admin")
    val db = metricConfig.getString("db", "flink")

    InfluxdbReporter.forRegistry(registry)
      .protocol(new HttpInfluxdbProtocol(server, port, user, password, db))
      .convertRatesTo(TimeUnit.SECONDS)
      .convertDurationsTo(TimeUnit.MILLISECONDS)
      .filter(MetricFilter.ALL)
      .skipIdleMetrics(false)
      .transformer(new CategoriesMetricMeasurementTransformer("host", "process_type", "tm_id", "job_name", "task_name", "subtask_index"))
      .build()
  }
} 
开发者ID:jgrier,项目名称:flink-stuff,代码行数:31,代码来源:InfluxDbReporter.scala


示例4: Graphite

//设置package包名称以及导入依赖的类
package utility.metric

import java.net.InetSocketAddress
import java.util.concurrent.TimeUnit._

import com.codahale.metrics.graphite.{Graphite, GraphiteReporter}
import com.codahale.metrics.{MetricFilter, SharedMetricRegistries}
import config.AppConfig


object Graphite {

  lazy val config = AppConfig

  val graphite = new Graphite(new InetSocketAddress(
    config.metricHost, config.metricPort))

  lazy val prefix: String = config.metricPrefix

  val reporter = GraphiteReporter.forRegistry(
    SharedMetricRegistries.getOrCreate(prefix))
    .prefixedWith(s"$prefix.${java.net.InetAddress.getLocalHost.getHostName}")
    .convertRatesTo(SECONDS)
    .convertDurationsTo(MILLISECONDS)
    .filter(MetricFilter.ALL)
    .build(graphite)

  def startGraphite(): Unit = {
    if (config.metricEnabled) {
      reporter.start(config.metricRefreshInterval, SECONDS)
    }
  }
} 
开发者ID:Harl0,项目名称:play-scala-forms-2.6,代码行数:34,代码来源:Graphite.scala



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Scala CopyOnWriteArrayList类代码示例发布时间:2022-05-23
下一篇:
Scala SparseVector类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap