From 6e9a582eb1ab040f532fbe95694f5272cda34188 Mon Sep 17 00:00:00 2001 From: Colin Patrick Mccabe Date: Fri, 11 Mar 2016 12:26:40 -0800 Subject: [PATCH] HDFS-9942. Add an HTrace span when refreshing the groups for a username (cmccabe) --- .../java/org/apache/hadoop/security/Groups.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/Groups.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/Groups.java index 9fd39b09aba..11d8f2a58c5 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/Groups.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/Groups.java @@ -27,6 +27,8 @@ import java.util.Set; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; +import org.apache.htrace.core.TraceScope; +import org.apache.htrace.core.Tracer; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Ticker; import com.google.common.cache.CacheBuilder; @@ -217,7 +219,20 @@ public class Groups { */ @Override public List load(String user) throws Exception { - List groups = fetchGroupList(user); + TraceScope scope = null; + Tracer tracer = Tracer.curThreadTracer(); + if (tracer != null) { + scope = tracer.newScope("Groups#fetchGroupList"); + scope.addKVAnnotation("user", user); + } + List groups = null; + try { + groups = fetchGroupList(user); + } finally { + if (scope != null) { + scope.close(); + } + } if (groups.isEmpty()) { if (isNegativeCacheEnabled()) {