Search in sources :

Example 21 with WeavePackageConfig

use of com.newrelic.weave.weavepackage.WeavePackageConfig in project newrelic-java-agent by newrelic.

the class ClassWeaverService method createWeavePackageConfig.

private WeavePackageConfig createWeavePackageConfig(JarInputStream jarStream, String source, Instrumentation instrumentation, WeavePackageType type, AgentConfig agentConfig) throws Exception {
    AgentPreprocessors preprocessors = new AgentPreprocessors(agentConfig, tracedWeaveInstrumentationDetails);
    AgentPostprocessors postprocessors = new AgentPostprocessors();
    WeavePackageConfig result = WeavePackageConfig.builder().source(source).jarInputStream(jarStream).weavePreprocessor(preprocessors).weavePostprocessor(postprocessors).errorHandleClassNode(LogAndReturnOriginal.ERROR_HANDLER_NODE).extensionClassTemplate(EXTENSION_TEMPLATE).build();
    preprocessors.setInstrumentationTitle(result.getName());
    if (result.getVendorId() != null) {
        // Set the type to "FIELD" for FIT modules. Otherwise this will already be set to INTERNAL or CUSTOM
        type = WeavePackageType.FIELD;
    }
    postprocessors.setWeavePackageType(type);
    return result;
}
Also used : WeavePackageConfig(com.newrelic.weave.weavepackage.WeavePackageConfig) AgentPreprocessors(com.newrelic.agent.instrumentation.weaver.preprocessors.AgentPreprocessors) AgentPostprocessors(com.newrelic.agent.instrumentation.weaver.preprocessors.AgentPostprocessors)

Example 22 with WeavePackageConfig

use of com.newrelic.weave.weavepackage.WeavePackageConfig in project newrelic-java-agent by newrelic.

the class WeavePackageAnalyzer method run.

@Override
public void run() {
    WeavePackageConfig weaveConfig;
    try {
        weaveConfig = WeavePackageConfig.builder().url(file.toURI().toURL()).build();
    } catch (Exception e) {
        logger.log(Level.FINEST, e, "{0} failed to build weave config for file");
        return;
    }
    JarData jarData = getWeaveJar(file, weaveConfig);
    logger.log(Level.FINEST, "{0} adding analyzed jar from weave package: {1}", file, jarData);
    analyzedJars.accept(jarData);
}
Also used : WeavePackageConfig(com.newrelic.weave.weavepackage.WeavePackageConfig)

Aggregations

WeavePackageConfig (com.newrelic.weave.weavepackage.WeavePackageConfig)22 Test (org.junit.Test)10 WeavePackage (com.newrelic.weave.weavepackage.WeavePackage)9 HashMap (java.util.HashMap)9 ArrayList (java.util.ArrayList)7 IOException (java.io.IOException)4 ClassTransformerConfig (com.newrelic.agent.config.ClassTransformerConfig)3 URL (java.net.URL)3 JarInputStream (java.util.jar.JarInputStream)3 AgentConfig (com.newrelic.agent.config.AgentConfig)2 WeaveViolation (com.newrelic.weave.violation.WeaveViolation)2 CachedWeavePackage (com.newrelic.weave.weavepackage.CachedWeavePackage)2 File (java.io.File)2 HashSet (java.util.HashSet)2 AgentClassLoaderBaseInstrumentation (com.newrelic.agent.instrumentation.builtin.AgentClassLoaderBaseInstrumentation)1 AgentClassLoaderInstrumentation (com.newrelic.agent.instrumentation.builtin.AgentClassLoaderInstrumentation)1 ClassLoaderPackageAccessInstrumentation (com.newrelic.agent.instrumentation.builtin.ClassLoaderPackageAccessInstrumentation)1 ClassMatchVisitorFactory (com.newrelic.agent.instrumentation.context.ClassMatchVisitorFactory)1 AgentPostprocessors (com.newrelic.agent.instrumentation.weaver.preprocessors.AgentPostprocessors)1 AgentPreprocessors (com.newrelic.agent.instrumentation.weaver.preprocessors.AgentPreprocessors)1