diff options
author | falmarri <psychicsurgeon@gmail.com> | 2018-06-12 21:24:56 -0700 |
---|---|---|
committer | falmarri <psychicsurgeon@gmail.com> | 2018-06-13 00:32:29 -0700 |
commit | 49940f942bef432190108fe4c5e1efcb9cc14f14 (patch) | |
tree | 89f810383f4101ea8e2fbb906ac361d7a8cd6979 /kamon-core/src/main | |
parent | e711bb0170f0939f9054cea76da0ce09005ccef3 (diff) | |
download | Kamon-49940f942bef432190108fe4c5e1efcb9cc14f14.tar.gz Kamon-49940f942bef432190108fe4c5e1efcb9cc14f14.tar.bz2 Kamon-49940f942bef432190108fe4c5e1efcb9cc14f14.zip |
Allow access to local span operation name
Diffstat (limited to 'kamon-core/src/main')
-rw-r--r-- | kamon-core/src/main/scala/kamon/trace/Span.scala | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/kamon-core/src/main/scala/kamon/trace/Span.scala b/kamon-core/src/main/scala/kamon/trace/Span.scala index 9778373a..43391af7 100644 --- a/kamon-core/src/main/scala/kamon/trace/Span.scala +++ b/kamon-core/src/main/scala/kamon/trace/Span.scala @@ -60,6 +60,8 @@ sealed abstract class Span { def finish(at: Instant): Unit def finish(): Unit + + def operationName(): String } object Span { @@ -83,6 +85,7 @@ object Span { override def disableMetrics(): Span = this override def finish(): Unit = {} override def finish(at: Instant): Unit = {} + override def operationName(): String = "empty" } @@ -93,7 +96,7 @@ object Span { private var open: Boolean = true private val sampled: Boolean = spanContext.samplingDecision == SamplingDecision.Sample private var hasError: Boolean = false - private var operationName: String = initialOperationName + private var _operationName: String = initialOperationName private var spanTags: Map[String, Span.TagValue] = initialSpanTags private var marks: List[Mark] = Nil @@ -185,7 +188,7 @@ object Span { override def setOperationName(operationName: String): Span = synchronized { if(open) - this.operationName = operationName + this._operationName = operationName this } @@ -205,22 +208,23 @@ object Span { } private def toFinishedSpan(to: Instant): Span.FinishedSpan = - Span.FinishedSpan(spanContext, operationName, from, to, spanTags, marks) + Span.FinishedSpan(spanContext, _operationName, from, to, spanTags, marks) private def recordSpanMetrics(to: Instant): Unit = { val elapsedTime = Clock.nanosBetween(from, to) val isErrorText = if(hasError) TagValue.True.text else TagValue.False.text if(scopeSpanMetrics) - parent.foreach(parentSpan => customMetricTags = customMetricTags + ("parentOperation" -> parentSpan.asInstanceOf[Local].operationName)) + parent.foreach(parentSpan => customMetricTags = customMetricTags + ("parentOperation" -> parentSpan.asInstanceOf[Local]._operationName)) val metricTags = Map( - "operation" -> operationName, + "operation" -> _operationName, "error" -> isErrorText ) ++ customMetricTags Span.Metrics.ProcessingTime.refine(metricTags).record(elapsedTime) } + override def operationName(): String = _operationName } object Local { @@ -247,6 +251,7 @@ object Span { override def disableMetrics(): Span = this override def finish(): Unit = {} override def finish(at: Instant): Unit = {} + override def operationName(): String = "remote" } object Remote { @@ -289,4 +294,4 @@ object Span { tags: Map[String, Span.TagValue], marks: Seq[Span.Mark] ) -}
\ No newline at end of file +} |