aboutsummaryrefslogtreecommitdiff
path: root/kamon-core
diff options
context:
space:
mode:
authorIvan Topolnjak <ivantopo@gmail.com>2018-02-10 01:12:36 +0100
committerIvan Topolnjak <ivantopo@gmail.com>2018-02-10 01:15:11 +0100
commitd64bbb1fdb634cafe13c0a19886550332d08f683 (patch)
tree27955096476dfbf5e53af926146bf2f1ac1c0653 /kamon-core
parentfa342db5ec6e80227d559ee5ac9d0b11b9f0b453 (diff)
downloadKamon-d64bbb1fdb634cafe13c0a19886550332d08f683.tar.gz
Kamon-d64bbb1fdb634cafe13c0a19886550332d08f683.tar.bz2
Kamon-d64bbb1fdb634cafe13c0a19886550332d08f683.zip
add support for environment tags, fixes #510
Diffstat (limited to 'kamon-core')
-rw-r--r--kamon-core/src/main/resources/reference.conf12
-rw-r--r--kamon-core/src/main/scala/kamon/Environment.scala7
2 files changed, 16 insertions, 3 deletions
diff --git a/kamon-core/src/main/resources/reference.conf b/kamon-core/src/main/resources/reference.conf
index 659114ca..b3fd3b17 100644
--- a/kamon-core/src/main/resources/reference.conf
+++ b/kamon-core/src/main/resources/reference.conf
@@ -11,6 +11,18 @@ kamon {
# Identifier for a particular instance of this service. If set to `auto` Kamon will use the pattern service@host.
instance = "auto"
+
+ # Arbitraty key-value pairs that further identify the environment where this service instance is running. Typically
+ # these tags will be used by the reporting modules as additional tags for all metrics or spans. Take a look at each
+ # reporter module's configuration to ensure these tags are supported and included in the reported data. Example:
+ #
+ # kamon.environment.tags {
+ # env = "staging"
+ # region = "us-east-1"
+ # }
+ tags {
+
+ }
}
# FQCN of the reporter instances that should be loaded when calling `Kamon.reporters.loadReportersFromConfig()`. All
diff --git a/kamon-core/src/main/scala/kamon/Environment.scala b/kamon-core/src/main/scala/kamon/Environment.scala
index 80833352..1c00679d 100644
--- a/kamon-core/src/main/scala/kamon/Environment.scala
+++ b/kamon-core/src/main/scala/kamon/Environment.scala
@@ -21,15 +21,16 @@ import java.util.concurrent.ThreadLocalRandom
import com.typesafe.config.Config
import kamon.util.HexCodec
-case class Environment(host: String, service: String, instance: String, incarnation: String)
+case class Environment(host: String, service: String, instance: String, incarnation: String, tags: Map[String, String])
object Environment {
private val incarnation = HexCodec.toLowerHex(ThreadLocalRandom.current().nextLong())
def fromConfig(config: Config): Environment = {
val environmentConfig = config.getConfig("kamon.environment")
-
val service = environmentConfig.getString("service")
+ val tagsConfig = environmentConfig.getConfig("tags")
+ val tags = tagsConfig.topLevelKeys.map(tag => (tag -> tagsConfig.getString(tag))).toMap
val host = readValueOrGenerate(
environmentConfig.getString("host"),
@@ -41,7 +42,7 @@ object Environment {
s"$service@$host"
)
- Environment(host, service, instance, incarnation)
+ Environment(host, service, instance, incarnation, tags)
}
private def readValueOrGenerate(configuredValue: String, generator: => String): String =