use of com.shulie.instrument.simulator.api.instrument.InstrumentClass in project LinkAgent by shulieTech.
the class CatalinaPlugin method onActive.
@Override
public boolean onActive() throws Throwable {
enhanceTemplate.enhance(this, "org.apache.catalina.core.StandardHostValve", new EnhanceCallback() {
@Override
public void doEnhance(InstrumentClass target) {
InstrumentMethod method = target.getDeclaredMethod("invoke", "org.apache.catalina.connector.Request", "org.apache.catalina.connector.Response");
method.addInterceptor(Listeners.of(StandardHostValveInvokeInterceptor.class));
}
});
enhanceTemplate.enhance(this, "org.apache.catalina.connector.Request", new EnhanceCallback() {
@Override
public void doEnhance(InstrumentClass target) {
InstrumentMethod method = target.getDeclaredMethod("startAsync", "javax.servlet.ServletRequest", "javax.servlet.ServletResponse");
method.addInterceptor(Listeners.of(RequestStartAsyncInterceptor.class));
}
});
// org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.MappingRegistry.getMappingsByUrl
enhanceTemplate.enhance(this, "org.springframework.web.servlet.handler.AbstractHandlerMethodMapping$MappingRegistry", new EnhanceCallback() {
@Override
public void doEnhance(InstrumentClass target) {
InstrumentMethod getMethod = target.getDeclaredMethod("getMappingsByUrl", "java.lang.String");
getMethod.addInterceptor(Listeners.of(SpringMvcInterceptor.class));
}
});
return true;
}
use of com.shulie.instrument.simulator.api.instrument.InstrumentClass in project LinkAgent by shulieTech.
the class KafkaPlugin method addConsumerRegisterInterceptor.
private boolean addConsumerRegisterInterceptor() {
enhanceConsumerRecordEntryPoint("org.springframework.kafka.listener.adapter.RecordMessagingMessageListenerAdapter");
enhanceConsumerRecordEntryPoint("org.springframework.kafka.listener.adapter.RetryingMessageListenerAdapter");
enhanceBatchMessagingMessage("org.springframework.kafka.listener.adapter.BatchMessagingMessageListenerAdapter");
enhanceSetMessageListener("org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer");
this.enhanceTemplate.enhance(this, "org.apache.kafka.clients.consumer.KafkaConsumer", new EnhanceCallback() {
@Override
public void doEnhance(InstrumentClass target) {
InstrumentMethod constructor = target.getConstructors();
constructor.addInterceptor(Listeners.of(ConsumerConstructorInterceptor.class, "KafkaConsumerConstructorScope", ExecutionPolicy.BOUNDARY, Interceptors.SCOPE_CALLBACK));
// Version 2.2.0+ is supported.
InstrumentMethod pollMethod = target.getDeclaredMethod("poll", "org.apache.kafka.common.utils.Timer", "boolean");
pollMethod.addInterceptor(Listeners.of(ConsumerPollInterceptor.class, "kafkaScope", ExecutionPolicy.BOUNDARY, Interceptors.SCOPE_CALLBACK));
pollMethod.addInterceptor(Listeners.of(ConsumerTraceInterceptor.class, "kafkaTraceScope", ExecutionPolicy.BOUNDARY, Interceptors.SCOPE_CALLBACK));
// Version 2.0.0+ is supported.
InstrumentMethod pollMethod1 = target.getDeclaredMethod("poll", "long", "boolean");
pollMethod1.addInterceptor(Listeners.of(ConsumerPollInterceptor.class, "kafkaScope", ExecutionPolicy.BOUNDARY, Interceptors.SCOPE_CALLBACK));
pollMethod1.addInterceptor(Listeners.of(ConsumerTraceInterceptor.class, "kafkaTraceScope", ExecutionPolicy.BOUNDARY, Interceptors.SCOPE_CALLBACK));
// Version 2.0.0-
InstrumentMethod pollMethod2 = target.getDeclaredMethod("poll", "long");
pollMethod2.addInterceptor(Listeners.of(ConsumerPollInterceptor.class, "kafkaScope", ExecutionPolicy.BOUNDARY, Interceptors.SCOPE_CALLBACK));
pollMethod2.addInterceptor(Listeners.of(ConsumerTraceInterceptor.class, "kafkaTraceScope", ExecutionPolicy.BOUNDARY, Interceptors.SCOPE_CALLBACK));
// 以下提交方法必须都要增强
target.getDeclaredMethod("commitAsync", "org.apache.kafka.clients.consumer.OffsetCommitCallback").addInterceptor(Listeners.of(ConsumerCommitAsyncInterceptor.class, "kafkaScope", ExecutionPolicy.BOUNDARY, Interceptors.SCOPE_CALLBACK));
target.getDeclaredMethod("commitAsync", "java.util.Map", "org.apache.kafka.clients.consumer.OffsetCommitCallback").addInterceptor(Listeners.of(ConsumerCommitAsyncInterceptor.class, "kafkaScope", ExecutionPolicy.BOUNDARY, Interceptors.SCOPE_CALLBACK));
target.getDeclaredMethod("commitSync", "java.util.Map").addInterceptor(Listeners.of(ConsumerCommitSyncInterceptor.class, "kafkaScope", ExecutionPolicy.BOUNDARY, Interceptors.SCOPE_CALLBACK));
target.getDeclaredMethod("commitSync", "java.time.Duration").addInterceptor(Listeners.of(ConsumerCommitSyncInterceptor.class, "kafkaScope", ExecutionPolicy.BOUNDARY, Interceptors.SCOPE_CALLBACK));
target.getDeclaredMethod("commitSync", "java.util.Map", "java.time.Duration").addInterceptor(Listeners.of(ConsumerCommitSyncInterceptor.class, "kafkaScope", ExecutionPolicy.BOUNDARY, Interceptors.SCOPE_CALLBACK));
target.getDeclaredMethods("close", "position", "assignment", "subscription", "subscribe", "assign", "unsubscribe", "seek", "seekToBeginning", "seekToEnd", "position", "committed", "metrics", "partitionsFor", "listTopics", "paused", "pause", "resume", "offsetsForTimes", "beginningOffsets", "endOffsets", "close", "wakeup").addInterceptor(Listeners.of(ConsumerOtherMethodInterceptor.class, "kafkaScope", ExecutionPolicy.BOUNDARY, Interceptors.SCOPE_CALLBACK));
}
});
return true;
}
use of com.shulie.instrument.simulator.api.instrument.InstrumentClass in project LinkAgent by shulieTech.
the class OKHttpPlugin method onActive.
@Override
public boolean onActive() throws Throwable {
// Support for OkHttp3
enhanceTemplate.enhance(this, "okhttp3.Request$Builder", new EnhanceCallback() {
@Override
public void doEnhance(InstrumentClass target) {
final InstrumentMethod buildMethod = target.getDeclaredMethod("build");
buildMethod.addInterceptor(Listeners.of(RequestBuilderBuildMethodV3Interceptor.class));
}
});
enhanceTemplate.enhance(this, "okhttp3.RealCall", new EnhanceCallback() {
@Override
public void doEnhance(InstrumentClass target) {
final InstrumentMethod executeMethod = target.getDeclaredMethod("execute");
executeMethod.addInterceptor(Listeners.of(RealCallExecuteV3Interceptor.class));
final InstrumentMethod enqueueMethod = target.getDeclaredMethod("enqueue", "okhttp3.Callback");
enqueueMethod.addInterceptor(Listeners.of(RealCallEnqueueV3Interceptor.class));
}
});
enhanceTemplate.enhance(this, "okhttp3.RealCall$AsyncCall", new EnhanceCallback() {
@Override
public void doEnhance(InstrumentClass target) {
InstrumentMethod constructor = target.getConstructor("okhttp3.RealCall", "okhttp3.Callback");
constructor.addInterceptor(Listeners.of(AsyncCallConstructorV3Interceptor.class));
}
});
// Support for OkHttp2
enhanceTemplate.enhance(this, "com.squareup.okhttp.Request$Builder", new EnhanceCallback() {
@Override
public void doEnhance(InstrumentClass target) {
final InstrumentMethod buildMethod = target.getDeclaredMethod("build");
buildMethod.addInterceptor(Listeners.of(RequestBuilderBuildMethodV2Interceptor.class));
}
});
enhanceTemplate.enhance(this, "com.squareup.okhttp.Call", new EnhanceCallback() {
@Override
public void doEnhance(InstrumentClass target) {
final InstrumentMethod executeMethod = target.getDeclaredMethod("execute");
executeMethod.addInterceptor(Listeners.of(RealCallExecuteV2Interceptor.class));
final InstrumentMethod enqueueMethod = target.getDeclaredMethod("enqueue", "com.squareup.okhttp.Callback");
enqueueMethod.addInterceptor(Listeners.of(RealCallEnqueueV2Interceptor.class));
}
});
enhanceTemplate.enhance(this, "com.squareup.okhttp.Call$AsyncCall", new EnhanceCallback() {
@Override
public void doEnhance(InstrumentClass target) {
InstrumentMethod constructor = target.getConstructor("com.squareup.okhttp.Call", "com.squareup.okhttp.Callback", "boolean");
constructor.addInterceptor(Listeners.of(AsyncCallConstructorV2Interceptor.class));
}
});
return true;
}
use of com.shulie.instrument.simulator.api.instrument.InstrumentClass in project LinkAgent by shulieTech.
the class ProxoolPlugin method onActive.
@Override
public boolean onActive() throws Throwable {
enhanceTemplate.enhance(this, "org.logicalcobwebs.proxool.ProxoolDataSource", new EnhanceCallback() {
@Override
public void doEnhance(InstrumentClass target) {
InstrumentMethod getConnection = target.getDeclaredMethod("getConnection");
getConnection.addInterceptor(Listeners.of(DataSourceGetConnectionCutoffInterceptor.class, "Proxool_Get_Connection_Scope", ExecutionPolicy.BOUNDARY, Interceptors.SCOPE_CALLBACK));
}
});
enhanceTemplate.enhance(this, "org.logicalcobwebs.proxool.ProxyStatement", new EnhanceCallback() {
@Override
public void doEnhance(InstrumentClass target) {
InstrumentMethod invoke = target.getDeclaredMethod("invoke", "java.lang.Object", "java.lang.reflect.Method", "java.lang.Object[]");
invoke.addInterceptor(Listeners.of(ProxyStatementInvokeInterceptor.class));
}
});
// org.logicalcobwebs.proxool.ConnectionPoolManager.createConnectionPool
enhanceTemplate.enhance(this, "org.logicalcobwebs.proxool.ConnectionPoolManager", new EnhanceCallback() {
@Override
public void doEnhance(InstrumentClass target) {
InstrumentMethod createConnectionPool = target.getDeclaredMethod("createConnectionPool", "org.logicalcobwebs.proxool.ConnectionPoolDefinition");
createConnectionPool.addInterceptor(Listeners.of(ConnectionPoolManagerCreateConnectionPoolInterceptor.class));
}
});
// org.logicalcobwebs.proxool.ProxoolDriver.connect
enhanceTemplate.enhance(this, "org.logicalcobwebs.proxool.ProxoolDriver", new EnhanceCallback() {
@Override
public void doEnhance(InstrumentClass target) {
InstrumentMethod getConnection = target.getDeclaredMethod("connect", "java.lang.String", "java.util.Properties");
getConnection.addInterceptor(Listeners.of(ProxoolDriverConnectInterceptor.class));
}
});
return true;
}
use of com.shulie.instrument.simulator.api.instrument.InstrumentClass in project LinkAgent by shulieTech.
the class RocketMQPlugin method addHookRegisterInterceptor.
private boolean addHookRegisterInterceptor() {
this.enhanceTemplate.enhance(this, "com.alibaba.rocketmq.client.consumer.DefaultMQPushConsumer", new EnhanceCallback() {
@Override
public void doEnhance(InstrumentClass target) {
final InstrumentMethod createTopicMethod = target.getDeclaredMethods("createTopic");
createTopicMethod.addInterceptor(Listeners.of(DefaultPushConsumerCreateTopicInterceptor.class));
final InstrumentMethod earliestMsgStoreTimeMethod = target.getDeclaredMethods("earliestMsgStore");
earliestMsgStoreTimeMethod.addInterceptor(Listeners.of(DefaultPushConsumerEarliestMsgStoreTimeInterceptor.class));
final InstrumentMethod searchOffsetMethod = target.getDeclaredMethods("searchOffset");
searchOffsetMethod.addInterceptor(Listeners.of(DefaultPushConsumerSearchOffsetInterceptor.class));
final InstrumentMethod maxOffsetMethod = target.getDeclaredMethods("maxOffset");
maxOffsetMethod.addInterceptor(Listeners.of(DefaultPushConsumerMaxOffsetInterceptor.class));
final InstrumentMethod minOffsetMethod = target.getDeclaredMethods("minOffset");
minOffsetMethod.addInterceptor(Listeners.of(DefaultPushConsumerMinOffsetInterceptor.class));
final InstrumentMethod viewMessageMethod = target.getDeclaredMethods("viewMessage");
viewMessageMethod.addInterceptor(Listeners.of(DefaultPushConsumerViewMessageInterceptor.class));
final InstrumentMethod queryMessageMethod = target.getDeclaredMethods("queryMessage");
queryMessageMethod.addInterceptor(Listeners.of(DefaultPushConsumerQueryMessageInterceptor.class));
final InstrumentMethod fetchSubscribeMessageQueuesMethod = target.getDeclaredMethods("fetchSubscribeMessageQueues");
fetchSubscribeMessageQueuesMethod.addInterceptor(Listeners.of(DefaultPushConsumerFetchSubscribeMessageQueuesInterceptor.class));
final InstrumentMethod sendMessageBackMethod = target.getDeclaredMethods("sendMessageBack");
sendMessageBackMethod.addInterceptor(Listeners.of(DefaultPushConsumerSendMessageBackInterceptor.class));
final InstrumentMethod shutdownMethod = target.getDeclaredMethod("shutdown");
shutdownMethod.addInterceptor(Listeners.of(DefaultPushConsumerShutdownInterceptor.class));
}
});
this.enhanceTemplate.enhance(this, "com.alibaba.rocketmq.client.impl.consumer.DefaultMQPushConsumerImpl", new EnhanceCallback() {
@Override
public void doEnhance(InstrumentClass target) {
final InstrumentMethod hasHookMethod = target.getDeclaredMethod("hasHook");
hasHookMethod.addInterceptor(Listeners.of(DefaultMQPushConsumerImplHasHookListener.class));
}
});
this.enhanceTemplate.enhance(this, "com.alibaba.rocketmq.client.impl.consumer.DefaultMQPullConsumerImpl", new EnhanceCallback() {
@Override
public void doEnhance(InstrumentClass target) {
target.getDeclaredMethod("pullSyncImpl", "com.alibaba.rocketmq.common.message.MessageQueue", "java.lang.String", "long", "int", "boolean", "long").addInterceptor(Listeners.of(PullConsumerInterceptor.class));
}
});
this.enhanceTemplate.enhance(this, "com.alibaba.rocketmq.client.producer.DefaultMQProducer", new EnhanceCallback() {
@Override
public void doEnhance(InstrumentClass target) {
target.getDeclaredMethod("start").addInterceptor(Listeners.of(MQProducerInterceptor.class));
// 压测代码
InstrumentMethod sendMethod = target.getDeclaredMethods("send*");
sendMethod.addInterceptor(Listeners.of(MQProducerSendInterceptor.class));
}
});
this.enhanceTemplate.enhance(this, "com.alibaba.rocketmq.client.impl.producer.DefaultMQProducerImpl", new EnhanceCallback() {
@Override
public void doEnhance(InstrumentClass target) {
// 压测代码
InstrumentMethod method = target.getDeclaredMethods("sendDefaultImpl");
method.addInterceptor(Listeners.of(MQProducerSendInterceptor.class));
InstrumentMethod sendMessageInTransactionMethod = target.getDeclaredMethods("sendMessageInTransaction");
sendMessageInTransactionMethod.addInterceptor(Listeners.of(MQProducerSendInterceptor.class));
// 压测代码 end
}
});
this.enhanceTemplate.enhance(this, "com.alibaba.rocketmq.client.impl.producer.DefaultMQProducerImpl", new EnhanceCallback() {
@Override
public void doEnhance(InstrumentClass target) {
InstrumentMethod enhanceMethod = target.getDeclaredMethods("checkTransactionState*");
enhanceMethod.addInterceptor(Listeners.of(TransactionCheckInterceptor.class));
}
});
this.enhanceTemplate.enhance(this, "com.alibaba.rocketmq.client.impl.consumer.ConsumeMessageConcurrentlyService$ConsumeRequest", new EnhanceCallback() {
@Override
public void doEnhance(InstrumentClass target) {
InstrumentMethod enhanceMethod = target.getDeclaredMethods("run");
enhanceMethod.addInterceptor(Listeners.of(ConcurrentlyTraceInterceptor.class));
}
});
// --for orderly
this.enhanceTemplate.enhance(this, "com.alibaba.rocketmq.client.impl.consumer.ConsumeMessageOrderlyService$ConsumeRequest", new EnhanceCallback() {
@Override
public void doEnhance(InstrumentClass target) {
InstrumentMethod enhanceMethod = target.getDeclaredMethods("run");
enhanceMethod.addInterceptor(Listeners.of(OrderlyTraceContextInterceptor.class));
}
});
this.enhanceTemplate.enhance(this, "com.alibaba.rocketmq.client.impl.consumer.ProcessQueue", new EnhanceCallback() {
@Override
public void doEnhance(InstrumentClass target) {
InstrumentMethod enhanceMethod = target.getDeclaredMethods("takeMessags");
enhanceMethod.addInterceptor(Listeners.of(OrderlyTraceBeforeInterceptor.class));
}
});
this.enhanceTemplate.enhance(this, "com.alibaba.rocketmq.client.impl.consumer.ConsumeMessageOrderlyService", new EnhanceCallback() {
@Override
public void doEnhance(InstrumentClass target) {
InstrumentMethod enhanceMethod = target.getDeclaredMethods("processConsumeResult");
enhanceMethod.addInterceptor(Listeners.of(OrderlyTraceAfterInterceptor.class));
}
});
return true;
}
Aggregations