DEV Community

Query Filter
Query Filter

Posted on

bridge54

new AgentBuilder.Default()
    // 1. SET STRATEGY: Use REDEFINE to replace existing class definitions
    .with(AgentBuilder.TypeStrategy.Default.REDEFINE)
    .with(AgentBuilder.RedefinitionStrategy.RETRANSFORMATION)

    // 2. POOL STRATEGY: Required for finding classes in isolated Child ClassLoaders
    .with(AgentBuilder.PoolStrategy.Default.METADATA) 

    // 3. IGNORE CHECK: Ensure we aren't accidentally ignoring Citi/Comet packages
    .ignore(ElementMatchers.none()) 

    .type(typeDescription -> targetClassSet.contains(typeDescription.getName()))
    .transform((builder, typeDescription, classLoader, module) -> {
        System.out.println("PROFILER: Attempting transformation of " + typeDescription.getName());
        return builder.method(ElementMatchers.any()
                .and(ElementMatchers.not(ElementMatchers.isAbstract()))
                .and(ElementMatchers.not(ElementMatchers.isNative())))
                .intercept(Advice.to(comet.agent.ProfilerAgent.ProfilerAdvice.class));
    })
    .installOn(inst);
Enter fullscreen mode Exit fullscreen mode

Top comments (0)