编写版本:v3.5.6
适用版本:所有版本

插件添加

  1. 将optional-plugins/apm-customize-enhance-plugin-x.x.x.jar复制到plugin/apm-customize-enhance-plugin-x.x.x.jar
  2. 如将optional-plugins/apm-customize-enhance-plugin-8.9.0.jar复制到plugin/apm-customize-enhance-plugin-8.9.0.jar

插件监控配置

  1. 配置agent.config文件增加plugin.customize.enhance_file=/absolute/path/to/customize_enhance.xml

  2. 编写customize_enhance.xml内容

    示例:监控数据模版保存表单数据
    接口:/iform/business/v3/data/template/saveFormData/vo

     <enhanced>
       <class class_name="com.ak.iform.form.provider.DataTemplateProvider">
         <method method="saveFormDataVo(com.ak.iform.form.vo.DataTemplateRequestVo)" operation_name="IFORM/DataTemplateProvider/saveFormDataVo(DataTemplateRequestVo)" static="false"/>
       </class>
       <class class_name="com.ak.iform.form.form.repository.impl.FormDefRepositoryImpl">
         <method method="getByFormKey(java.lang.String)" operation_name="IFORM/FormDefRepositoryImpl/getByFormKey(String)" static="false"/>
       </class>
       <class class_name="com.ak.iform.base.bo.repository.impl.BoDefRepositoryImpl">
         <method method="get(java.lang.String)" operation_name="IFORM/BoDefRepositoryImpl/get(String)" static="false"/>
         <method method="getByCode(java.lang.String,int.class)" operation_name="IFORM/BoDefRepositoryImpl/getByCode(String,int)" static="false"/>
       </class>
       <class class_name="com.ak.iform.base.bo.mongodb.MongodbBoInstanceService">
         <method method="getDataObject(java.lang.String,java.lang.String,java.lang.Integer)" operation_name="IFORM/MongodbBoInstanceService/getDataObject(String,String,Integer)" static="false"/>
         <method method="save(com.ak.iform.base.bo.model.DataObjectModel)" operation_name="IFORM/MongodbBoInstanceService/save(DataObjectModel)" static="false"/>
         <method method="save(com.ak.iform.base.bo.model.DataObjectModel,boolean.class)" operation_name="IFORM/MongodbBoInstanceService/save(DataObjectModel,boolean)" static="false"/>
         <method method="getTransaction()" operation_name="IFORM/MongodbBoInstanceService/getTransaction()" static="false"/>
       </class>
       <class class_name="com.ak.iform.base.bo.util.FormValidateUtil">
         <method method="isOpenConflict(java.lang.String)" operation_name="IFORM/FormValidateUtil/isOpenConflict(String)" static="true"/>
         <method method="isOpenFormValidate(com.ak.iform.base.bo.model.DataObjectModel)" operation_name="IFORM/FormValidateUtil/isOpenFormValidate(DataObjectModel)" static="true"/>
       </class>
       <class class_name="com.ak.iform.base.bo.validator.DataObjectValidator">
         <method method="validate(com.ak.iform.base.bo.model.DataObjectModel,org.springframework.validation.Errors)" operation_name="IFORM/DataObjectValidator/validate(DataObjectModel,Errors)" static="false"/>
       </class>
       <class class_name="com.ak.iform.base.bo.strategy.impl.SaveBusinessObjectDataStrategy">
         <method method="before(com.ak.iform.base.bo.model.DataObjectModel,[Ljava.lang.Object;)" operation_name="IFORM/SaveBusinessObjectDataStrategy/before(DataObjectModel,[Ljava.lang.Object;)" static="false"/>
         <method method="after(com.ak.iform.base.bo.model.DataObjectModel,[Ljava.lang.Object;)" operation_name="IFORM/SaveBusinessObjectDataStrategy/after(DataObjectModel,[Ljava.lang.Object;)" static="false"/>
       </class>
       <class class_name="com.ak.iform.base.bo.helper.MongodbDataHelper">
         <method method="executeSubPk(com.ak.iform.base.bo.model.DataObjectModel)" operation_name="IFORM/MongodbDataHelper/executeSubPk(DataObjectModel)" static="false"/>
         <method method="removeUnpersistenceAttrData(com.ak.iform.base.bo.model.DataObjectModel)" operation_name="IFORM/MongodbDataHelper/removeUnpersistenceAttrData(DataObjectModel)" static="false"/>
         <method method="fillPublicAttrData(com.ak.iform.base.bo.model.DataObjectModel,java.util.Map)" operation_name="IFORM/MongodbDataHelper/fillPublicAttrData(DataObjectModel,Map)" static="false"/>
       </class>
       <class class_name="com.ak.iform.base.bo.strategy.impl.JacksonFormDataExecutorStrategy">
         <method method="execute(com.ak.iform.base.bo.model.DataObjectModel)" operation_name="IFORM/JacksonFormDataExecutorStrategy/execute(DataObjectModel)" static="false"/>
       </class>
       <class class_name="com.ak.iform.form.mq.utils.QueueUtil">
         <method method="pushToMqRelative(com.ak.iform.form.mq.producer.RabbitDataSyncQueueProducer,com.ak.iform.form.mq.handler.BusinessDataSyncHandler,com.ak.iform.base.bo.persistence.entity.BoDefPo,com.ak.iform.base.bo.model.DataObjectModel)" operation_name="IFORM/QueueUtil/pushToMqRelative(RabbitDataSyncQueueProducer,BusinessDataSyncHandler,BoDefPo,DataObjectModel)" static="true"/>
       </class>
       <class class_name="com.ak.iform.base.bo.repository.impl.BoInstanceRepositoryImpl">
         <method method="getDataObjectModelByBoDef(com.ak.iform.base.bo.persistence.entity.BoDefPo,java.lang.Object)" operation_name="IFORM/BoInstanceRepositoryImpl/getDataObjectModelByBoDef(BoDefPo,Object)" static="false"/>
       </class>
       <class class_name="com.ak.iform.form.form.helper.JacksonFormDefDataBuilder">
         <method method="buildFormOptionData(com.ak.iform.form.form.persistence.entity.FormDefPo,java.lang.String)" operation_name="IFORM/JacksonFormDefDataBuilder/buildFormOptionData(FormDefPo,String)" static="true"/>
       </class>
       <class class_name="com.ak.iform.base.bo.helper.BoInstaneHelper">
         <method method="createSaveBoData2TableSql(java.lang.String,com.ak.iform.base.bo.model.DataObjectModel)" operation_name="IFORM/BoInstaneHelper/createSaveBoData2TableSql(String,DataObjectModel)" static="false"/>
       </class>
       <class class_name="com.ak.iform.base.bo.service.impl.DefaultBoInstanceService">
         <method method="saveBoData2Table(com.ak.iform.base.bo.model.DataObjectModel,java.util.List,java.util.Map)" operation_name="IFORM/DefaultBoInstanceService/saveBoData2Table(DataObjectModel,List,Map)" static="false"/>
         <method method="isUpdateLogOpenning()" operation_name="IFORM/DefaultBoInstanceService/isUpdateLogOpenning()" static="false"/>
       </class>
     </enhanced>
  3. 操作名定义

  • 使用operation_name,则重写操作名。
  • 不使用operation_name,则默认生成。
  1. 参数写法说明
原始类型 写法
String str0 java.lang.String
int count int.class
Map map java.util.Map
List list java.util.List
String[] os [Ljava.lang.String;
int[] os [I
boolean[] os [Z
Object[] os [Ljava.lang.Object;
其余类型 使用System.out.println输出句柄获取@符合前的部分即可

详见: https://skywalking.apache.org/docs/skywalking-java/v8.9.0/en/setup/service-agent/java-agent/customize-enhance-trace/
参考: https://blog.csdn.net/lt326030434/article/details/107149565/

作者:hugh  创建时间:2024-06-20 11:30
最后编辑:hugh  更新时间:2024-11-15 11:25