aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Topolnjak <ivantopo@gmail.com>2018-09-18 12:19:08 +0200
committerIvan Topolnjak <ivantopo@gmail.com>2018-09-18 12:19:08 +0200
commit6941f53c79bb4ad8adb5ebc4bcc3a3c44d02e353 (patch)
tree39e0f9aabb676ec5a0e5f46eda7e4c25c1bb9a67
parent3af459577753485e74e3ae93b2cd02bb19c6910f (diff)
downloadKamon-6941f53c79bb4ad8adb5ebc4bcc3a3c44d02e353.tar.gz
Kamon-6941f53c79bb4ad8adb5ebc4bcc3a3c44d02e353.tar.bz2
Kamon-6941f53c79bb4ad8adb5ebc4bcc3a3c44d02e353.zip
use NonFatal instead of plain Throwable when catching exceptions
-rw-r--r--kamon-core/src/main/scala/kamon/ContextStorage.scala4
-rw-r--r--kamon-core/src/main/scala/kamon/context/HttpPropagation.scala9
2 files changed, 8 insertions, 5 deletions
diff --git a/kamon-core/src/main/scala/kamon/ContextStorage.scala b/kamon-core/src/main/scala/kamon/ContextStorage.scala
index ee35264a..47d0b567 100644
--- a/kamon-core/src/main/scala/kamon/ContextStorage.scala
+++ b/kamon-core/src/main/scala/kamon/ContextStorage.scala
@@ -3,6 +3,8 @@ package kamon
import kamon.context.{Context, Storage}
import kamon.trace.Span
+import scala.util.control.NonFatal
+
trait ContextStorage {
private val _contextStorage = Storage.ThreadLocal()
@@ -34,7 +36,7 @@ trait ContextStorage {
try {
withContextKey(Span.ContextKey, span)(f)
} catch {
- case t: Throwable =>
+ case NonFatal(t) =>
span.addError(t.getMessage, t)
throw t
diff --git a/kamon-core/src/main/scala/kamon/context/HttpPropagation.scala b/kamon-core/src/main/scala/kamon/context/HttpPropagation.scala
index d225aa28..d53a6250 100644
--- a/kamon-core/src/main/scala/kamon/context/HttpPropagation.scala
+++ b/kamon-core/src/main/scala/kamon/context/HttpPropagation.scala
@@ -5,6 +5,7 @@ import com.typesafe.config.Config
import org.slf4j.LoggerFactory
import scala.reflect.ClassTag
+import scala.util.control.NonFatal
import scala.util.{Failure, Success}
/**
@@ -145,7 +146,7 @@ object HttpPropagation {
})
}
} catch {
- case t: Throwable => log.warn("Failed to read the context tags header", t.asInstanceOf[Any])
+ case NonFatal(t) => log.warn("Failed to read the context tags header", t.asInstanceOf[Any])
}
// Tags explicitly mapped on the tags.mappings configuration.
@@ -154,7 +155,7 @@ object HttpPropagation {
try {
reader.readHeader(httpHeader).foreach(tagValue => tags += (tagName -> tagValue))
} catch {
- case t: Throwable => log.warn("Failed to read mapped tag [{}]", tagName, t.asInstanceOf[Any])
+ case NonFatal(t) => log.warn("Failed to read mapped tag [{}]", tagName, t.asInstanceOf[Any])
}
}
@@ -165,7 +166,7 @@ object HttpPropagation {
try {
result = entryDecoder.readEntry(reader, context)
} catch {
- case t: Throwable => log.warn("Failed to read entry [{}]", entryName.asInstanceOf[Any], t.asInstanceOf[Any])
+ case NonFatal(t) => log.warn("Failed to read entry [{}]", entryName.asInstanceOf[Any], t.asInstanceOf[Any])
}
result
@@ -209,7 +210,7 @@ object HttpPropagation {
try {
entryWriter.writeEntry(context, writer, direction)
} catch {
- case t: Throwable => log.warn("Failed to write entry [{}] due to: {}", entryName.asInstanceOf[Any], t.asInstanceOf[Any])
+ case NonFatal(t) => log.warn("Failed to write entry [{}] due to: {}", entryName.asInstanceOf[Any], t.asInstanceOf[Any])
}
}
}