1

我正在尝试将KamonStatsD 后端一起用于 Akka 监控/遥测。我目前只有一个演员,我正在向ask呼叫者发送回复。我可以在 Graphana 和 Graphite 中看到我的自定义计数器数据以及 JVM 和操作系统统计信息,但没有来自 Akka 的参与者统计信息。我的项目就像这个介绍一样设置,但我添加了 Kamon 的东西和我自己的 HttpService。我错过了什么?

这是我的配置:

kamon {
  trace.level = simple-trace
  metric {
    tick-interval = 1 second
    filters {
      akka-actor.includes = [ "**" ]
      akka-router.includes = [ "**" ]
      akka-dispatcher.includes = [ "**" ]
      trace.includes =  [ "**" ]
      trace-segment.includes =  [ "**" ]
      histogram.includes =  [ "**" ]
      min-max-counter.includes =  [ "**" ]
      gauge.includes =  [ "**" ]
      counters.includes =  [ "**" ]
      # For web projects
      http-server.includes = [ "**" ]

      akka-actor.excludes = [ "**" ]
      akka-router.excludes = [ "**" ]
      akka-dispatcher.excludes = [ "**" ]
      counters.excludes =  [ "" ]
      trace-segment.excludes =  [ "" ]
      histogram.excludes =  [ "" ]
      min-max-counter.excludes =  [ "" ]
      gauge.excludes =  [ "" ]
      http-server.excludes =  [ "" ]
    }
  }

  akka {
    ask-pattern-timeout-warning = "lightweight"
  }

  statsd {
    hostname = "localhost" //Graphite Host
    port = "8125"
    flush-interval = 1 second
    max-packet-size = 1024 bytes
    subscriptions {
      histogram = ["**"]
      min-max-counter = ["**"]
      gauge = ["**"]
      counter = ["**"]
      trace = ["**"]
      trace-segment = ["**"]
      system-metric = ["**"]
      akka-actor = ["**"]
      akka-dispatcher = ["**"]
      http-server = ["**"]
    }
    report-system-metrics = true

    simple-metric-key-generator {
      application = "data-id-generator"
    }
  }
  system-metrics {
    #sigar is enabled by default
    sigar-enabled = false

    #jmx related metrics are enabled by default
    jmx-enabled = true
  }
}

这是我的服务:

import akka.event.Logging
import akka.http.scaladsl.server.Directives._
import akka.http.scaladsl.server.Route
import akka.pattern.ask
import akka.util.{ByteString, Timeout}
import com.incontact.data.GeneratorActor.GenerateId
import com.incontact.data.IdGenerator.{GeneratorError, IdResult}
import com.incontact.http.HttpService
import akka.http.scaladsl.model.StatusCodes._
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport
import spray.json._
import kamon.Kamon

import scala.concurrent.duration._

trait IdService extends HttpService with SprayJsonSupport with DefaultJsonProtocol {
  private lazy val log = Logging(system, classOf[IdService])

  implicit val timeout: Timeout = 1.second
  //implicit val errorFormat = jsonFormat2(GeneratorError)

  abstract override def route: Route = {
    log.info("creating generator actor")
    val generator = system.actorOf(GeneratorActor.props, "generator")
    val counter = Kamon.metrics.counter("generate-long-id")

    path("") {
      get {
        counter.increment()
        log.info("IdService sending single request to actor")
        onSuccess((generator ? GenerateId).mapTo[IdResult]) {
          case Right(id) => complete(ByteString(s"${id}\n"))
          case Left(e:GeneratorError) => failWith(e.Error)
        }
      }
    }
  } ~ super.route
}

Main.scala(启动)

import akka.event.Logging
import com.incontact.data.IdService
import com.incontact.http.HttpServer
import kamon.Kamon

import scala.io.StdIn
import scala.util.Success

object Main extends App
  with HttpServer
  with IdService {

  Kamon.start()

  private lazy val log = Logging(system, getClass)
  bindingFuture.andThen {
    case Success(binding) =>
      // this really doesn't support any production behavior since [ENTER] won't be used to shut down the docker container
      log.info("Press ENTER to exit")
      StdIn.readLine()
      log.info("Shutting down...")
      Kamon.shutdown()
      system.terminate()
  }
}

构建.sbt

scalaVersion := "2.11.8"
val akkaVersion = "2.4.14"
val kamonVersion = "0.6.3"

libraryDependencies ++= Seq(
 // remove multiple-dependency warnings
 "org.scala-lang" % "scala-reflect" % scalaVersion.value,
 "org.scala-lang.modules" %% "scala-xml" % "1.0.5",

 // application dependencies
 "com.typesafe.akka" %% "akka-actor" % akkaVersion,
 "com.typesafe.akka" %% "akka-http" % "10.0.0",
 "com.typesafe.akka" %% "akka-http-spray-json" % "10.0.0",
 "com.amazonaws" % "aws-java-sdk-dynamodb" % "1.11.63",

 // kamon dependencies
 "io.kamon" %% "kamon-core" % kamonVersion,
 "io.kamon" %% "kamon-statsd" % kamonVersion,
 "io.kamon" %% "kamon-system-metrics" % kamonVersion,
 "org.aspectj" % "aspectjweaver" % "1.8.6",

 // test dependencies
 "com.typesafe.akka" %% "akka-testkit" % akkaVersion % "test",
 "org.scalatest" %% "scalatest" % "3.0.1" % "test",
 "com.typesafe.akka" %% "akka-http-testkit" % "10.0.0" % "test",
 "org.pegdown" % "pegdown" % "1.1.0" % "test"
)

项目/plugins.sbt

addSbtPlugin("io.kamon" % "aspectj-runner" % "0.1.3")

从命令行启动:

$ sbt aspectj-runner:run
4

1 回答 1

2

看起来您正在排除配置中的所有参与者/调度程序/路由器指标。这应该排除所有指标(即使您还包括所有指标)。

  akka-actor.excludes = [ "**" ]
  akka-router.excludes = [ "**" ]
  akka-dispatcher.excludes = [ "**" ]

尝试将其更改为

  akka-actor.excludes = [  ]
  akka-router.excludes = [  ]
  akka-dispatcher.excludes = [  ]
于 2016-12-08T21:28:23.780 回答