From f1a7ca91af05206b3c47573689331a1fafec16de Mon Sep 17 00:00:00 2001 From: Douglas Chimento Date: Sun, 4 Aug 2019 00:52:01 +0300 Subject: [PATCH] Add public method isFinished() on JaegerSpan (#634) * Add public method isFinished() on JaegerSpan Signed-off-by: Doug Chimento * Adding sync block around isFinished for JaegerSpan Signed-off-by: Doug Chimento --- .../src/main/java/io/jaegertracing/internal/JaegerSpan.java | 6 ++++++ .../test/java/io/jaegertracing/internal/JaegerSpanTest.java | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/jaeger-core/src/main/java/io/jaegertracing/internal/JaegerSpan.java b/jaeger-core/src/main/java/io/jaegertracing/internal/JaegerSpan.java index f53d5a7ea..0d6246889 100644 --- a/jaeger-core/src/main/java/io/jaegertracing/internal/JaegerSpan.java +++ b/jaeger-core/src/main/java/io/jaegertracing/internal/JaegerSpan.java @@ -75,6 +75,12 @@ public long getStart() { return startTimeMicroseconds; } + public boolean isFinished() { + synchronized (this) { + return finished; + } + } + public long getDuration() { synchronized (this) { return durationMicroseconds; diff --git a/jaeger-core/src/test/java/io/jaegertracing/internal/JaegerSpanTest.java b/jaeger-core/src/test/java/io/jaegertracing/internal/JaegerSpanTest.java index acb4f9f8d..893c5d67f 100644 --- a/jaeger-core/src/test/java/io/jaegertracing/internal/JaegerSpanTest.java +++ b/jaeger-core/src/test/java/io/jaegertracing/internal/JaegerSpanTest.java @@ -158,6 +158,12 @@ public void testSetNumberTag() { assertEquals(expected, jaegerSpan.getTags().get(key)); } + @Test + public void testFinished() { + jaegerSpan.finish(); + assertTrue(jaegerSpan.isFinished()); + } + @Test public void testSetTag() { jaegerSpan.setTag(new StringTag("stringTag"), "stringTagValue")