Search in sources :

Example 21 with InstrumentMethod

use of com.shulie.instrument.simulator.api.instrument.InstrumentMethod in project LinkAgent by shulieTech.

the class ResinPlugin method onActive.

@Override
public boolean onActive() throws Throwable {
    enhanceTemplate.enhance(this, "com.caucho.server.http.HttpServletRequestImpl", new EnhanceCallback() {

        @Override
        public void doEnhance(InstrumentClass target) {
            final InstrumentMethod startAsyncMethodEditor = target.getDeclaredMethod("startAsync", "javax.servlet.ServletRequest", "javax.servlet.ServletResponse");
            if (startAsyncMethodEditor != null) {
                startAsyncMethodEditor.addInterceptor(Listeners.of(HttpServletRequestImplStartAsyncInterceptor.class));
            }
        }
    });
    enhanceTemplate.enhance(this, "com.caucho.server.dispatch.ServletInvocation", new EnhanceCallback() {

        @Override
        public void doEnhance(InstrumentClass target) {
            final InstrumentMethod serviceMethodEditorBuilder = target.getDeclaredMethod("service", "javax.servlet.ServletRequest", "javax.servlet.ServletResponse");
            if (serviceMethodEditorBuilder != null) {
                serviceMethodEditorBuilder.addInterceptor(Listeners.of(ServletInvocationServiceInterceptor.class, "RESIN_REQUEST", ExecutionPolicy.BOUNDARY, Interceptors.SCOPE_CALLBACK));
            }
        }
    });
    return true;
}
Also used : InstrumentClass(com.shulie.instrument.simulator.api.instrument.InstrumentClass) InstrumentMethod(com.shulie.instrument.simulator.api.instrument.InstrumentMethod) EnhanceCallback(com.shulie.instrument.simulator.api.instrument.EnhanceCallback)

Example 22 with InstrumentMethod

use of com.shulie.instrument.simulator.api.instrument.InstrumentMethod in project LinkAgent by shulieTech.

the class JettyPlugin method addServerInterceptor.

private boolean addServerInterceptor() {
    enhanceTemplate.enhance(this, "org.eclipse.jetty.server.handler.HandlerWrapper", new EnhanceCallback() {

        @Override
        public void doEnhance(InstrumentClass target) {
            // 7.x ~ 9.x
            final InstrumentMethod handleMethod = target.getDeclaredMethod("handle", "java.lang.String", "org.eclipse.jetty.server.Request", "javax.servlet.http.HttpServletRequest", "javax.servlet.http.HttpServletResponse");
            handleMethod.addInterceptor(Listeners.of(JettyServerHandleInterceptor.class));
        }
    });
    // jetty 6.x
    enhanceTemplate.enhance(this, "org.mortbay.jetty.Server", new EnhanceCallback() {

        @Override
        public void doEnhance(InstrumentClass target) {
            InstrumentMethod handleMethod = target.getDeclaredMethod("handle", "java.lang.String", "javax.servlet.http.HttpServletRequest", "javax.servlet.http.HttpServletResponse", "int");
            handleMethod.addInterceptor(Listeners.of(Jetty6xServerHandleInterceptor.class));
        }
    });
    enhanceTemplate.enhance(this, "org.eclipse.jetty.server.Request", new EnhanceCallback() {

        @Override
        public void doEnhance(InstrumentClass target) {
            // Add async listener. Servlet 3.0
            final InstrumentMethod startAsyncMethod = target.getDeclaredMethod("startAsync");
            startAsyncMethod.addInterceptor(Listeners.of(RequestStartAsyncInterceptor.class));
            final InstrumentMethod startAsyncMethod0 = target.getDeclaredMethod("startAsync", "javax.servlet.ServletRequest", "javax.servlet.ServletResponse");
            startAsyncMethod0.addInterceptor(Listeners.of(RequestStartAsyncInterceptor.class));
        }
    });
    return true;
}
Also used : InstrumentClass(com.shulie.instrument.simulator.api.instrument.InstrumentClass) InstrumentMethod(com.shulie.instrument.simulator.api.instrument.InstrumentMethod) EnhanceCallback(com.shulie.instrument.simulator.api.instrument.EnhanceCallback)

Example 23 with InstrumentMethod

use of com.shulie.instrument.simulator.api.instrument.InstrumentMethod in project LinkAgent by shulieTech.

