HDDS-1153. Make tracing instrumentation configurable

Closes #673
This commit is contained in:
Kitti Nanasi 2019-04-02 13:47:18 +02:00 committed by Márton Elek
parent d31c86892e
commit aeb43dfba3
No known key found for this signature in database
GPG Key ID: D51EA8F00EE79B28
9 changed files with 35 additions and 11 deletions

View File

@ -372,6 +372,10 @@ public final class ScmConfigKeys {
"ozone.scm.network.topology.schema.file"; "ozone.scm.network.topology.schema.file";
public static final String OZONE_SCM_NETWORK_TOPOLOGY_SCHEMA_FILE_DEFAULT = public static final String OZONE_SCM_NETWORK_TOPOLOGY_SCHEMA_FILE_DEFAULT =
"network-topology-default.xml"; "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. * Never constructed.
*/ */

View File

@ -27,6 +27,8 @@
import io.opentracing.Tracer; import io.opentracing.Tracer;
import io.opentracing.util.GlobalTracer; import io.opentracing.util.GlobalTracer;
import org.apache.hadoop.hdds.scm.ScmConfigKeys;
/** /**
* Utility class to collect all the tracing helper methods. * 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 delegate the original class instance
* @param interfce the interface which should be implemented by the proxy * @param interfce the interface which should be implemented by the proxy
* @param <T> the type of the interface * @param <T> the type of the interface
* @param conf configuration
* *
* @return A new interface which implements interfce but delegate all the * @return A new interface which implements interfce but delegate all the
* calls to the delegate and also enables tracing. * calls to the delegate and also enables tracing.
*/ */
public static <T> T createProxy(T delegate, Class<T> interfce) { public static <T> T createProxy(T delegate, Class<T> 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(); Class<?> aClass = delegate.getClass();
return (T) Proxy.newProxyInstance(aClass.getClassLoader(), return (T) Proxy.newProxyInstance(aClass.getClassLoader(),
new Class<?>[] {interfce}, new Class<?>[] {interfce},

View File

@ -2377,4 +2377,12 @@
to datanodes. After this timeout the command will be retried. to datanodes. After this timeout the command will be retried.
</description> </description>
</property> </property>
<property>
<name>hdds.tracing.enabled</name>
<value>true</value>
<tag>OZONE, HDDS</tag>
<description>
If enabled, tracing information is sent to tracing server.
</description>
</property>
</configuration> </configuration>

View File

@ -143,7 +143,7 @@ public ScmClient createScmClient()
scmAddress, UserGroupInformation.getCurrentUser(), ozoneConf, scmAddress, UserGroupInformation.getCurrentUser(), ozoneConf,
NetUtils.getDefaultSocketFactory(ozoneConf), NetUtils.getDefaultSocketFactory(ozoneConf),
Client.getRpcTimeout(ozoneConf))), Client.getRpcTimeout(ozoneConf))),
StorageContainerLocationProtocol.class); StorageContainerLocationProtocol.class, ozoneConf);
return new ContainerOperationClient( return new ContainerOperationClient(
client, new XceiverClientManager(ozoneConf)); client, new XceiverClientManager(ozoneConf));
} }

View File

@ -66,7 +66,7 @@ public class ObjectStore {
* @param proxy ClientProtocol proxy. * @param proxy ClientProtocol proxy.
*/ */
public ObjectStore(Configuration conf, 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); this.listCacheSize = HddsClientUtils.getListCacheSize(conf);
} }

View File

@ -156,7 +156,8 @@ public RpcClient(Configuration conf) throws IOException {
scmAddress, ugi, conf, NetUtils.getDefaultSocketFactory(conf), scmAddress, ugi, conf, NetUtils.getDefaultSocketFactory(conf),
Client.getRpcTimeout(conf))); Client.getRpcTimeout(conf)));
this.storageContainerLocationClient = this.storageContainerLocationClient =
TracingUtil.createProxy(client, StorageContainerLocationProtocol.class); TracingUtil.createProxy(client, StorageContainerLocationProtocol.class,
conf);
this.xceiverClientManager = new XceiverClientManager(conf); this.xceiverClientManager = new XceiverClientManager(conf);
int configuredChunkSize = (int) conf int configuredChunkSize = (int) conf

View File

