diff options
Diffstat (limited to 'kamon-core/src/main/scala')
-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 8149be74..63cecadc 100644 --- a/kamon-core/src/main/scala/kamon/trace/Span.scala +++ b/kamon-core/src/main/scala/kamon/trace/Span.scala @@ -153,14 +153,19 @@ class Span(spanContext: SpanContext, initialOperationName: String, initialTags: val elapsedTime = endTimestampMicros - startTimestampMicros val metricTags = Map("operation" -> operationName) ++ additionalMetricTags - val latencyHistogram = Span.Metrics.SpanProcessingTimeMetric.refine(metricTags) - latencyHistogram.record(elapsedTime) + val isError = tags.get("error").exists { + errorTag => errorTag != null && errorTag.equals(Span.BooleanTagTrueValue) + } - tags.get("error").foreach { errorTag => - if(errorTag != null && errorTag.equals(Span.BooleanTagTrueValue)) { - Span.Metrics.SpanErrorCount.refine(metricTags).increment() - } + val refinedTags = if(isError) { + Span.Metrics.SpanErrorCount.refine(metricTags).increment() + metricTags + ("error" -> Span.BooleanTagTrueValue) + } else { + metricTags } + + val latencyHistogram = Span.Metrics.SpanProcessingTimeMetric.refine(refinedTags) + latencyHistogram.record(elapsedTime) } } |