Add a flag to determine whether to bind data
This commit is contained in:
parent
e8084e548d
commit
e42bf6e014
|
|
@ -23,6 +23,13 @@ public class Config {
|
|||
* Zero and negative number are illegal.
|
||||
*/
|
||||
public static int SAMPLING_CYCLE = 1;
|
||||
|
||||
/**
|
||||
* Set Mongodb plugin whether to bind params
|
||||
* False=Not bound
|
||||
* True=Binding
|
||||
*/
|
||||
public static boolean MONGODB_BINDPARAM = false;
|
||||
}
|
||||
|
||||
public static class Collector {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import java.util.List;
|
|||
|
||||
import org.bson.BsonDocument;
|
||||
|
||||
import com.a.eye.skywalking.api.conf.Config;
|
||||
import com.a.eye.skywalking.api.context.ContextManager;
|
||||
import com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
import com.a.eye.skywalking.api.plugin.interceptor.enhance.InstanceMethodInvokeContext;
|
||||
|
|
@ -65,13 +66,18 @@ public class MongoDBMethodInterceptor implements InstanceMethodsAroundIntercepto
|
|||
public void beforeMethod(final EnhancedClassInstanceContext context,
|
||||
final InstanceMethodInvokeContext interceptorContext, final MethodInterceptResult result) {
|
||||
Object[] arguments = interceptorContext.allArguments();
|
||||
OperationInfo operationInfo = this.getReadOperationInfo(arguments[0]);
|
||||
Span span = ContextManager.createSpan(METHOD + operationInfo.getMethodName());
|
||||
Span span = null;
|
||||
if (Config.Agent.MONGODB_BINDPARAM) {
|
||||
OperationInfo operationInfo = this.getReadOperationInfo(arguments[0]);
|
||||
span = ContextManager.createSpan(METHOD + operationInfo.getMethodName());
|
||||
Tags.DB_STATEMENT.set(span, operationInfo.getMethodName() + " " + operationInfo.getFilter());
|
||||
} else {
|
||||
span = ContextManager.createSpan(METHOD + arguments[0].getClass().getSimpleName());
|
||||
}
|
||||
Tags.COMPONENT.set(span, MONGODB_COMPONENT);
|
||||
Tags.DB_TYPE.set(span, MONGODB_COMPONENT);
|
||||
Tags.SPAN_KIND.set(span, Tags.SPAN_KIND_CLIENT);
|
||||
Tags.SPAN_LAYER.asDB(span);
|
||||
Tags.DB_STATEMENT.set(span, operationInfo.getMethodName() + " " + operationInfo.getFilter());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Reference in New Issue