in apm-sniffer/apm-sdk-plugin/hbase-1.x-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hbase/HTableInterceptor.java [52:93]
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
MethodInterceptResult result) throws Throwable {
boolean canTracingServer = false;
List<OperationWithAttributes> operations = null;
OperationWithAttributes operation = null;
if (allArguments != null && allArguments.length > 0) {
if (allArguments[0] instanceof List) {
List list = (List) allArguments[0];
if (!CollectionUtil.isEmpty(list) && list.get(0) instanceof OperationWithAttributes) {
operations = list;
canTracingServer = true;
}
} else if (allArguments[0] instanceof OperationWithAttributes) {
operation = (OperationWithAttributes) allArguments[0];
canTracingServer = true;
}
}
AbstractSpan span;
if (canTracingServer) {
ContextCarrier contextCarrier = new ContextCarrier();
span = ContextManager.createExitSpan(PREFIX_OPERATION_NAME + method.getName(),
contextCarrier, (String) objInst.getSkyWalkingDynamicField());
CarrierItem next = contextCarrier.items();
while (next.hasNext()) {
next = next.next();
if (operation != null) {
operation.setAttribute(next.getHeadKey(), next.getHeadValue().getBytes(StandardCharsets.UTF_8));
} else {
for (OperationWithAttributes o : operations) {
o.setAttribute(next.getHeadKey(), next.getHeadValue().getBytes(StandardCharsets.UTF_8));
}
}
}
} else {
span = ContextManager.createExitSpan(PREFIX_OPERATION_NAME + method.getName(),
(String) objInst.getSkyWalkingDynamicField());
}
span.setComponent(ComponentsDefine.HBASE);
Tags.DB_TYPE.set(span, HBASE_DB_TYPE);
Tags.DB_INSTANCE.set(span, ((HTable) objInst).getName().getNameAsString());
SpanLayer.asDB(span);
}