本文整理汇总了Scala中kamon.trace.TraceContext类的典型用法代码示例。如果您正苦于以下问题:Scala TraceContext类的具体用法?Scala TraceContext怎么用?Scala TraceContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TraceContext类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: postHook
//设置package包名称以及导入依赖的类
package io.kyriakos.library.rest.hooks
import com.typesafe.scalalogging.LazyLogging
import io.kyriakos.library.utils.ManifestUtils
import kamon.Kamon
import kamon.trace.TraceContext
import spray.httpx.marshalling.{ToResponseMarshallable => Response}
import scala.language.postfixOps
trait KamonRestHooks[T] extends RestHooks[T] with LazyLogging {
Kamon.start()
// TODO no implicit manifest?
private val domain: String = ManifestUtils.simpleName(manifest)
override protected def postHook(postFunction: => Response): Response =
kamonTrace(s"$domain-post-trace") {
postFunction
}
override protected def getHook(getFunction: => Response): Response =
kamonTrace(s"$domain-get-trace") {
getFunction
}
override protected def putHook(putFunction: => Response): Response =
kamonTrace(s"$domain-put-trace") {
putFunction
}
override protected def patchHook(putFunction: => Response): Response =
kamonTrace(s"$domain-patch-trace") {
putFunction
}
override protected def deleteHook(deleteFunction: => Response): Response =
kamonTrace(s"$domain-delete-trace") {
deleteFunction
}
private def kamonTrace(name: String)(function: => Response): Response = {
logger debug s"starting kamon trace [$name]"
val traceContext: TraceContext = Kamon.tracer.newContext(name)
val response: Response = function
traceContext finish()
response
}
}
示例2: EnvelopeContext
//设置package包名称以及导入依赖的类
package akka.kamon.instrumentation
import kamon.trace.{ EmptyTraceContext, TraceContext }
import kamon.util.RelativeNanoTimestamp
import org.aspectj.lang.annotation.{ DeclareMixin, Aspect }
case class EnvelopeContext(nanoTime: RelativeNanoTimestamp, context: TraceContext)
object EnvelopeContext {
val Empty = EnvelopeContext(RelativeNanoTimestamp.zero, EmptyTraceContext)
}
trait InstrumentedEnvelope extends Serializable {
def envelopeContext(): EnvelopeContext
def setEnvelopeContext(envelopeContext: EnvelopeContext): Unit
}
object InstrumentedEnvelope {
def apply(): InstrumentedEnvelope = new InstrumentedEnvelope {
var envelopeContext: EnvelopeContext = _
def setEnvelopeContext(envelopeContext: EnvelopeContext): Unit =
this.envelopeContext = envelopeContext
}
}
@Aspect
class EnvelopeContextIntoEnvelopeMixin {
@DeclareMixin("akka.dispatch.Envelope")
def mixinInstrumentationToEnvelope: InstrumentedEnvelope = InstrumentedEnvelope()
}