Skip to content

Commit 82a6fe3

Browse files
authored
Add try-catch to VersionFiltering (#939)
1 parent bc067bf commit 82a6fe3

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

instrumentation/kamon-akka-http/src/main/scala/kamon/instrumentation/akka/http/VersionFiltering.scala

+11-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,17 @@ package kamon.instrumentation.akka.http
22

33
trait VersionFiltering {
44
def onAkkaHttp(version: String)(block: => Unit): Unit = {
5-
if(akka.http.Version.current.startsWith(version))
5+
val akkaHttpVersion = getVersion
6+
7+
if (akkaHttpVersion.exists(_.startsWith(version)))
68
block
79
}
10+
11+
private def getVersion: Option[String] = {
12+
try {
13+
Option(akka.http.Version.current)
14+
} catch {
15+
case _: Throwable => None
16+
}
17+
}
818
}

0 commit comments

Comments
 (0)