Plug in function : Customize and enhance any method in any class , So as to realize the monitoring of any method in any class .
Use
for instance , There is a class , The definition is as follows :
1 |
public class TestService1 { |
that , Want to monitor this method , You can do the following :
Move jar package
take optional-plugins/apm-customize-enhance-plugin-6.5.0.jar
Move to plugins
Catalog
Write enhancement rules
Create a file , It's called, for example customize_enhance.xml
, The contents are as follows :
1 |
<?xml version="1.0" encoding="UTF-8"?> |
Rule description :
To configure | explain |
---|---|
class_name | Class to be enhanced |
method | Class interceptor method |
operation_name | If configured , It will be used instead of the default operation_name |
operation_name_suffix | It means that operation_name Add dynamic data after |
static | Whether the method is static |
tag | Will be in local span Add a tag.key The value of must be in XML The node represents . |
log | Will be in local span Add a log.key The value of must be in XML The node represents . |
arg[x] | Represents the input parameter value . such as args[0] Represents the first parameter . |
.[x] | When the object being parsed is Array or List, You can use this expression to get the corresponding index On the object . |
.[‘key’] | When the object being parsed is Map, You can use this expression to get map Of key. |
One thing in particular to note method Writing :
Basic types :
Basic types .class
, for example :int.class
Non basic type :
Fully qualified name of the class
, for example :java.lang.String
Array : You can write an array and print it , You'll know the format , for example :
1
2
3
4
5
6
7public static void main(String[] args) {
String[] s = new String[]{};
System.out.println(s);
int [] x = new int []{};
System.out.println(x);
}result :
1
2[Ljava.lang.String;@1b0375b3
[I@2f7c7260therefore , about String An array of types , I can write this as
[Ljava.lang.String;
; about int An array of types , It's written as[I
.
To configure
agent.config Add configuration in :
1 |
plugin.customize.enhance_file=customize_enhance.xml The absolute path of |
Bonus ^_^
apm-trace-ignore-plugin
- effect : Filter out what you want to be ignored endpoint
- Instructions :http://www.itmuch.com/books/skywalking/setup/service-agent/java-agent/agent-optional-plugins/trace-ignore-plugin.html