the class HystrixPlugin method onActive.

@Override
public boolean onActive() throws Throwable {
    enhanceTemplate.enhance(this, "com.netflix.hystrix.strategy.concurrency.HystrixContextScheduler$HystrixContextSchedulerWorker", new EnhanceCallback() {

        @Override
        public void doEnhance(InstrumentClass target) {
            InstrumentMethod constructors = target.getConstructors();
            constructors.addInterceptor(Listeners.of(ConstructorInterceptor.class));
            InstrumentMethod scheduleMethod1 = target.getDeclaredMethod("schedule", "rx.functions.Action0");
            scheduleMethod1.addInterceptor(Listeners.of(InvokeInterceptor.class));
            InstrumentMethod scheduleMethod2 = target.getDeclaredMethod("schedule", "rx.functions.Action0", "long", "java.util.concurrent.TimeUnit");
            scheduleMethod2.addInterceptor(Listeners.of(InvokeInterceptor.class));
        }
    });
    enhanceTemplate.enhance(this, "com.netflix.hystrix.strategy.concurrency.HystrixContexSchedulerAction", new EnhanceCallback() {

        @Override
        public void doEnhance(InstrumentClass target) {
            InstrumentMethod constructor1 = target.getConstructor("com.netflix.hystrix.strategy.concurrency.HystrixConcurrencyStrategy", "rx.functions.Action0");
            constructor1.addInterceptor(Listeners.of(ConstructorInterceptor.class));
            InstrumentMethod callMethod = target.getDeclaredMethod("call");
            callMethod.addInterceptor(Listeners.of(InvokeInterceptor.class));
        }
    });
    enhanceTemplate.enhance(this, "rx.internal.operators.OnSubscribeDefer", new EnhanceCallback() {

        @Override
        public void doEnhance(InstrumentClass target) {
            InstrumentMethod constructors = target.getConstructors();
            constructors.addInterceptor(Listeners.of(ConstructorInterceptor.class));
            InstrumentMethod callMethod = target.getDeclaredMethod("call", "rx.Subscriber");
            callMethod.addInterceptor(Listeners.of(InvokeInterceptor.class));
        }
    });
    return true;
}
Also used : InstrumentClass(com.shulie.instrument.simulator.api.instrument.InstrumentClass) InstrumentMethod(com.shulie.instrument.simulator.api.instrument.InstrumentMethod) EnhanceCallback(com.shulie.instrument.simulator.api.instrument.EnhanceCallback)

Example 24 with InstrumentMethod

use of com.shulie.instrument.simulator.api.instrument.InstrumentMethod in project LinkAgent by shulieTech.

the class JetCachePlugin method onActive.

@Override
public boolean onActive() throws Throwable {
    enhanceTemplate.enhance(this, "com.alicp.jetcache.embedded.AbstractEmbeddedCache", new EnhanceCallback() {

        @Override
        public void doEnhance(InstrumentClass target) {
            InstrumentMethod buildKeyMethod = target.getDeclaredMethod("buildKey", "java.lang.Object");
            buildKeyMethod.addInterceptor(Listeners.of(EmbeddedCacheBuildKeyInterceptor.class));
        }
    });
    enhanceTemplate.enhance(this, "com.alicp.jetcache.external.AbstractExternalCache", new EnhanceCallback() {

        @Override
        public void doEnhance(InstrumentClass target) {
            InstrumentMethod buildKeyMethod = target.getDeclaredMethod("buildKey", "java.lang.Object");
            buildKeyMethod.addInterceptor(Listeners.of(ExternalCacheBuildKeyInterceptor.class));
        }
    });
    return true;
}
Also used : InstrumentClass(com.shulie.instrument.simulator.api.instrument.InstrumentClass) InstrumentMethod(com.shulie.instrument.simulator.api.instrument.InstrumentMethod) EnhanceCallback(com.shulie.instrument.simulator.api.instrument.EnhanceCallback)

Example 25 with InstrumentMethod

use of com.shulie.instrument.simulator.api.instrument.InstrumentMethod in project LinkAgent by shulieTech.

the class GoogleGuavaPlugin method addGuaveInterceptor.

