diff --git a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/ScmConfigKeys.java b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/ScmConfigKeys.java index 3b45b89dc8..b097321507 100644 --- a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/ScmConfigKeys.java +++ b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/ScmConfigKeys.java @@ -372,6 +372,10 @@ public final class ScmConfigKeys { "ozone.scm.network.topology.schema.file"; public static final String OZONE_SCM_NETWORK_TOPOLOGY_SCHEMA_FILE_DEFAULT = "network-topology-default.xml"; + + public static final String HDDS_TRACING_ENABLED = "hdds.tracing.enabled"; + public static final boolean HDDS_TRACING_ENABLED_DEFAULT = true; + /** * Never constructed. */ diff --git a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/tracing/TracingUtil.java b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/tracing/TracingUtil.java index 4f285f708c..c274625dda 100644 --- a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/tracing/TracingUtil.java +++ b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/tracing/TracingUtil.java @@ -27,6 +27,8 @@ import io.opentracing.Tracer; import io.opentracing.util.GlobalTracer; +import org.apache.hadoop.hdds.scm.ScmConfigKeys; + /** * Utility class to collect all the tracing helper methods. */ @@ -112,11 +114,19 @@ public static Scope importAndCreateScope(String name, String encodedParent) { * @param delegate the original class instance * @param interfce the interface which should be implemented by the proxy * @param the type of the interface + * @param conf configuration * * @return A new interface which implements interfce but delegate all the * calls to the delegate and also enables tracing. */ - public static T createProxy(T delegate, Class interfce) { + public static T createProxy(T delegate, Class interfce, + org.apache.hadoop.conf.Configuration conf) { + boolean isTracingEnabled = conf.getBoolean( + ScmConfigKeys.HDDS_TRACING_ENABLED, + ScmConfigKeys.HDDS_TRACING_ENABLED_DEFAULT); + if (!isTracingEnabled) { + return delegate; + } Class aClass = delegate.getClass(); return (T) Proxy.newProxyInstance(aClass.getClassLoader(), new Class[] {interfce}, diff --git a/hadoop-hdds/common/src/main/resources/ozone-default.xml b/hadoop-hdds/common/src/main/resources/ozone-default.xml index 9fd4ef3b70..cbd249a0a0 100644 --- a/hadoop-hdds/common/src/main/resources/ozone-default.xml +++ b/hadoop-hdds/common/src/main/resources/ozone-default.xml @@ -2377,4 +2377,12 @@ to datanodes. After this timeout the command will be retried. + + hdds.tracing.enabled + true + OZONE, HDDS + + If enabled, tracing information is sent to tracing server. + + diff --git a/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/SCMCLI.java b/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/SCMCLI.java index 4e2b3841a1..c722f2b6e4 100644 --- a/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/SCMCLI.java +++ b/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/SCMCLI.java @@ -143,7 +143,7 @@ public ScmClient createScmClient() scmAddress, UserGroupInformation.getCurrentUser(), ozoneConf, NetUtils.getDefaultSocketFactory(ozoneConf), Client.getRpcTimeout(ozoneConf))), - StorageContainerLocationProtocol.class); + StorageContainerLocationProtocol.class, ozoneConf); return new ContainerOperationClient( client, new XceiverClientManager(ozoneConf)); } diff --git a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/ObjectStore.java b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/ObjectStore.java index 5ac44ed25d..c5e3210d44 100644 --- a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/ObjectStore.java +++ b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/ObjectStore.java @@ -66,7 +66,7 @@ public class ObjectStore { * @param proxy ClientProtocol proxy. */ public ObjectStore(Configuration conf, ClientProtocol proxy) { - this.proxy = TracingUtil.createProxy(proxy, ClientProtocol.class); + this.proxy = TracingUtil.createProxy(proxy, ClientProtocol.class, conf); this.listCacheSize = HddsClientUtils.getListCacheSize(conf); } diff --git a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/rpc/RpcClient.java b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/rpc/RpcClient.java index 6b60f96de1..e81cca76e1 100644 --- a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/rpc/RpcClient.java +++ b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/rpc/RpcClient.java @@ -156,7 +156,8 @@ public RpcClient(Configuration conf) throws IOException { scmAddress, ugi, conf, NetUtils.getDefaultSocketFactory(conf), Client.getRpcTimeout(conf))); this.storageContainerLocationClient = - TracingUtil.createProxy(client, StorageContainerLocationProtocol.class); + TracingUtil.createProxy(client, StorageContainerLocationProtocol.class, + conf); this.xceiverClientManager = new XceiverClientManager(conf); int configuredChunkSize = (int) conf diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocolPB/OzoneManagerProtocolClientSideTranslatorPB.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocolPB/OzoneManagerProtocolClientSideTranslatorPB.java index 968ff397f5..7e3b33f5c7 100644 --- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocolPB/OzoneManagerProtocolClientSideTranslatorPB.java +++ b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocolPB/OzoneManagerProtocolClientSideTranslatorPB.java @@ -189,7 +189,7 @@ public OzoneManagerProtocolClientSideTranslatorPB(OzoneConfiguration conf, this.rpcProxy = TracingUtil.createProxy( createRetryProxy(omFailoverProxyProvider, maxRetries, maxFailovers, sleepBase, sleepMax), - OzoneManagerProtocolPB.class); + OzoneManagerProtocolPB.class, conf); this.clientID = clientId; } diff --git a/hadoop-ozone/objectstore-service/src/main/java/org/apache/hadoop/hdfs/server/datanode/ObjectStoreHandler.java b/hadoop-ozone/objectstore-service/src/main/java/org/apache/hadoop/hdfs/server/datanode/ObjectStoreHandler.java index 48722400ba..a2ee6d908e 100644 --- a/hadoop-ozone/objectstore-service/src/main/java/org/apache/hadoop/hdfs/server/datanode/ObjectStoreHandler.java +++ b/hadoop-ozone/objectstore-service/src/main/java/org/apache/hadoop/hdfs/server/datanode/ObjectStoreHandler.java @@ -104,7 +104,7 @@ public ObjectStoreHandler(Configuration conf) throws IOException { scmAddress, UserGroupInformation.getCurrentUser(), conf, NetUtils.getDefaultSocketFactory(conf), Client.getRpcTimeout(conf))), - StorageContainerLocationProtocol.class); + StorageContainerLocationProtocol.class, conf); InetSocketAddress scmBlockAddress = getScmAddressForBlockClients(conf); @@ -115,7 +115,7 @@ public ObjectStoreHandler(Configuration conf) throws IOException { scmBlockAddress, UserGroupInformation.getCurrentUser(), conf, NetUtils.getDefaultSocketFactory(conf), Client.getRpcTimeout(conf))), - ScmBlockLocationProtocol.class); + ScmBlockLocationProtocol.class, conf); RPC.setProtocolEngine(conf, OzoneManagerProtocolPB.class, ProtobufRpcEngine.class); @@ -129,12 +129,12 @@ public ObjectStoreHandler(Configuration conf) throws IOException { omAddress, UserGroupInformation.getCurrentUser(), conf, NetUtils.getDefaultSocketFactory(conf), Client.getRpcTimeout(conf)), clientId.toString()), - OzoneManagerProtocol.class); + OzoneManagerProtocol.class, conf); storageHandler = new DistributedStorageHandler( new OzoneConfiguration(conf), TracingUtil.createProxy(storageContainerLocationClient, - StorageContainerLocationProtocol.class), + StorageContainerLocationProtocol.class, conf), this.ozoneManagerClient); ApplicationAdapter aa = new ApplicationAdapter(new ObjectStoreApplication()); diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java index c8fdef429d..549e6bd9e4 100644 --- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java +++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java @@ -760,7 +760,8 @@ private static ScmBlockLocationProtocol getScmBlockClient( NetUtils.getDefaultSocketFactory(conf), Client.getRpcTimeout(conf))); return TracingUtil - .createProxy(scmBlockLocationClient, ScmBlockLocationProtocol.class); + .createProxy(scmBlockLocationClient, ScmBlockLocationProtocol.class, + conf); } /** @@ -807,7 +808,7 @@ private static StorageContainerLocationProtocol getScmContainerClient( scmAddr, UserGroupInformation.getCurrentUser(), conf, NetUtils.getDefaultSocketFactory(conf), Client.getRpcTimeout(conf))), - StorageContainerLocationProtocol.class); + StorageContainerLocationProtocol.class, conf); return scmContainerClient; }