diff options
author | Ivan Topolnjak <ivantopo@gmail.com> | 2014-01-31 09:01:18 -0300 |
---|---|---|
committer | Ivan Topolnjak <ivantopo@gmail.com> | 2014-01-31 09:01:18 -0300 |
commit | 59c01d880379dfc48c6d82da13ef628a587a9bbb (patch) | |
tree | dd323caa93133a98da5f76be332dfdbf76280ea5 /kamon-spray/src/main/scala/kamon | |
parent | a15e17d2462105ad8b72054be58dc9e8f9dc64ed (diff) | |
download | Kamon-59c01d880379dfc48c6d82da13ef628a587a9bbb.tar.gz Kamon-59c01d880379dfc48c6d82da13ef628a587a9bbb.tar.bz2 Kamon-59c01d880379dfc48c6d82da13ef628a587a9bbb.zip |
remake of trace context and allow different tracing levels
Diffstat (limited to 'kamon-spray/src/main/scala/kamon')
-rw-r--r-- | kamon-spray/src/main/scala/kamon/spray/Spray.scala | 37 | ||||
-rw-r--r-- | kamon-spray/src/main/scala/kamon/spray/UowDirectives.scala | 5 |
2 files changed, 39 insertions, 3 deletions
diff --git a/kamon-spray/src/main/scala/kamon/spray/Spray.scala b/kamon-spray/src/main/scala/kamon/spray/Spray.scala new file mode 100644 index 00000000..4dc98d85 --- /dev/null +++ b/kamon-spray/src/main/scala/kamon/spray/Spray.scala @@ -0,0 +1,37 @@ +/* + * ========================================================================================= + * Copyright © 2013 the kamon project <http://kamon.io/> + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the + * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + * ========================================================================================= + */ + +package kamon.spray + +import akka.actor.{ ExtendedActorSystem, ExtensionIdProvider, ExtensionId } +import akka.actor +import kamon.Kamon +import spray.http.HttpRequest + +object Spray extends ExtensionId[SprayExtension] with ExtensionIdProvider { + def lookup(): ExtensionId[_ <: actor.Extension] = Spray + def createExtension(system: ExtendedActorSystem): SprayExtension = new SprayExtension(system) +} + +class SprayExtension(private val system: ExtendedActorSystem) extends Kamon.Extension { + private val config = system.settings.config.getConfig("kamon.spray") + + val includeTraceToken: Boolean = config.getBoolean("include-trace-token-header") + val traceTokenHeaderName: String = config.getString("trace-token-header-name") + + // Later we should expose a way for the user to customize this. + def assignHttpClientRequestName(request: HttpRequest): String = request.uri.authority.host.address +} diff --git a/kamon-spray/src/main/scala/kamon/spray/UowDirectives.scala b/kamon-spray/src/main/scala/kamon/spray/UowDirectives.scala index 78a5b336..56cc6d5e 100644 --- a/kamon-spray/src/main/scala/kamon/spray/UowDirectives.scala +++ b/kamon-spray/src/main/scala/kamon/spray/UowDirectives.scala @@ -20,7 +20,6 @@ import spray.routing._ import java.util.concurrent.atomic.AtomicLong import scala.util.Try import java.net.InetAddress -import kamon.trace.Trace import spray.http.HttpHeaders.RawHeader trait UowDirectives extends BasicDirectives { @@ -28,10 +27,10 @@ trait UowDirectives extends BasicDirectives { val uowHeader = request.headers.find(_.name == "X-UOW") val generatedUow = uowHeader.map(_.value).getOrElse(UowDirectives.newUow) - Trace.transformContext(_.copy(token = generatedUow)) + //Trace.transformContext(_.copy(token = generatedUow)) request } - def respondWithUow = mapHttpResponseHeaders(headers ⇒ Trace.context().map(ctx ⇒ RawHeader("X-UOW", ctx.token) :: headers).getOrElse(headers)) + //def respondWithUow = mapHttpResponseHeaders(headers ⇒ Trace.context().map(ctx ⇒ RawHeader("X-UOW", ctx.token) :: headers).getOrElse(headers)) } object UowDirectives { |