diff options
author | Ivan Topolnjak <ivantopo@gmail.com> | 2014-12-03 02:10:46 +0100 |
---|---|---|
committer | Ivan Topolnjak <ivantopo@gmail.com> | 2014-12-03 02:10:46 +0100 |
commit | 594c7a1729789eae7037918cde7287bdc4111b70 (patch) | |
tree | 1c54caaee4d218640c93d23dcdf6a8167cb2b4e0 /kamon-core/src/main/scala/kamon/trace/TraceRecorder.scala | |
parent | f511e1c25aa683e0d436ef9b65d3e841b4a83732 (diff) | |
download | Kamon-594c7a1729789eae7037918cde7287bdc4111b70.tar.gz Kamon-594c7a1729789eae7037918cde7287bdc4111b70.tar.bz2 Kamon-594c7a1729789eae7037918cde7287bdc4111b70.zip |
= core: first simple approach to providing traces and a subscription mechanism.
Diffstat (limited to 'kamon-core/src/main/scala/kamon/trace/TraceRecorder.scala')
-rw-r--r-- | kamon-core/src/main/scala/kamon/trace/TraceRecorder.scala | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/kamon-core/src/main/scala/kamon/trace/TraceRecorder.scala b/kamon-core/src/main/scala/kamon/trace/TraceRecorder.scala index 8da187cb..572d94e5 100644 --- a/kamon-core/src/main/scala/kamon/trace/TraceRecorder.scala +++ b/kamon-core/src/main/scala/kamon/trace/TraceRecorder.scala @@ -16,6 +16,8 @@ package kamon.trace +import kamon.Kamon + import scala.language.experimental.macros import java.util.concurrent.atomic.AtomicLong import kamon.macros.InlineTraceContextMacro @@ -34,27 +36,20 @@ object TraceRecorder { def newToken: String = hostnamePrefix + "-" + String.valueOf(tokenCounter.incrementAndGet()) - private def newTraceContext(name: String, token: Option[String], system: ActorSystem): TraceContext = { - new DefaultTraceContext( - name, - token.getOrElse(newToken), - izOpen = true, - LevelOfDetail.OnlyMetrics, - TraceContextOrigin.Local, - nanoTimeztamp = System.nanoTime, - system) - } + private def newTraceContext(name: String, token: Option[String], system: ActorSystem): TraceContext = + Kamon(Trace)(system).newTraceContext(name, token.getOrElse(newToken), true, TraceContextOrigin.Local, System.nanoTime(), system) def joinRemoteTraceContext(traceName: String, traceToken: String, startMilliTime: Long, isOpen: Boolean, system: ActorSystem): TraceContext = { val equivalentNanotime = System.nanoTime() - ((System.currentTimeMillis() - startMilliTime) * 1000000) - new DefaultTraceContext( + /*new MetricsOnlyContext( traceName, traceToken, isOpen, - LevelOfDetail.OnlyMetrics, + LevelOfDetail.MetricsOnly, TraceContextOrigin.Remote, equivalentNanotime, - system) + system)*/ + ??? } def setContext(context: TraceContext): Unit = traceContextStorage.set(context) @@ -81,8 +76,8 @@ object TraceRecorder { } def withTraceContextAndSystem[T](thunk: (TraceContext, ActorSystem) ⇒ T): Option[T] = currentContext match { - case ctx: DefaultTraceContext ⇒ Some(thunk(ctx, ctx.system)) - case EmptyTraceContext ⇒ None + case ctx: MetricsOnlyContext ⇒ Some(thunk(ctx, ctx.system)) + case EmptyTraceContext ⇒ None } def withInlineTraceContextReplacement[T](traceCtx: TraceContext)(thunk: ⇒ T): T = macro InlineTraceContextMacro.withInlineTraceContextImpl[T, TraceContext] |