Skip to content

Commit

Permalink
Add try-catch to VersionFiltering (#939)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimunKaracic authored Feb 10, 2021
1 parent bc067bf commit 82a6fe3
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,17 @@ package kamon.instrumentation.akka.http

trait VersionFiltering {
def onAkkaHttp(version: String)(block: => Unit): Unit = {
if(akka.http.Version.current.startsWith(version))
val akkaHttpVersion = getVersion

if (akkaHttpVersion.exists(_.startsWith(version)))
block
}

private def getVersion: Option[String] = {
try {
Option(akka.http.Version.current)
} catch {
case _: Throwable => None
}
}
}

0 comments on commit 82a6fe3

Please sign in to comment.