use of org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance in project incubator-skywalking by apache.
the class KafkaProducerInterceptor method beforeMethod.
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
ContextCarrier contextCarrier = new ContextCarrier();
ProducerRecord record = (ProducerRecord) allArguments[0];
String topicName = (String) ((EnhancedInstance) record).getSkyWalkingDynamicField();
AbstractSpan activeSpan = ContextManager.createExitSpan(OPERATE_NAME_PREFIX + topicName + PRODUCER_OPERATE_NAME_SUFFIX, contextCarrier, (String) objInst.getSkyWalkingDynamicField());
Tags.MQ_BROKER.set(activeSpan, (String) objInst.getSkyWalkingDynamicField());
Tags.MQ_TOPIC.set(activeSpan, topicName);
SpanLayer.asMQ(activeSpan);
activeSpan.setComponent(ComponentsDefine.KAFKA);
CarrierItem next = contextCarrier.items();
while (next.hasNext()) {
next = next.next();
record.headers().add(next.getHeadKey(), next.getHeadValue().getBytes());
}
EnhancedInstance callbackInstance = (EnhancedInstance) allArguments[1];
if (callbackInstance != null) {
callbackInstance.setSkyWalkingDynamicField(ContextManager.capture());
}
}
use of org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance in project incubator-skywalking by apache.
the class SWExecutionHookWrapper method onStart.
@Override
public <T> void onStart(HystrixCommand<T> commandInstance) {
EnhancedInstance enhancedInstance = (EnhancedInstance) commandInstance;
EnhanceRequireObjectCache enhanceRequireObjectCache = (EnhanceRequireObjectCache) enhancedInstance.getSkyWalkingDynamicField();
enhanceRequireObjectCache.setContextSnapshot(ContextManager.capture());
actual.onStart(commandInstance);
}
use of org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance in project incubator-skywalking by apache.
the class SuccessInterceptor method beforeMethod.
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
SessionRequest request = (SessionRequest) allArguments[0];
AbstractSpan localSpan = ContextManager.createLocalSpan("AsyncThread/execute");
localSpan.setComponent(ComponentsDefine.HTTP_ASYNC_CLIENT).setLayer(SpanLayer.HTTP);
Object cacheValue = ((EnhancedInstance) request).getSkyWalkingDynamicField();
ContextManager.continued((ContextSnapshot) cacheValue);
}
use of org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance in project incubator-skywalking by apache.
the class ResponseCallBackInterceptor method beforeMethod.
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
EnhancedInstance successCallBak = (EnhancedInstance) allArguments[0];
successCallBak.setSkyWalkingDynamicField(objInst.getSkyWalkingDynamicField());
if (allArguments.length == 2) {
EnhancedInstance failedCallBack = (EnhancedInstance) allArguments[1];
failedCallBack.setSkyWalkingDynamicField(objInst.getSkyWalkingDynamicField());
}
}
use of org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance in project incubator-skywalking by apache.
the class MessageSendInterceptorTest method setUp.
@Before
public void setUp() {
messageSendInterceptor = new MessageSendInterceptor();
enhancedInstance = new EnhancedInstance() {
@Override
public Object getSkyWalkingDynamicField() {
return "127.0.0.1:6543";
}
@Override
public void setSkyWalkingDynamicField(Object value) {
}
};
arguments = new Object[] { "127.0.0.1", "test", message, messageRequestHeader, null, CommunicationMode.ASYNC, callBack };
argumentsWithoutCallback = new Object[] { "127.0.0.1", "test", message, messageRequestHeader, null, CommunicationMode.ASYNC, null };
when(messageRequestHeader.getProperties()).thenReturn("");
when(message.getTags()).thenReturn("TagA");
}
Aggregations