diff options
author | Ivan Topolnjak <ivantopo@gmail.com> | 2014-11-09 17:14:37 +0100 |
---|---|---|
committer | Ivan Topolnjak <ivantopo@gmail.com> | 2014-11-09 18:01:45 +0100 |
commit | ef21f8d0ade1015f71f1d289c8d041e2b525d824 (patch) | |
tree | c45cbb88dfbd8fbf5c35f205401926636fc80045 /kamon-spray/src/main/scala | |
parent | a736b7c2a946f9bd270dae07ecc079f307633482 (diff) | |
download | Kamon-ef21f8d0ade1015f71f1d289c8d041e2b525d824.tar.gz Kamon-ef21f8d0ade1015f71f1d289c8d041e2b525d824.tar.bz2 Kamon-ef21f8d0ade1015f71f1d289c8d041e2b525d824.zip |
! spray: correcly provide http-client segment names based on the request host.
Diffstat (limited to 'kamon-spray/src/main/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 } |