diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 56950740e17..6bb0c0894e4 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -186,6 +186,9 @@ Release 2.8.0 - UNRELEASED HADOOP-12195. Add annotation to package-info.java file to workaround MCOMPILER-205. (wang) + HADOOP-12201. Add tracing to FileSystem#createFileSystem and Globber#glob + (cmccabe) + OPTIMIZATIONS HADOOP-11785. Reduce the number of listStatus operation in distcp diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java index 800d13268a5..3a589decfa6 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java @@ -67,6 +67,9 @@ import org.apache.hadoop.util.Progressable; import org.apache.hadoop.util.ReflectionUtils; import org.apache.hadoop.util.ShutdownHookManager; import org.apache.hadoop.util.StringUtils; +import org.apache.htrace.Span; +import org.apache.htrace.Trace; +import org.apache.htrace.TraceScope; import com.google.common.annotations.VisibleForTesting; @@ -2676,10 +2679,19 @@ public abstract class FileSystem extends Configured implements Closeable { private static FileSystem createFileSystem(URI uri, Configuration conf ) throws IOException { - Class clazz = getFileSystemClass(uri.getScheme(), conf); - FileSystem fs = (FileSystem)ReflectionUtils.newInstance(clazz, conf); - fs.initialize(uri, conf); - return fs; + TraceScope scope = Trace.startSpan("FileSystem#createFileSystem"); + Span span = scope.getSpan(); + if (span != null) { + span.addKVAnnotation("scheme", uri.getScheme()); + } + try { + Class clazz = getFileSystemClass(uri.getScheme(), conf); + FileSystem fs = (FileSystem)ReflectionUtils.newInstance(clazz, conf); + fs.initialize(uri, conf); + return fs; + } finally { + scope.close(); + } } /** Caching FileSystem objects */ diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Globber.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Globber.java index 9cb810fc5cf..48639b4e5e3 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Globber.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Globber.java @@ -28,6 +28,10 @@ import org.apache.commons.logging.Log; import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceStability; +import org.apache.htrace.Span; +import org.apache.htrace.Trace; +import org.apache.htrace.TraceScope; + @InterfaceAudience.Private @InterfaceStability.Unstable class Globber { @@ -136,6 +140,19 @@ class Globber { } public FileStatus[] glob() throws IOException { + TraceScope scope = Trace.startSpan("Globber#glob"); + Span span = scope.getSpan(); + if (span != null) { + span.addKVAnnotation("pattern", pathPattern.toUri().getPath()); + } + try { + return doGlob(); + } finally { + scope.close(); + } + } + + private FileStatus[] doGlob() throws IOException { // First we get the scheme and authority of the pattern that was passed // in. String scheme = schemeFromPath(pathPattern);