aboutsummaryrefslogtreecommitdiff
path: root/kamon-core/src/main/scala/kamon/metric/Entity.scala
diff options
context:
space:
mode:
authorMartin Grotzke <martin.grotzke@googlemail.com>2017-07-06 17:22:55 +0200
committerDiego Parra <diegolparra@gmail.com>2017-07-06 12:22:55 -0300
commit79c7f9bbbbf775e09b7a02109a77986665be43bc (patch)
tree753cba629f7c24365eb6a41251ac20fa9a5c2355 /kamon-core/src/main/scala/kamon/metric/Entity.scala
parent097caeb1f15c24db6d28cb646a064a9f3d5fa80d (diff)
downloadKamon-kamon-0.6.x.tar.gz
Kamon-kamon-0.6.x.tar.bz2
Kamon-kamon-0.6.x.zip
Log warn when Entity with name=null is created / if dispatching entities fails (#475)kamon-0.6.x
An application that creates a metric while passing `null` as metrics name will not receive the expected `TickMetricSnapshot` (if it subscribes for metrics). As log level _warn_ (instead of error) is chosen, because from an application perspective the app's functionality is not affected, i.e. there's no _immediate_ action required, but it's ok if this gets solved eventually.
Diffstat (limited to 'kamon-core/src/main/scala/kamon/metric/Entity.scala')
-rw-r--r--kamon-core/src/main/scala/kamon/metric/Entity.scala9
1 files changed, 8 insertions, 1 deletions
diff --git a/kamon-core/src/main/scala/kamon/metric/Entity.scala b/kamon-core/src/main/scala/kamon/metric/Entity.scala
index 91249af0..17b728fd 100644
--- a/kamon-core/src/main/scala/kamon/metric/Entity.scala
+++ b/kamon-core/src/main/scala/kamon/metric/Entity.scala
@@ -16,6 +16,8 @@
package kamon.metric
+import org.slf4j.LoggerFactory
+
/**
* Identify a `thing` that is being monitored by Kamon. A [[kamon.metric.Entity]] is used to identify tracked `things`
* in both the metrics recording and reporting sides. Only the name and category fields are used with determining
@@ -23,9 +25,14 @@ package kamon.metric
*
* // TODO: Find a better word for `thing`.
*/
-case class Entity(name: String, category: String, tags: Map[String, String])
+case class Entity(name: String, category: String, tags: Map[String, String]) {
+ if(name == null) Entity.log.warn("Entity with name=null created (category: {}), your monitoring will not work as expected!", category)
+}
object Entity {
+
+ private lazy val log = LoggerFactory.getLogger(classOf[Entity])
+
def apply(name: String, category: String): Entity =
apply(name, category, Map.empty)