作者:Eddy  历史版本:1  最后编辑:Eddy  更新时间:2024-11-15 09:05

编写版本: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内容

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

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