youjie23 commented on code in PR #728:
URL: https://github.com/apache/skywalking-java/pull/728#discussion_r1857282931
##########
apm-sniffer/apm-sdk-plugin/mongodb-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/mongodb/v3/support/MongoSpanHelper.java:
##########
@@ -72,9 +65,54 @@ private static void extractTagsFromNamespace(AbstractSpan
span, MongoNamespace n
}
}
- private static MongoNamespace tryToGetMongoNamespace(Object operation)
throws IllegalAccessException, NoSuchFieldException {
- Field namespaceField =
operation.getClass().getDeclaredField("namespace");
- Field.setAccessible(new Field[]{namespaceField}, true);
- return (MongoNamespace) namespaceField.get(operation);
+ private static MongoNamespace tryToGetMongoNamespace(Object operation,
Field[] declaredFields) throws IllegalAccessException {
+ Field namespaceField = null;
+ Field wrappedField = null;
+ Field databaseField = null;
+ Field collectionField = null;
+ for (Field field : declaredFields) {
+ if ("namespace".equals(field.getName())) {
+ namespaceField = field;
+ Field.setAccessible(new Field[]{field}, true);
+ }
+ if ("wrapped".equals(field.getName())) {
+ wrappedField = field;
+ Field.setAccessible(new Field[]{field}, true);
+ }
+ if ("databaseName".equals(field.getName())) {
+ databaseField = field;
+ Field.setAccessible(new Field[]{field}, true);
+ }
+ if ("collectionName".equals(field.getName())) {
+ collectionField = field;
+ Field.setAccessible(new Field[]{field}, true);
+ }
Review Comment:
Thank you for the review. I have made the changes using
SkyWalkingDynamicField based on your feedback.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]