Better witness class for mongo3.8.x (#5524)
* modify witness class * modify witness class & add test case * replace DB_STATEMENT to DB_BIND_VARIABLES & remove executeMethod prefix * fix ci Co-authored-by: 吴晟 Wu Sheng <wu.sheng@foxmail.com>
This commit is contained in:
parent
075cb981a9
commit
c3edd3dad0
|
|
@ -35,7 +35,7 @@ import org.apache.skywalking.apm.agent.core.plugin.match.NameMatch;
|
|||
*/
|
||||
public class MongoDBOperationExecutorInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
|
||||
|
||||
private static final String WITNESS_CLASS = "com.mongodb.client.ClientSession";
|
||||
private static final String WITNESS_CLASS = "com.mongodb.operation.AggregateOperationImpl";
|
||||
|
||||
private static final String ENHANCE_CLASS = "com.mongodb.client.internal.MongoClientDelegate$DelegateOperationExecutor";
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ public class MongoSpanHelper {
|
|||
SpanLayer.asDB(span);
|
||||
|
||||
if (MongoPluginConfig.Plugin.MongoDB.TRACE_PARAM) {
|
||||
Tags.DB_STATEMENT.set(span, executeMethod + " " + MongoOperationHelper.getTraceParam(operation));
|
||||
Tags.DB_BIND_VARIABLES.set(span, MongoOperationHelper.getTraceParam(operation));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ public class MongoDBInterceptorTest {
|
|||
assertThat(span.getOperationName(), is("MongoDB/FindOperation"));
|
||||
assertThat(SpanHelper.getComponentId(span), is(42));
|
||||
List<TagValuePair> tags = SpanHelper.getTags(span);
|
||||
assertThat(tags.get(1).getValue(), is("FindOperation {\"name\": \"by\"}"));
|
||||
assertThat(tags.get(1).getValue(), is("{\"name\": \"by\"}"));
|
||||
assertThat(tags.get(0).getValue(), is("MongoDB"));
|
||||
assertThat(span.isExit(), is(true));
|
||||
assertThat(SpanHelper.getLayer(span), CoreMatchers.is(SpanLayer.DB));
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ public class MongoDBOperationExecutorInterceptorTest {
|
|||
assertThat(span.getOperationName(), is("MongoDB/FindOperation"));
|
||||
assertThat(SpanHelper.getComponentId(span), is(42));
|
||||
List<TagValuePair> tags = SpanHelper.getTags(span);
|
||||
assertThat(tags.get(1).getValue(), is("FindOperation {\"name\": \"by\"}"));
|
||||
assertThat(tags.get(1).getValue(), is("{\"name\": \"by\"}"));
|
||||
assertThat(tags.get(0).getValue(), is("MongoDB"));
|
||||
assertThat(span.isExit(), is(true));
|
||||
assertThat(SpanHelper.getLayer(span), CoreMatchers.is(SpanLayer.DB));
|
||||
|
|
|
|||
|
|
@ -18,4 +18,4 @@
|
|||
|
||||
home="$(cd "$(dirname $0)"; pwd)"
|
||||
|
||||
java -jar ${agent_opts} ${home}/../libs/mongodb-3.x-scenario.jar &
|
||||
java -jar -Dskywalking.plugin.mongodb.trace_param=true ${agent_opts} ${home}/../libs/mongodb-3.x-scenario.jar &
|
||||
|
|
@ -32,6 +32,7 @@ segmentItems:
|
|||
peer: mongodb-server:27017
|
||||
tags:
|
||||
- {key: db.type, value: MongoDB}
|
||||
- {key: db.bind_vars, value: not null}
|
||||
skipAnalysis: 'false'
|
||||
- operationName: MongoDB/MixedBulkWriteOperation
|
||||
operationId: 0
|
||||
|
|
@ -46,6 +47,7 @@ segmentItems:
|
|||
peer: mongodb-server:27017
|
||||
tags:
|
||||
- {key: db.type, value: MongoDB}
|
||||
- {key: db.bind_vars, value: not null}
|
||||
skipAnalysis: 'false'
|
||||
- operationName: MongoDB/FindOperation
|
||||
operationId: 0
|
||||
|
|
@ -60,6 +62,7 @@ segmentItems:
|
|||
peer: mongodb-server:27017
|
||||
tags:
|
||||
- {key: db.type, value: MongoDB}
|
||||
- {key: db.bind_vars, value: not null}
|
||||
skipAnalysis: 'false'
|
||||
- operationName: MongoDB/MixedBulkWriteOperation
|
||||
operationId: 0
|
||||
|
|
@ -74,6 +77,7 @@ segmentItems:
|
|||
peer: mongodb-server:27017
|
||||
tags:
|
||||
- {key: db.type, value: MongoDB}
|
||||
- {key: db.bind_vars, value: not null}
|
||||
skipAnalysis: 'false'
|
||||
- operationName: MongoDB/FindOperation
|
||||
operationId: 0
|
||||
|
|
@ -88,6 +92,7 @@ segmentItems:
|
|||
peer: mongodb-server:27017
|
||||
tags:
|
||||
- {key: db.type, value: MongoDB}
|
||||
- {key: db.bind_vars, value: not null}
|
||||
skipAnalysis: 'false'
|
||||
- operationName: MongoDB/MixedBulkWriteOperation
|
||||
operationId: 0
|
||||
|
|
@ -102,6 +107,7 @@ segmentItems:
|
|||
peer: mongodb-server:27017
|
||||
tags:
|
||||
- {key: db.type, value: MongoDB}
|
||||
- {key: db.bind_vars, value: not null}
|
||||
skipAnalysis: 'false'
|
||||
- operationName: MongoDB/DropDatabaseOperation
|
||||
operationId: 0
|
||||
|
|
@ -116,6 +122,7 @@ segmentItems:
|
|||
peer: mongodb-server:27017
|
||||
tags:
|
||||
- {key: db.type, value: MongoDB}
|
||||
- {key: db.bind_vars, value: not null}
|
||||
skipAnalysis: 'false'
|
||||
- operationName: /mongodb-case/case/mongodb
|
||||
operationId: 0
|
||||
|
|
|
|||
Loading…
Reference in New Issue