diff options
author | Ivan Topolnjak <ivantopo@gmail.com> | 2018-02-13 11:36:49 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-13 11:36:49 +0100 |
commit | 26e8684b88c0c5abc4c6e0a1e5c59cd0be058186 (patch) | |
tree | 1d516e55ce35d81762e761f2b7d5e299e64019b2 /kamon-core/src/main/scala/kamon | |
parent | fa342db5ec6e80227d559ee5ac9d0b11b9f0b453 (diff) | |
parent | 5f748c1c74bb71ba4125644b2afec7d4e58bcb9f (diff) | |
download | Kamon-26e8684b88c0c5abc4c6e0a1e5c59cd0be058186.tar.gz Kamon-26e8684b88c0c5abc4c6e0a1e5c59cd0be058186.tar.bz2 Kamon-26e8684b88c0c5abc4c6e0a1e5c59cd0be058186.zip |
Merge pull request #516 from ivantopo/issue#513/tagMetric-not-working-on-unsampled-spans
apply metric tags on spans, even if the span is not sampled, fixes #513
Diffstat (limited to 'kamon-core/src/main/scala/kamon')
-rw-r--r-- | kamon-core/src/main/scala/kamon/trace/Span.scala | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/kamon-core/src/main/scala/kamon/trace/Span.scala b/kamon-core/src/main/scala/kamon/trace/Span.scala index 690efeb4..9778373a 100644 --- a/kamon-core/src/main/scala/kamon/trace/Span.scala +++ b/kamon-core/src/main/scala/kamon/trace/Span.scala @@ -123,11 +123,12 @@ object Span { } override def tagMetric(key: String, value: String): Span = synchronized { - if(sampled && open) { - spanTags = spanTags + (key -> TagValue.String(value)) - + if(open) { if(collectMetrics) customMetricTags = customMetricTags + (key -> value) + + if(sampled) + spanTags = spanTags + (key -> TagValue.String(value)) } this } @@ -142,23 +143,29 @@ object Span { } override def addError(error: String): Span = synchronized { - if(sampled && open) { + if(open) { hasError = true - spanTags = spanTags ++ Map( - "error" -> TagValue.True, - "error.object" -> TagValue.String(error) - ) + + if(sampled) { + spanTags = spanTags ++ Map( + "error" -> TagValue.True, + "error.object" -> TagValue.String(error) + ) + } } this } override def addError(error: String, throwable: Throwable): Span = synchronized { - if(sampled && open) { + if(open) { hasError = true - spanTags = spanTags ++ Map( - "error" -> TagValue.True, - "error.object" -> TagValue.String(throwable.getMessage()) - ) + + if(sampled) { + spanTags = spanTags ++ Map( + "error" -> TagValue.True, + "error.object" -> TagValue.String(throwable.getMessage()) + ) + } } this } |