Skip to content
This repository has been archived by the owner on May 27, 2021. It is now read-only.

Commit

Permalink
upgrade to Kamon 2.0.0-RC1
Browse files Browse the repository at this point in the history
  • Loading branch information
ivantopo committed Jun 18, 2019
1 parent b112e93 commit 3891345
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 20 deletions.
21 changes: 9 additions & 12 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
onLoad in Global ~= (_ andThen ("project kamonApmReporter" :: _))
//onLoad in Global ~= (_ andThen ("project kamonApmReporter" :: _))
resolvers += Resolver.bintrayRepo("kamon-io", "snapshots")

lazy val kamonCore = "io.kamon" %% "kamon-core" % "2.0.0-M5"
lazy val kamonCore = "io.kamon" %% "kamon-core" % "2.0.0-RC1"

lazy val kamonApmReporter = project
lazy val root = project
.settings(name := "kamon-apm-reporter")
.aggregate(reporter, publishing)

lazy val reporter = (project in file("."))
lazy val reporter = (project in file("kamon-apm-reporter"))
.enablePlugins(AssemblyPlugin)
.settings(
skip in publish := true,
name := "kamon-apm-reporter",
scalaVersion := "2.12.8",
crossScalaVersions := Seq("2.11.12", "2.12.8"),
assemblyOption in assembly := (assemblyOption in assembly).value.copy(
Expand Down Expand Up @@ -39,18 +38,16 @@ lazy val reporter = (project in file("."))
"com.google.protobuf" % "protobuf-java" % "3.8.0",
"com.squareup.okhttp3" % "okhttp" % "3.9.1",

"ch.qos.logback" % "logback-classic" % "1.2.3" % Test,
"org.scalatest" %% "scalatest" % "3.0.4" % Test,
"com.typesafe.akka" %% "akka-http" % "10.0.10" % Test,
"com.typesafe.akka" %% "akka-testkit" % "2.4.19" % Test
"ch.qos.logback" % "logback-classic" % "1.2.3" % "test",
"org.scalatest" %% "scalatest" % "3.0.4" % "test",
"com.typesafe.akka" %% "akka-http" % "10.0.10" % "test",
"com.typesafe.akka" %% "akka-testkit" % "2.4.19" % "test"
)
)

lazy val publishing = project
.settings(
name := (name in (reporter, Compile)).value,
scalaVersion := (scalaVersion in assembly).value,
crossScalaVersions := (crossScalaVersions in assembly).value,
moduleName := "kamon-apm-reporter",
packageBin in Compile := (assembly in (reporter, Compile)).value,
packageSrc in Compile := (packageSrc in (reporter, Compile)).value,
libraryDependencies += kamonCore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,5 @@ kamon.modules {
name = "Kamon APM Reporter"
description = "Sends metrics and traces data to Kamon APM"
factory = "kamon.apm.KamonApm$Factory"
config-path = "kamon.apm"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import scala.collection.JavaConverters.seqAsJavaListConverter
import scala.util.Try


class KamonApm(initialConfig: Config) extends CombinedReporter {
class KamonApm(configPath: String) extends CombinedReporter {
private val _maxSnapshotAge = Duration.ofMinutes(30)
private var _settings = readSettings(initialConfig)
private var _settings = readSettings(Kamon.config(), configPath)
private var _httpClient: Option[KamonApmApiClient] = Option(new KamonApmApiClient(_settings))
private val _valueBuffer = ByteBuffer.wrap(Array.ofDim[Byte](16))
private val _accumulator = PeriodSnapshot.accumulator(Duration.ofSeconds(60), Duration.ofSeconds(1))
Expand All @@ -39,7 +39,7 @@ class KamonApm(initialConfig: Config) extends CombinedReporter {
}

def this() =
this(Kamon.config().getConfig("kamon.apm"))
this("kamon.apm")

override def stop(): Unit = {
reportShutdown(Kamon.clock().millis())
Expand All @@ -48,7 +48,7 @@ class KamonApm(initialConfig: Config) extends CombinedReporter {
}

override def reconfigure(config: Config): Unit = {
_settings = readSettings(config)
_settings = readSettings(config, configPath)
_httpClient.foreach(_.stop)
_httpClient = Option(new KamonApmApiClient(_settings))
}
Expand Down Expand Up @@ -229,7 +229,7 @@ object KamonApm {

class Factory extends ModuleFactory {
override def create(settings: ModuleFactory.Settings): Module =
new KamonApm(settings.config)
new KamonApm()
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ package object apm {
private[apm] val _logger = LoggerFactory.getLogger("kamon.apm")
private val _apiKeyPattern = Pattern.compile("^[a-zA-Z0-9]*$")

def readSettings(apmConfig: Config): Settings = {
def readSettings(config: Config, path: String): Settings = {
val apmConfig = config.getConfig(path)
val apiKey = apmConfig.getString("api-key")

if(apiKey.equals("none"))
_logger.error("No API key defined in the kamino.api-key setting.")
_logger.error("No API key defined in the kamon.apm.api-key setting")

Settings (
apiKey = apiKey,
Expand Down

0 comments on commit 3891345

Please sign in to comment.