0

我在 Akka 中创建了一个示例服务,用于测试 Kamon + DataDog 监控。

这是我添加的依赖项:

"io.kamon" %% "kamon-core" % "1.1.0",
"io.kamon" %% "kamon-datadog" % "1.0.0",
"io.kamon" %% "kamon-akka-2.5" % "1.0.1"

以下是启用的插件build.sbt

.enablePlugins(AshScriptPlugin, DockerPlugin, SbtAspectJRunner)

然后application.conf

kamon {
  datadog {
    time-units = "ms"
    memory-units = "b"
  }
  util {
    filters {
      "akka.tracked-actor" {
        includes = [ "testSystem/user/**" ]
        excludes = [ "testSystem/system/**" ]
      }

      "s3-worker-actors" {
        includes = [ "testSystem/user/s3Router/*" ]
      }

      "fb-worker-actors" {
        includes = [ "testSystem/user/fbRouter/*" ]
      }

      "akka.tracked-router" {
        includes = [ "testSystem/user/s3Router", "testSystem/user/fbRouter" ]
      }

      "akka.tracked-dispatcher" {
        includes = [ "**" ]
      }

      "akka.traced-actor" {
        includes = [ "**" ]
      }
    }
  }
  akka.actor-groups = [ "s3-worker-actors", "fb-worker-actors" ]
}

最后在Main我调用的类中:

Kamon.addReporter(new DatadogAgentReporter())

在 EC2 上,我为 docker 安装了 datadog-agent。

当我在 EC2 实例上运行服务容器然后查看 DataDog 界面时,我没有看到任何与 akka 相关的指标,只是一个标准指标列表,例如:datadog.process.agentdocker.cpu.usagesystem.io.await

如果将 akka 应用程序打包到 docker 并部署在 EC2 上,如何启用 akka 相关指标?

4

1 回答 1

0

启动 Akka 应用程序时,需要将 AspectJ weaver 添加为 Java 代理:-javaagent:aspectjweaver.jar

您可以在项目 SBT 配置中添加以下设置:

.settings(
  retrieveManaged := true,
  libraryDependencies += "org.aspectj" % "aspectjweaver" % aspectJWeaverV)

因此 AspectJ weaver JAR 将被复制到./lib_managed/jars/org.aspectj/aspectjweaver/aspectjweaver-[aspectJWeaverV].jar您的项目根目录中。

然后你可以在你的 Dockerfile 中引用这个 JAR:

COPY ./lib_managed/jars/org.aspectj/aspectjweaver/aspectjweaver-*.jar /app- 
workdir/aspectjweaver.jar
WORKDIR /app-workdir
CMD ["java", "-javaagent:aspectjweaver.jar", "-jar", "app.jar"]
于 2018-10-24T14:06:01.457 回答