Search in sources :

Example 31 with InstrumentClass

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

the class ZuulPlugin method onActive.

// @Override
// public boolean onActive() throws Throwable {
// enhanceTemplate.enhance(this, "com.netflix.zuul.netty.filter.ZuulFilterChainRunner", new EnhanceCallback() {
// @Override
// public void doEnhance(InstrumentClass target) {
// // filter(T) 这个方法开始trace 然后弹出,并且将trace存放到request上面
// InstrumentMethod filterBeforeMethod = target.getDeclaredMethod("filter",
// "com.netflix.zuul.message.ZuulMessage");
// filterBeforeMethod.addInterceptor(
// Listeners.of(ZuulBeforeInterceptor.class));
// 
// // filter(T,HttpContent) 从request上面拿出trace 并且endTrace
// InstrumentMethod filterMethod = target.getDeclaredMethod("filter",
// "com.netflix.zuul.message.ZuulMessage", "io.netty.handler.codec.http.HttpContent");
// filterMethod.addInterceptor(
// Listeners.of(ZuulInterceptor.class));
// }
// });
// return true;
// }
// @Override
// public boolean onActive() throws Throwable {
// enhanceTemplate.enhance(this, "com.netflix.zuul.netty.filter.ZuulFilterChainRunner", new EnhanceCallback() {
// @Override
// public void doEnhance(InstrumentClass target) {
// //InstrumentMethod method = target.getDeclaredMethod("runFilters", "java.lang.Object", "java.util
// // .concurrent.atomic.AtomicInteger");
// InstrumentMethod method = target.getDeclaredMethod("runFilters", 1,
// "java.util.concurrent.atomic.AtomicInteger");
// method.addInterceptor(Listeners.of(ZuulBackupInterceptor.class));
// }
// });
// return true;
// }
@Override
public boolean onActive() throws Throwable {
    enhanceTemplate.enhance(this, "com.netflix.zuul.netty.filter.ZuulFilterChainHandler", new EnhanceCallback() {

        @Override
        public void doEnhance(InstrumentClass target) {
            InstrumentMethod method = target.getDeclaredMethod("userEventTriggered", "io.netty.channel.ChannelHandlerContext", "java.lang.Object");
            method.addInterceptor(Listeners.of(ZuulEventTriggerInterceptor.class));
        }
    });
    enhanceTemplate.enhance(this, "com.netflix.zuul.netty.filter.ZuulFilterChainHandler", new EnhanceCallback() {

        @Override
        public void doEnhance(InstrumentClass target) {
            InstrumentMethod method = target.getDeclaredMethod("channelRead", "io.netty.channel.ChannelHandlerContext", "java.lang.Object");
            method.addInterceptor(Listeners.of(ZuulChannelReadInterceptor.class));
        }
    });
    enhanceTemplate.enhance(this, "com.netflix.zuul.netty.filter.ZuulFilterChainRunner", new EnhanceCallback() {

        @Override
        public void doEnhance(InstrumentClass target) {
            InstrumentMethod method = target.getDeclaredMethod("runFilters", 1, "java.util.concurrent.atomic.AtomicInteger");
            method.addInterceptor(Listeners.of(ZuulFilterRunnerInterceptor.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 32 with InstrumentClass

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

the class WebFluxPlugin method onActive.

@Override
public boolean onActive() throws Throwable {
    // org.springframework.cloud.gateway.handler.FilteringWebHandler$DefaultGatewayFilterChain.filter
    // enhanceTemplate.enhance(this, "org.springframework.cloud.gateway.handler.FilteringWebHandler$DefaultGatewayFilterChain", new EnhanceCallback() {
    // @Override
    // public void doEnhance(InstrumentClass target) {
    // 
    // final InstrumentMethod invokeHandler = target.getDeclaredMethod("filter", "org.springframework.web.server.ServerWebExchange"
    // );
    // invokeHandler.addInterceptor(Listeners.of(InvokeHandlerInterceptor.class));
    // 
    // 
    // }
    // });
    enhanceTemplate.enhance(this, "org.springframework.web.reactive.DispatcherHandler", new EnhanceCallback() {

        @Override
        public void doEnhance(InstrumentClass target) {
            final InstrumentMethod invokeHandler = target.getDeclaredMethod("invokeHandler", "org.springframework.web.server.ServerWebExchange", "java.lang.Object");
            invokeHandler.addInterceptor(Listeners.of(HandlerStartInterceptor.class));
            final InstrumentMethod handleResult = target.getDeclaredMethod("handleResult", "org.springframework.web.server.ServerWebExchange", "org.springframework.web.reactive.HandlerResult");
            handleResult.addInterceptor(Listeners.of(HandlerResultInterceptor.class));
        }
    });
    enhanceTemplate.enhance(this, "org.springframework.http.server.reactive.AbstractServerHttpRequest", new EnhanceCallback() {

        @Override
        public void doEnhance(InstrumentClass target) {
            final InstrumentMethod constructor = target.getConstructor("java.net.URI", "java.lang.String", "org.springframework.http.HttpHeaders");
            constructor.addInterceptor(Listeners.of(AbstractServerHttpRequestInterceptor.class));
        }
    });
    enhanceTemplate.enhance(this, "org.springframework.http.ReadOnlyHttpHeaders", new EnhanceCallback() {

        @Override
        public void doEnhance(InstrumentClass target) {
            List<String> list = new ArrayList<String>();
            list.add("add");
            list.add("set");
            final InstrumentMethod methods = target.getDeclaredMethods(list);
            methods.addInterceptor(Listeners.of(HeaderMethodInterceptor.class));
        }
    });
    return true;
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) 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 33 with InstrumentClass

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

the class Log4jPlugin method addV2AppenderAndRouter.

private void addV2AppenderAndRouter() {
    // =============v2
    // org.apache.logging.log4j.core.config.AppenderControl.tryCallAppender
    enhanceTemplate.enhance(this, "org.apache.logging.log4j.core.config.AppenderControl", new EnhanceCallback() {

        @Override
        public void doEnhance(InstrumentClass target) {
            InstrumentMethod method = target.getDeclaredMethod("tryCallAppender", "org.apache.logging.log4j.core.LogEvent");
            method.addInterceptor(Listeners.of(AppenderRouterInterceptor.class, new Object[] { isBusinessLogOpen, bizShadowLogPath }));
        }
    });
    // org.apache.logging.log4j.core.config.LoggerConfig.log
    enhanceTemplate.enhance(this, "org.apache.logging.log4j.core.config.LoggerConfig", new EnhanceCallback() {

        @Override
        public void doEnhance(InstrumentClass target) {
            InstrumentMethod method = target.getDeclaredMethods("log");
            method.addInterceptor(Listeners.of(AppenderRegisterAttachInterceptor.class, new Object[] { isBusinessLogOpen, bizShadowLogPath }));
        }
    });
}
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 34 with InstrumentClass

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

the class ApacheHbasePlugin method onActive.

@Override
public boolean onActive() throws Throwable {
    this.enhanceTemplate.enhance(this, "org.apache.hadoop.hbase.client.ConnectionFactory", new EnhanceCallback() {

        @Override
        public void doEnhance(InstrumentClass target) {
            final InstrumentMethod connectionMethod = target.getDeclaredMethod("createConnection", "org.apache.hadoop.conf.Configuration", "java.util.concurrent.ExecutorService", "org.apache.hadoop.hbase.security.User");
            connectionMethod.addInterceptor(Listeners.of(ConnectionShadowInterceptor.class));
        }
    });
    initEventListener();
    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 35 with InstrumentClass

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

the class CaffeinePlugin method onActive.

@Override
public boolean onActive() throws Throwable {
    enhanceTemplate.enhance(this, new EnhanceCallback() {

        @Override
        public void doEnhance(InstrumentClass target) {
            // ConcurrentMap接口所有方法
            addConcurrentMapMethodInterceptor(target);
            // 特有的方法
            target.getDeclaredMethod("getIfPresent", "java.lang.Object", "boolean").addInterceptor(Listeners.of(FirstKeyInterceptor.class));
            target.getDeclaredMethod("put", "java.lang.Object", "java.lang.Object", "boolean").addInterceptor(Listeners.of(FirstKeyInterceptor.class));
            target.getDeclaredMethod("computeIfAbsent", "java.lang.Object", "java.util.function.Function", "boolean", "boolean").addInterceptor(Listeners.of(ComputeIfAbsentInterceptor.class));
            target.getDeclaredMethod("remap", "java.lang.Object", "java.util.function.BiFunction").addInterceptor(Listeners.of(FirstKeyWithBiFunctionInterceptor.class));
            target.getDeclaredMethod("getAllPresent", "java.lang.Iterable").addInterceptor(Listeners.of(GetAllInterceptor.class));
            target.getDeclaredMethod("compute", "java.lang.Object", "java.util.function.BiFunction", "boolean", "boolean", "boolean").addInterceptor(Listeners.of(ComputeInterceptor.class));
        }
    }, "com.github.benmanes.caffeine.cache.UnboundedLocalCache");
    enhanceTemplate.enhance(this, new EnhanceCallback() {

        @Override
        public void doEnhance(InstrumentClass target) {
            // ConcurrentMap接口所有方法
            addConcurrentMapMethodInterceptor(target);
            // 特有的方法
            target.getDeclaredMethod("getIfPresent", "java.lang.Object", "boolean").addInterceptor(Listeners.of(FirstKeyInterceptor.class));
            target.getDeclaredMethod("getIfPresentQuietly", "java.lang.Object", "long[]").addInterceptor(Listeners.of(FirstKeyInterceptor.class));
            target.getDeclaredMethod("put", "java.lang.Object", "java.lang.Object", "com.github.benmanes.caffeine.cache.Expiry", "boolean", "boolean").addInterceptor(Listeners.of(FirstKeyInterceptor.class));
            target.getDeclaredMethod("computeIfAbsent", "java.lang.Object", "java.util.function.Function", "boolean", "boolean").addInterceptor(Listeners.of(ComputeIfAbsentInterceptor.class));
            target.getDeclaredMethod("remap", "java.lang.Object", "java.lang.Object", "java.util.function.BiFunction", "long[]", "boolean").addInterceptor(Listeners.of(FirstKeyInterceptor.class));
            target.getDeclaredMethod("getAllPresent", "java.lang.Iterable").addInterceptor(Listeners.of(GetAllInterceptor.class));
            target.getDeclaredMethod("compute", "java.lang.Object", "java.util.function.BiFunction", "boolean", "boolean", "boolean").addInterceptor(Listeners.of(ComputeInterceptor.class));
            target.getDeclaredMethod("compute", "java.lang.Object", "java.util.function.BiFunction", "boolean", "boolean").addInterceptor(Listeners.of(ComputeInterceptor.class));
        }
    }, "com.github.benmanes.caffeine.cache.BoundedLocalCache");
    return true;
}
Also used : InstrumentClass(com.shulie.instrument.simulator.api.instrument.InstrumentClass) EnhanceCallback(com.shulie.instrument.simulator.api.instrument.EnhanceCallback)

Aggregations

EnhanceCallback (com.shulie.instrument.simulator.api.instrument.EnhanceCallback)42 InstrumentClass (com.shulie.instrument.simulator.api.instrument.InstrumentClass)42 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