diff options
author | Ivan Topolnjak <ivantopo@gmail.com> | 2018-02-13 11:37:11 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-13 11:37:11 +0100 |
commit | d9ae0f4d50763017b8d33dfcb6094375a30cb361 (patch) | |
tree | ab6be198b4c27ea2237e8ca5b24e4092c8e05fec /kamon-core/src/main | |
parent | 26e8684b88c0c5abc4c6e0a1e5c59cd0be058186 (diff) | |
parent | d64bbb1fdb634cafe13c0a19886550332d08f683 (diff) | |
download | Kamon-d9ae0f4d50763017b8d33dfcb6094375a30cb361.tar.gz Kamon-d9ae0f4d50763017b8d33dfcb6094375a30cb361.tar.bz2 Kamon-d9ae0f4d50763017b8d33dfcb6094375a30cb361.zip |
Merge pull request #515 from ivantopo/issue#510/add-support-for-environment-tags
add support for environment tags, fixes #510
Diffstat (limited to 'kamon-core/src/main')
-rw-r--r-- | kamon-core/src/main/resources/reference.conf | 12 | ||||
-rw-r--r-- | kamon-core/src/main/scala/kamon/Environment.scala | 7 |
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 = |