diff options
Diffstat (limited to 'kamon-core/src/main/scala')
-rw-r--r-- | kamon-core/src/main/scala/kamon/trace/Span.scala | 17 | ||||
-rw-r--r-- | kamon-core/src/main/scala/kamon/trace/SpanCodec.scala | 6 |
2 files changed, 14 insertions, 9 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 +} diff --git a/kamon-core/src/main/scala/kamon/trace/SpanCodec.scala b/kamon-core/src/main/scala/kamon/trace/SpanCodec.scala index 093257c0..14b28d54 100644 --- a/kamon-core/src/main/scala/kamon/trace/SpanCodec.scala +++ b/kamon-core/src/main/scala/kamon/trace/SpanCodec.scala @@ -137,8 +137,8 @@ object SpanCodec { val spanContext = SpanContext( traceID = identityProvider.traceIdGenerator().from(colferSpan.traceID), - spanID = identityProvider.traceIdGenerator().from(colferSpan.spanID), - parentID = identityProvider.traceIdGenerator().from(colferSpan.parentID), + spanID = identityProvider.spanIdGenerator().from(colferSpan.spanID), + parentID = identityProvider.spanIdGenerator().from(colferSpan.parentID), samplingDecision = byteToSamplingDecision(colferSpan.samplingDecision) ) @@ -165,4 +165,4 @@ object SpanCodec { override def initialValue(): Array[Byte] = Array.ofDim[Byte](256) } } -}
\ No newline at end of file +} |