HDFS-11583. Parent spans are not initialized to NullScope for every DFSPacket. Contributed by Masatake Iwasaki.

This commit is contained in:
Akira Ajisaka 2017-06-15 14:15:36 +09:00
parent 59fab4ea04
commit f36da00c1f
No known key found for this signature in database
GPG Key ID: C1EDBB9CA400FD50
3 changed files with 40 additions and 0 deletions

View File

@ -355,6 +355,9 @@ Release 2.7.4 - UNRELEASED
HDFS-11736. OIV tests should not write outside 'target' directory.
(Yiqun Lin via aajisaka)
HDFS-11583. Parent spans are not initialized to NullScope for every
DFSPacket. (Masatake Iwasaki via aajisaka)
Release 2.7.3 - 2016-08-25
INCOMPATIBLE CHANGES

View File

@ -674,6 +674,7 @@ public class DFSOutputStream extends FSOutputSummer
}
} finally {
scope.close();
scope = NullScope.INSTANCE;
}
}
closeInternal();
@ -945,6 +946,7 @@ public class DFSOutputStream extends FSOutputSummer
}
} finally {
scope.close();
scope = NullScope.INSTANCE;
}
}
}

View File

@ -68,6 +68,41 @@ public class TestTracing {
readWithTracing();
}
@Test
public void testTracingInDataStreamer() throws Exception {
DistributedFileSystem fs = cluster.getFileSystem();
FSDataOutputStream os = fs.create(new Path("/testTracingInDataStreamer"));
byte[] bytes = "foo-bar-baz".getBytes();
try (TraceScope ts = Trace.startSpan("top level", Sampler.ALWAYS)) {
os.write(bytes);
os.hflush();
}
assertSpanNamesFound(new String[]{ "writeTo" });
int spans1 = 0;
for (Span s : SetSpanReceiver.SetHolder.spans.values()) {
if (s.getDescription().equals("writeTo")) {
spans1++;
}
}
Assert.assertEquals(1, spans1);
os.write(bytes);
os.hflush();
os.close();
int spans2 = 0;
for (Span s : SetSpanReceiver.SetHolder.spans.values()) {
if (s.getDescription().equals("writeTo")) {
spans2++;
}
}
// If there are multiple "writeTo" spans,
// spans are started in DataStreamer even after "top level" span is closed.
Assert.assertEquals(spans1, spans2);
}
public void writeWithTracing() throws Exception {
long startTime = System.currentTimeMillis();
TraceScope ts = Trace.startSpan("testWriteTraceHooks", Sampler.ALWAYS);