diff options
author | mladens <mladens42@gmail.com> | 2017-07-12 12:05:56 +0200 |
---|---|---|
committer | mladens <mladens42@gmail.com> | 2017-07-12 12:05:56 +0200 |
commit | 09af20cca6243400e0b922113d896e1ddc46382c (patch) | |
tree | 9883e3aad7ca456a8a247bb22ece726c60fdd140 /kamon-core/src/main | |
parent | 52c4503b6aea2309feeb550b7db2e5fa627dedc8 (diff) | |
download | Kamon-09af20cca6243400e0b922113d896e1ddc46382c.tar.gz Kamon-09af20cca6243400e0b922113d896e1ddc46382c.tar.bz2 Kamon-09af20cca6243400e0b922113d896e1ddc46382c.zip |
Separate span metrics and counts for spans finished with an error
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 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) } } |