akka-http not showing metrics in NewRelic

我只是一个虾纸丫 提交于 2020-01-07 01:49:29

问题


I'm trying to monitor my akka-http Rest web-service with NewRelic

The application has only one GET url (defined with akka-http)

I have the following configuration in the plugins.sbt

logLevel := Level.Warn
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.0.4")
addSbtPlugin("com.gilt.sbt" % "sbt-newrelic" % "0.1.4")

I have the following configuration in the build.sbt

scalaVersion := "2.11.7"
name := "recommender-api"

...blablabla...

libraryDependencies += "com.typesafe.akka" % "akka-actor_2.11" % "2.4.2"
libraryDependencies += "com.typesafe.akka" % "akka-http-experimental_2.11" % "2.4.2"
libraryDependencies += "com.typesafe.akka" % "akka-http-spray-json-experimental_2.11" % "2.4.2"
libraryDependencies += "com.typesafe.akka" % "akka-slf4j_2.11" % "2.4.2"

newrelicIncludeApi := true
newrelicAppName := name.toString
enablePlugins(JavaServerAppPackaging, UniversalDeployPlugin, NewRelic)

I compile (and deploy) the code with sbt universal:publish, it creates a .zip, inside the .zip there is an executable file.

I pass the newRelic licenceKey by enviroment (NEW_RELIC_LICENSE_KEY)

The program starts and all works fine, the newRelic key is found (because the log dosen't say that it didn't find the key)

The aplication apears in the newRelic monitor system with the correct name

BUT NewRelic dosen't show any metrics

what I have to do to see some metrics on NewRelic?


回答1:


When you specify the value of newrelicAppName as name.toString, you are not doing what you expect.

name is a value of type sbt.SettingKey, this contains details of a setting's name, type, and a short description of what the key is used for.

The type that actually contains a value is an sbt.Setting. You can get a Setting from a SettingKey (in the current project and configuration) by calling the .value method.


So when you set the value like this:

newrelicAppName := name.toString

the value looks something like this:

$ show newrelicAppName
[info] sbt.SettingKey$$anon$4@54ec2887

Yes, that is actually a string containing lots of strange characters.


On the other hand, if you used the .value call:

newrelicAppName := name.value

the value then looks like:

$ show newrelicAppName
[info] my-project

My best guess is that New Relic doesn't like application names with strange characters (like dollar signs and ampersands). By setting a more normal string, you made it more likely that New Relic would accept such a name as input.

Note: the default value for newrelicAppName is the name for the containing project, so not setting the value at all in the first example would probably have "just worked" as you would have liked.




回答2:


I realy don't know what I did to make it work, the changes I made were:

In the build.sbt

newrelicVersion := "3.26.1"
newrelicAppName := "recommenders-jobs-api-monitor"

In the plugin.sbt

addSbtPlugin("com.gilt.sbt" % "sbt-newrelic" % "0.1.5")

(I updated de sbt-newrelic version)
(I harcoded the name of the new relic app)
(I specified the version of the Java Agent)



来源:https://stackoverflow.com/questions/35930515/akka-http-not-showing-metrics-in-newrelic

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!