本文整理汇总了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
}
}
开发者ID:edinhodzic,项目名称:kyriakos-lib-rest-spray,代码行数:53,代码来源:KamonRestHooks.scala
示例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()
}
开发者ID:kamon-io,项目名称:kamon-akka,代码行数:33,代码来源:EnvelopeInstrumentation.scala
注:本文中的kamon.trace.TraceContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论