diff options
author | Diego Parra <diegolparra@gmail.com> | 2015-04-11 09:23:34 -0300 |
---|---|---|
committer | Diego Parra <diegolparra@gmail.com> | 2015-04-11 09:23:34 -0300 |
commit | 851d28402be634966cf4130bce4f54eaddd1cbe8 (patch) | |
tree | bd263a6d7e9adb62110435d6a9cf683d5ab6728e /kamon-play/src/main/scala | |
parent | fc86654c2ff451fa222677b27a5b45e024b93f61 (diff) | |
parent | bf54ca0e8fdb3c3e54bafb87ac716ee95b8fbe78 (diff) | |
download | Kamon-851d28402be634966cf4130bce4f54eaddd1cbe8.tar.gz Kamon-851d28402be634966cf4130bce4f54eaddd1cbe8.tar.bz2 Kamon-851d28402be634966cf4130bce4f54eaddd1cbe8.zip |
Merge pull request #159 from magro/master
= play: Compile pattern for path normalization only once
Diffstat (limited to 'kamon-play/src/main/scala')
-rw-r--r-- | kamon-play/src/main/scala/kamon/play/instrumentation/RequestInstrumentation.scala | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/kamon-play/src/main/scala/kamon/play/instrumentation/RequestInstrumentation.scala b/kamon-play/src/main/scala/kamon/play/instrumentation/RequestInstrumentation.scala index 9079b391..5214f420 100644 --- a/kamon-play/src/main/scala/kamon/play/instrumentation/RequestInstrumentation.scala +++ b/kamon-play/src/main/scala/kamon/play/instrumentation/RequestInstrumentation.scala @@ -106,12 +106,14 @@ object RequestInstrumentation { private val cache = TrieMap.empty[String, String] + private val normalizePattern = """\$([^<]+)<[^>]+>""".r + def normaliseTraceName(requestHeader: RequestHeader): Option[String] = requestHeader.tags.get(Routes.ROUTE_VERB).map({ verb ⇒ val path = requestHeader.tags(Routes.ROUTE_PATTERN) cache.atomicGetOrElseUpdate(s"$verb$path", { val traceName = { // Convert paths of form GET /foo/bar/$paramname<regexp>/blah to foo.bar.paramname.blah.get - val p = path.replaceAll("""\$([^<]+)<[^>]+>""", "$1").replace('/', '.').dropWhile(_ == '.') + val p = normalizePattern.replaceAllIn(path, "$1").replace('/', '.').dropWhile(_ == '.') val normalisedPath = { if (p.lastOption.filter(_ != '.').isDefined) s"$p." else p |