Search in sources :

Example 1 with ProfilerPlugin

use of com.navercorp.pinpoint.bootstrap.plugin.ProfilerPlugin in project pinpoint by naver.

the class ProfilerPluginLoader method load.

public List<SetupResult> load(URL[] pluginJars) {
    List<SetupResult> pluginContexts = new ArrayList<SetupResult>(pluginJars.length);
    for (URL pluginJar : pluginJars) {
        final JarFile pluginJarFile = createJarFile(pluginJar);
        final List<String> pluginPackageList = getPluginPackage(pluginJarFile);
        final ClassNameFilter pluginFilterChain = createPluginFilterChain(pluginPackageList);
        final List<ProfilerPlugin> original = PluginLoader.load(ProfilerPlugin.class, new URL[] { pluginJar });
        List<ProfilerPlugin> plugins = filterDisablePlugin(original);
        for (ProfilerPlugin plugin : plugins) {
            if (logger.isInfoEnabled()) {
                logger.info("{} Plugin {}:{}", plugin.getClass(), PluginConfig.PINPOINT_PLUGIN_PACKAGE, pluginPackageList);
            }
            logger.info("Loading plugin:{} pluginPackage:{}", plugin.getClass().getName(), plugin);
            PluginConfig pluginConfig = new PluginConfig(pluginJar, pluginFilterChain);
            final ClassInjector classInjector = new JarProfilerPluginClassInjector(pluginConfig, instrumentEngine);
            final SetupResult result = pluginSetup.setupPlugin(plugin, classInjector);
            pluginContexts.add(result);
        }
    }
    return pluginContexts;
}
Also used : ArrayList(java.util.ArrayList) ProfilerPlugin(com.navercorp.pinpoint.bootstrap.plugin.ProfilerPlugin) JarFile(java.util.jar.JarFile) URL(java.net.URL) JarProfilerPluginClassInjector(com.navercorp.pinpoint.profiler.instrument.classloading.JarProfilerPluginClassInjector) ClassInjector(com.navercorp.pinpoint.profiler.instrument.classloading.ClassInjector) JarProfilerPluginClassInjector(com.navercorp.pinpoint.profiler.instrument.classloading.JarProfilerPluginClassInjector)

Example 2 with ProfilerPlugin

use of com.navercorp.pinpoint.bootstrap.plugin.ProfilerPlugin in project pinpoint by naver.

the class MockPluginContextLoadResult method load.

private List<SetupResult> load() {
    List<ProfilerPlugin> plugins = PluginLoader.load(ProfilerPlugin.class, ClassLoader.getSystemClassLoader());
    List<SetupResult> pluginContexts = new ArrayList<SetupResult>();
    ClassInjector classInjector = new TestProfilerPluginClassLoader();
    PluginSetup pluginSetup = new MockPluginSetup(profilerConfig, instrumentEngine, dynamicTransformTrigger);
    for (ProfilerPlugin plugin : plugins) {
        SetupResult context = pluginSetup.setupPlugin(plugin, classInjector);
        pluginContexts.add(context);
    }
    return pluginContexts;
}
Also used : SetupResult(com.navercorp.pinpoint.profiler.plugin.SetupResult) PluginSetup(com.navercorp.pinpoint.profiler.plugin.PluginSetup) ArrayList(java.util.ArrayList) ProfilerPlugin(com.navercorp.pinpoint.bootstrap.plugin.ProfilerPlugin) ClassInjector(com.navercorp.pinpoint.profiler.instrument.classloading.ClassInjector)

Example 3 with ProfilerPlugin

use of com.navercorp.pinpoint.bootstrap.plugin.ProfilerPlugin in project pinpoint by naver.

the class ProfilerPluginLoader method filterDisablePlugin.

private List<ProfilerPlugin> filterDisablePlugin(List<ProfilerPlugin> plugins) {
    List<String> disabled = profilerConfig.getDisabledPlugins();
    List<ProfilerPlugin> result = new ArrayList<ProfilerPlugin>();
    for (ProfilerPlugin plugin : plugins) {
        if (disabled.contains(plugin.getClass().getName())) {
            logger.info("Skip disabled plugin: {}", plugin.getClass().getName());
            continue;
        }
        result.add(plugin);
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) ProfilerPlugin(com.navercorp.pinpoint.bootstrap.plugin.ProfilerPlugin)

Example 4 with ProfilerPlugin

use of com.navercorp.pinpoint.bootstrap.plugin.ProfilerPlugin in project pinpoint by naver.

the class JarProfilerPluginClassInjectorTest method testInjectClass.

@Test
public void testInjectClass() throws Exception {
    final URL sampleJar = getSampleJar("org.slf4j.impl.Log4jLoggerAdapter");
    final ClassLoader contextTypeMatchClassLoader = createContextTypeMatchClassLoader(new URL[] { sampleJar });
    final ProfilerPlugin profilerPlugin = Mockito.mock(ProfilerPlugin.class);
    final PluginPackageFilter pluginPackageFilter = new PluginPackageFilter(Arrays.asList(LOG4_IMPL));
    PluginConfig pluginConfig = new PluginConfig(sampleJar, pluginPackageFilter);
    logger.debug("pluginConfig:{}", pluginConfig);
    PlainClassLoaderHandler injector = new PlainClassLoaderHandler(pluginConfig);
    final Class<?> loggerClass = injector.injectClass(contextTypeMatchClassLoader, logger.getClass().getName());
    logger.debug("ClassLoader{}", loggerClass.getClassLoader());
    Assert.assertEquals("check className", loggerClass.getName(), "org.slf4j.impl.Log4jLoggerAdapter");
    Assert.assertEquals("check ClassLoader", loggerClass.getClassLoader().getClass().getName(), CONTEXT_TYPE_MATCH_CLASS_LOADER);
}
Also used : PluginConfig(com.navercorp.pinpoint.profiler.plugin.PluginConfig) PinpointURLClassLoader(com.navercorp.pinpoint.bootstrap.PinpointURLClassLoader) ProfilerPlugin(com.navercorp.pinpoint.bootstrap.plugin.ProfilerPlugin) PluginPackageFilter(com.navercorp.pinpoint.profiler.plugin.PluginPackageFilter) URL(java.net.URL) Test(org.junit.Test)

Aggregations

ProfilerPlugin (com.navercorp.pinpoint.bootstrap.plugin.ProfilerPlugin)4 ArrayList (java.util.ArrayList)3 ClassInjector (com.navercorp.pinpoint.profiler.instrument.classloading.ClassInjector)2 URL (java.net.URL)2 PinpointURLClassLoader (com.navercorp.pinpoint.bootstrap.PinpointURLClassLoader)1 JarProfilerPluginClassInjector (com.navercorp.pinpoint.profiler.instrument.classloading.JarProfilerPluginClassInjector)1 PluginConfig (com.navercorp.pinpoint.profiler.plugin.PluginConfig)1 PluginPackageFilter (com.navercorp.pinpoint.profiler.plugin.PluginPackageFilter)1 PluginSetup (com.navercorp.pinpoint.profiler.plugin.PluginSetup)1 SetupResult (com.navercorp.pinpoint.profiler.plugin.SetupResult)1 JarFile (java.util.jar.JarFile)1 Test (org.junit.Test)1