天天看点

Pinpoint关闭指定PluginPinpoint关闭指定Plugin

Pinpoint关闭指定Plugin

一、背景

代码中需要对某些文件进行转存,并且允许通过url下载文件为空,因此对这段代码进行了try catch处理,仅打印warn日志。但上线后发现Pinpoint中依然出现大量的相关Error:
  • Pinpoint关闭指定PluginPinpoint关闭指定Plugin
通过查看Pinpoint源码发现,是其默认提供的

JdkHttpPlugin

插件自动对Http相关方法进行了增强,并捕获了异常进行上报:
  • Pinpoint关闭指定PluginPinpoint关闭指定Plugin
因此我考虑关闭此Plugin,避免出现Error上报

二、具体方法

1、resources目录下新增一个

pinpoint.config

文件:

  • Pinpoint关闭指定PluginPinpoint关闭指定Plugin

2、此配置文件中配置需要关闭的Plugin:

  • profiler.plugin.disable=XxxPlugin

    (多个用逗号分隔)
  • Pinpoint关闭指定PluginPinpoint关闭指定Plugin

这样即可关闭指定Plugin,应用再次启动时,这里配置的Plugin便不会再加载并对相应的类进行增强拦截。

三、相关源码说明

关于Pinpoint启动加载过程可以看我的另一篇文章:初探Pinpoint Agent 启动源码

Pinpoint Agent在启动时会创建一个

ProfilerConfig

对象,用于存储配置信息,具体实现类就是

DefaultProfilerConfig.java

,其中包含

PLUGIN_DISABLE

属性用于加载禁用plugin的配置

Pinpoint关闭指定PluginPinpoint关闭指定Plugin

配置信息在此方法中加载:

DefaultProfilerConfig.readPropertyValues()

加载完成并构建Config对象后,在

DefaultProfilerPluginContextLoader.setupPlugin()

中,通过config中配置的disabledPlugins过滤不需要的plugin:

Pinpoint关闭指定PluginPinpoint关闭指定Plugin