private boolean addGuaveInterceptor() {
    final boolean skipTrace = true;
    enhanceTemplate.enhance(this, "com.google.common.collect.ImmutableMap", new EnhanceCallback() {

        @Override
        public void doEnhance(InstrumentClass target) {
            InstrumentMethod copyOf = target.getDeclaredMethods("copyOf");
            copyOf.addInterceptor(Listeners.of(CacheOperationGetAllResInterceptor.class));
        }
    });
    this.enhanceTemplate.enhance(this, "com.google.common.cache.LocalCache$LoadingValueReference", new EnhanceCallback() {

        @Override
        public void doEnhance(InstrumentClass target) {
            InstrumentMethod load = target.getDeclaredMethods("loadFuture");
            load.addInterceptor(Listeners.of(CacheLoaderKeyConvertInterceptor.class));
        }
    });
    final String[] methods = new String[] { "getAllPresent", "invalidateAll", "get", "invalidate", "putAll", "put", "getIfPresent" };
    // Cache operation
    enhanceTemplate.enhance(this, "com.google.common.cache.LocalCache$LocalManualCache", new EnhanceCallback() {

        @Override
        public void doEnhance(InstrumentClass target) {
            InstrumentMethod build = target.getDeclaredMethods(methods);
            build.addInterceptor(Listeners.of(CacheOperationInterceptor.class));
            if (!skipTrace) {
                InstrumentMethod declaredMethods = target.getDeclaredMethods("*");
                declaredMethods.addInterceptor(Listeners.of(CacheOperationTraceInterceptor.class));
            }
            InstrumentMethod asMap = target.getDeclaredMethods("asMap");
            asMap.addInterceptor(Listeners.of(CacheAsMapInterceptor.class));
        }
    });
    enhanceTemplate.enhance(this, "com.google.common.cache.LocalCache$LocalLoadingCache", new EnhanceCallback() {

        @Override
        public void doEnhance(InstrumentClass target) {
            InstrumentMethod build = target.getDeclaredMethods(methods);
            build.addInterceptor(Listeners.of(CacheOperationInterceptor.class));
            if (!skipTrace) {
                InstrumentMethod declaredMethods = target.getDeclaredMethods("*");
                declaredMethods.addInterceptor(Listeners.of(CacheOperationTraceInterceptor.class));
            }
            InstrumentMethod asMap = target.getDeclaredMethods("asMap");
            asMap.addInterceptor(Listeners.of(CacheAsMapInterceptor.class));
        }
    });
    enhanceTemplate.enhance(this, "com.google.common.cache.ForwardingCache", new EnhanceCallback() {

        @Override
        public void doEnhance(InstrumentClass target) {
            InstrumentMethod build = target.getDeclaredMethods(methods);
            build.addInterceptor(Listeners.of(CacheOperationInterceptor.class));
            if (!skipTrace) {
                InstrumentMethod declaredMethods = target.getDeclaredMethods("*");
                declaredMethods.addInterceptor(Listeners.of(CacheOperationTraceInterceptor.class));
            }
            InstrumentMethod asMap = target.getDeclaredMethods("asMap");
            asMap.addInterceptor(Listeners.of(CacheAsMapInterceptor.class));
        }
    });
    return true;
}
Also used : InstrumentClass(com.shulie.instrument.simulator.api.instrument.InstrumentClass) InstrumentMethod(com.shulie.instrument.simulator.api.instrument.InstrumentMethod) EnhanceCallback(com.shulie.instrument.simulator.api.instrument.EnhanceCallback)

Aggregations

EnhanceCallback (com.shulie.instrument.simulator.api.instrument.EnhanceCallback)41 InstrumentClass (com.shulie.instrument.simulator.api.instrument.InstrumentClass)41 InstrumentMethod (com.shulie.instrument.simulator.api.instrument.InstrumentMethod)41 XxlJobAdapter (com.pamirs.attach.plugin.shadowjob.adapter.XxlJobAdapter)1 IEvent (com.pamirs.pradar.pressurement.agent.event.IEvent)1 ClusterTestSwitchOffEvent (com.pamirs.pradar.pressurement.agent.event.impl.ClusterTestSwitchOffEvent)1 ClusterTestSwitchOnEvent (com.pamirs.pradar.pressurement.agent.event.impl.ClusterTestSwitchOnEvent)1 EventResult (com.pamirs.pradar.pressurement.agent.listener.EventResult)1 PradarEventListener (com.pamirs.pradar.pressurement.agent.listener.PradarEventListener)1 ShadowImplListener (com.pamirs.pradar.pressurement.agent.listener.impl.ShadowImplListener)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1