@ -189,7 +189,7 @@ public OzoneManagerProtocolClientSideTranslatorPB(OzoneConfiguration conf,
this.rpcProxy = TracingUtil.createProxy( this.rpcProxy = TracingUtil.createProxy(
createRetryProxy(omFailoverProxyProvider, maxRetries, maxFailovers, createRetryProxy(omFailoverProxyProvider, maxRetries, maxFailovers,
sleepBase, sleepMax), sleepBase, sleepMax),
OzoneManagerProtocolPB.class); OzoneManagerProtocolPB.class, conf);
this.clientID = clientId; this.clientID = clientId;
} }

View File

@ -104,7 +104,7 @@ public ObjectStoreHandler(Configuration conf) throws IOException {
scmAddress, UserGroupInformation.getCurrentUser(), conf, scmAddress, UserGroupInformation.getCurrentUser(), conf,
NetUtils.getDefaultSocketFactory(conf), NetUtils.getDefaultSocketFactory(conf),
Client.getRpcTimeout(conf))), Client.getRpcTimeout(conf))),
StorageContainerLocationProtocol.class); StorageContainerLocationProtocol.class, conf);
InetSocketAddress scmBlockAddress = InetSocketAddress scmBlockAddress =
getScmAddressForBlockClients(conf); getScmAddressForBlockClients(conf);
@ -115,7 +115,7 @@ public ObjectStoreHandler(Configuration conf) throws IOException {
scmBlockAddress, UserGroupInformation.getCurrentUser(), scmBlockAddress, UserGroupInformation.getCurrentUser(),
conf, NetUtils.getDefaultSocketFactory(conf), conf, NetUtils.getDefaultSocketFactory(conf),
Client.getRpcTimeout(conf))), Client.getRpcTimeout(conf))),
ScmBlockLocationProtocol.class); ScmBlockLocationProtocol.class, conf);
RPC.setProtocolEngine(conf, OzoneManagerProtocolPB.class, RPC.setProtocolEngine(conf, OzoneManagerProtocolPB.class,
ProtobufRpcEngine.class); ProtobufRpcEngine.class);
@ -129,12 +129,12 @@ public ObjectStoreHandler(Configuration conf) throws IOException {
omAddress, UserGroupInformation.getCurrentUser(), conf, omAddress, UserGroupInformation.getCurrentUser(), conf,
NetUtils.getDefaultSocketFactory(conf), NetUtils.getDefaultSocketFactory(conf),
Client.getRpcTimeout(conf)), clientId.toString()), Client.getRpcTimeout(conf)), clientId.toString()),
OzoneManagerProtocol.class); OzoneManagerProtocol.class, conf);
storageHandler = new DistributedStorageHandler( storageHandler = new DistributedStorageHandler(
new OzoneConfiguration(conf), new OzoneConfiguration(conf),
TracingUtil.createProxy(storageContainerLocationClient, TracingUtil.createProxy(storageContainerLocationClient,
StorageContainerLocationProtocol.class), StorageContainerLocationProtocol.class, conf),
this.ozoneManagerClient); this.ozoneManagerClient);
ApplicationAdapter aa = ApplicationAdapter aa =
new ApplicationAdapter(new ObjectStoreApplication()); new ApplicationAdapter(new ObjectStoreApplication());

View File

@ -760,7 +760,8 @@ private static ScmBlockLocationProtocol getScmBlockClient(
NetUtils.getDefaultSocketFactory(conf), NetUtils.getDefaultSocketFactory(conf),
Client.getRpcTimeout(conf))); Client.getRpcTimeout(conf)));
return TracingUtil return TracingUtil
.createProxy(scmBlockLocationClient, ScmBlockLocationProtocol.class); .createProxy(scmBlockLocationClient, ScmBlockLocationProtocol.class,
conf);
} }
/** /**
@ -807,7 +808,7 @@ private static StorageContainerLocationProtocol getScmContainerClient(
scmAddr, UserGroupInformation.getCurrentUser(), conf, scmAddr, UserGroupInformation.getCurrentUser(), conf,
NetUtils.getDefaultSocketFactory(conf), NetUtils.getDefaultSocketFactory(conf),
Client.getRpcTimeout(conf))), Client.getRpcTimeout(conf))),
StorageContainerLocationProtocol.class); StorageContainerLocationProtocol.class, conf);
return scmContainerClient; return scmContainerClient;
} }