diff options
author | Ivan Topolnjak <ivantopo@gmail.com> | 2014-11-09 18:44:39 +0100 |
---|---|---|
committer | Ivan Topolnjak <ivantopo@gmail.com> | 2014-11-09 18:44:39 +0100 |
commit | 6adfad4127d8fad73000d3c47e6a0f89d1e58fa5 (patch) | |
tree | 1e10d93c760542e9c95333c03e9756ee291eb7d1 /kamon-spray/src/main/scala/kamon/spray/Spray.scala | |
parent | 5681a09bdd1fdbc6a7e0a42bb51f18406b70eaff (diff) | |
parent | 01117944af0363e37807a071f8f22ecaca0931f6 (diff) | |
download | Kamon-6adfad4127d8fad73000d3c47e6a0f89d1e58fa5.tar.gz Kamon-6adfad4127d8fad73000d3c47e6a0f89d1e58fa5.tar.bz2 Kamon-6adfad4127d8fad73000d3c47e6a0f89d1e58fa5.zip |
Merge branch 'wip/newrelic-agent-rewrite'
Diffstat (limited to 'kamon-spray/src/main/scala/kamon/spray/Spray.scala')
-rw-r--r-- | kamon-spray/src/main/scala/kamon/spray/Spray.scala | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/kamon-spray/src/main/scala/kamon/spray/Spray.scala b/kamon-spray/src/main/scala/kamon/spray/Spray.scala index c1c81116..72b997d7 100644 --- a/kamon-spray/src/main/scala/kamon/spray/Spray.scala +++ b/kamon-spray/src/main/scala/kamon/spray/Spray.scala @@ -21,6 +21,7 @@ import akka.actor import kamon.Kamon import kamon.http.HttpServerMetrics import kamon.metric.Metrics +import spray.http.HttpHeaders.Host import spray.http.HttpRequest object Spray extends ExtensionId[SprayExtension] with ExtensionIdProvider { @@ -66,7 +67,14 @@ trait SprayNameGenerator { } class DefaultSprayNameGenerator extends SprayNameGenerator { - def generateRequestLevelApiSegmentName(request: HttpRequest): String = request.method.value + ": " + request.uri.path + def hostFromHeaders(request: HttpRequest): Option[String] = request.header[Host].map(_.host) + + def generateRequestLevelApiSegmentName(request: HttpRequest): String = { + val uriAddress = request.uri.authority.host.address + if (uriAddress.equals("")) hostFromHeaders(request).getOrElse("unknown-host") else uriAddress + } + + def generateHostLevelApiSegmentName(request: HttpRequest): String = hostFromHeaders(request).getOrElse("unknown-host") + def generateTraceName(request: HttpRequest): String = request.method.value + ": " + request.uri.path - def generateHostLevelApiSegmentName(request: HttpRequest): String = request.uri.authority.host.address } |