You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2022/06/09 20:34:08 UTC
[GitHub] [skywalking-java] ForestWang123 opened a new pull request, #194: Fix argument type name in postgresql plugin and add type name checking
ForestWang123 opened a new pull request, #194:
URL: https://github.com/apache/skywalking-java/pull/194
1. fix argument type name of Array in postgresql-8.x-plugin from java.lang.String[] to [Ljava.lang.String;
2. add type name checking in ArgumentTypeNameMatch and ReturnTypeNameMatch
3. highlight the type naming rule in docs/en/setup/service-agent/java-agent/Java-Plugin-Development-Guide.md
### Fix <argument type name of Array in postgresql-8.x-plugin>
- [x] Add a unit test to verify that the fix works.
- [x] Explain briefly why the bug exists and how to fix it.
- [x] If this pull request closes/resolves/fixes an existing issue, replace the issue number. Closes #<issue number>.
- [x] Update the [`CHANGES` log](https://github.com/apache/skywalking-java/blob/main/CHANGES.md).
--
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: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [skywalking-java] wu-sheng commented on a diff in pull request #194: Fix argument type name in postgresql plugin and add type name checking
Posted by GitBox <gi...@apache.org>.
wu-sheng commented on code in PR #194:
URL: https://github.com/apache/skywalking-java/pull/194#discussion_r894046104
##########
docs/en/setup/service-agent/java-agent/Java-Plugin-Development-Guide.md:
##########
@@ -297,7 +297,16 @@ public interface InstanceMethodsInterceptPoint {
}
```
You may also use `Matcher` to set the target methods. Return **true** in `isOverrideArgs`, if you want to change the argument
-ref in interceptor.
+ref in interceptor.
+Please refer to [bytebuddy](https://bytebuddy.net/#/) for details of defining `ElementMatcher`.
+
+In Skywalking, we provide 3 classes to facilitate `ElementMatcher` definition:
+* `AnnotationTypeNameMatch`: Depends on whether there are certain annotations in the target methods.
+* `ReturnTypeNameMatch`: Based on return type name (package name + `.` + class name) of the target methods.
+* `ArgumentTypeNameMatch`: Based on argument index and type name (package name + `.` + class name) of the target methods.
+
+**Attention**:
+* For `ReturnTypeNameMatch` and `ArgumentTypeNameMatch`, please use [Lxxx; (Java file format defined in [JVM Specification](https://docs.oracle.com/javase/specs/jvms/se8/html/)) to define an Array type. For example, you should write [Ljava.lang.String; for `java.lang.String[]`.
Review Comment:
```suggestion
* In case of using `ReturnTypeNameMatch` and `ArgumentTypeNameMatch`, use [Lxxx; (Java file format defined in [JVM Specification](https://docs.oracle.com/javase/specs/jvms/se8/html/)) to define an Array type. For example, you should write `[Ljava.lang.String;` for `java.lang.String[]`.
```
--
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: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [skywalking-java] ForestWang123 commented on a diff in pull request #194: Fix argument type name in postgresql plugin and add type name checking
Posted by GitBox <gi...@apache.org>.
ForestWang123 commented on code in PR #194:
URL: https://github.com/apache/skywalking-java/pull/194#discussion_r894453492
##########
apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/postgresql/define/PgStatementInstrumentation.java:
##########
@@ -43,12 +43,8 @@ public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
new InstanceMethodsInterceptPoint() {
@Override
public ElementMatcher<MethodDescription> getMethodsMatcher() {
- return named("execute").and(takesArgumentWithType(0, "java.lang.String"))
- .or(named("execute").and(takesArgumentWithType(0, "java.lang.String[]")))
Review Comment:
OK, There are some problems of my implementation here.
I have tightened the matching rule for execute and executeUpdate; delete the executeLargeUpdate methods which have not been implemented in PgStatement.
Please check, thank you
--
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: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [skywalking-java] wu-sheng merged pull request #194: Fix argument type name in postgresql plugin and add type name checking
Posted by GitBox <gi...@apache.org>.
wu-sheng merged PR #194:
URL: https://github.com/apache/skywalking-java/pull/194
--
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: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [skywalking-java] wu-sheng commented on a diff in pull request #194: Fix argument type name in postgresql plugin and add type name checking
Posted by GitBox <gi...@apache.org>.
wu-sheng commented on code in PR #194:
URL: https://github.com/apache/skywalking-java/pull/194#discussion_r894060347
##########
apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/postgresql/define/PgStatementInstrumentation.java:
##########
@@ -43,12 +43,8 @@ public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
new InstanceMethodsInterceptPoint() {
@Override
public ElementMatcher<MethodDescription> getMethodsMatcher() {
- return named("execute").and(takesArgumentWithType(0, "java.lang.String"))
- .or(named("execute").and(takesArgumentWithType(0, "java.lang.String[]")))
Review Comment:
Meanwhile `public int executeUpdate(String sql, String[] columnNames)` seems having a different execution path. Is this another bug? (should be `takesArgumentWithType(1...)?`
--
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: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [skywalking-java] wu-sheng commented on a diff in pull request #194: Fix argument type name in postgresql plugin and add type name checking
Posted by GitBox <gi...@apache.org>.
wu-sheng commented on code in PR #194:
URL: https://github.com/apache/skywalking-java/pull/194#discussion_r894045665
##########
docs/en/setup/service-agent/java-agent/Java-Plugin-Development-Guide.md:
##########
@@ -297,7 +297,16 @@ public interface InstanceMethodsInterceptPoint {
}
```
You may also use `Matcher` to set the target methods. Return **true** in `isOverrideArgs`, if you want to change the argument
-ref in interceptor.
+ref in interceptor.
+Please refer to [bytebuddy](https://bytebuddy.net/#/) for details of defining `ElementMatcher`.
+
+In Skywalking, we provide 3 classes to facilitate `ElementMatcher` definition:
+* `AnnotationTypeNameMatch`: Depends on whether there are certain annotations in the target methods.
+* `ReturnTypeNameMatch`: Based on return type name (package name + `.` + class name) of the target methods.
+* `ArgumentTypeNameMatch`: Based on argument index and type name (package name + `.` + class name) of the target methods.
Review Comment:
```suggestion
* `AnnotationTypeNameMatch`: Check on whether there is a certain annotation in the target method.
* `ReturnTypeNameMatch`: Check the return type name (package name + `.` + class name) of the target method.
* `ArgumentTypeNameMatch`: Check on the argument index and the type name (package name + `.` + class name) of the target method.
```
--
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: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [skywalking-java] wu-sheng commented on a diff in pull request #194: Fix argument type name in postgresql plugin and add type name checking
Posted by GitBox <gi...@apache.org>.
wu-sheng commented on code in PR #194:
URL: https://github.com/apache/skywalking-java/pull/194#discussion_r894043795
##########
apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/postgresql/define/PgStatementInstrumentation.java:
##########
@@ -43,12 +43,8 @@ public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
new InstanceMethodsInterceptPoint() {
@Override
public ElementMatcher<MethodDescription> getMethodsMatcher() {
- return named("execute").and(takesArgumentWithType(0, "java.lang.String"))
- .or(named("execute").and(takesArgumentWithType(0, "java.lang.String[]")))
Review Comment:
Is this removed on purpose?
--
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: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [skywalking-java] wu-sheng commented on a diff in pull request #194: Fix argument type name in postgresql plugin and add type name checking
Posted by GitBox <gi...@apache.org>.
wu-sheng commented on code in PR #194:
URL: https://github.com/apache/skywalking-java/pull/194#discussion_r894051502
##########
apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/postgresql/define/PgStatementInstrumentation.java:
##########
@@ -43,12 +43,8 @@ public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
new InstanceMethodsInterceptPoint() {
@Override
public ElementMatcher<MethodDescription> getMethodsMatcher() {
- return named("execute").and(takesArgumentWithType(0, "java.lang.String"))
- .or(named("execute").and(takesArgumentWithType(0, "java.lang.String[]")))
Review Comment:
I noticed in `org.postgresql.jdbc.PgStatement`, there is no `String[]` at index 0 for `execute` and `executeUpdate` method.
--
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: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [skywalking-java] wu-sheng commented on pull request #194: Fix argument type name in postgresql plugin and add type name checking
Posted by GitBox <gi...@apache.org>.
wu-sheng commented on PR #194:
URL: https://github.com/apache/skywalking-java/pull/194#issuecomment-1151726927
This PR is generally good, thanks for fixing quickly. Please polish based on review comments.
--
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: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org