use of org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan in project incubator-skywalking by apache.
the class MessageConcurrentlyConsumeInterceptor method afterMethod.
@Override
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, Object ret) throws Throwable {
ConsumeConcurrentlyStatus status = (ConsumeConcurrentlyStatus) ret;
if (status == ConsumeConcurrentlyStatus.RECONSUME_LATER) {
AbstractSpan activeSpan = ContextManager.activeSpan();
activeSpan.errorOccurred();
Tags.STATUS_CODE.set(activeSpan, status.name());
}
ContextManager.stopSpan();
return ret;
}
use of org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan in project incubator-skywalking by apache.
the class MessageSendInterceptor method beforeMethod.
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
Message message = (Message) allArguments[2];
ContextCarrier contextCarrier = new ContextCarrier();
String namingServiceAddress = String.valueOf(objInst.getSkyWalkingDynamicField());
AbstractSpan span = ContextManager.createExitSpan(buildOperationName(message.getTopic()), contextCarrier, namingServiceAddress);
span.setComponent(ComponentsDefine.ROCKET_MQ);
Tags.MQ_BROKER.set(span, (String) allArguments[0]);
Tags.MQ_TOPIC.set(span, message.getTopic());
SpanLayer.asMQ(span);
SendMessageRequestHeader requestHeader = (SendMessageRequestHeader) allArguments[3];
StringBuilder properties = new StringBuilder(requestHeader.getProperties());
CarrierItem next = contextCarrier.items();
while (next.hasNext()) {
next = next.next();
if (!StringUtil.isEmpty(next.getHeadValue())) {
properties.append(next.getHeadKey());
properties.append(NAME_VALUE_SEPARATOR);
properties.append(next.getHeadValue());
properties.append(PROPERTY_SEPARATOR);
}
}
requestHeader.setProperties(properties.toString());
if (allArguments[6] != null) {
((EnhancedInstance) allArguments[6]).setSkyWalkingDynamicField(new SendCallBackEnhanceInfo(message.getTopic(), ContextManager.capture()));
}
}
use of org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan in project incubator-skywalking by apache.
the class OnSuccessInterceptor method beforeMethod.
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
SendCallBackEnhanceInfo enhanceInfo = (SendCallBackEnhanceInfo) objInst.getSkyWalkingDynamicField();
AbstractSpan activeSpan = ContextManager.createLocalSpan(CALLBACK_OPERATION_NAME_PREFIX + enhanceInfo.getTopicId() + "/Producer/Callback");
activeSpan.setComponent(ComponentsDefine.ROCKET_MQ);
SendStatus sendStatus = ((SendResult) allArguments[0]).getSendStatus();
if (sendStatus != SendStatus.SEND_OK) {
activeSpan.errorOccurred();
Tags.STATUS_CODE.set(activeSpan, sendStatus.name());
}
ContextManager.continued(enhanceInfo.getContextSnapshot());
}
use of org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan in project incubator-skywalking by apache.
the class ProducerOperationHandlerInterceptor method handleMethodException.
@Override
public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, Throwable t) {
AbstractSpan span = ContextManager.activeSpan();
span.errorOccurred();
span.log(t);
}
use of org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan in project incubator-skywalking by apache.
the class RestResponseInterceptor method afterMethod.
@Override
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, Object ret) throws Throwable {
ClientHttpResponse response = (ClientHttpResponse) allArguments[2];
int statusCode = response.getStatusCode().value();
AbstractSpan span = ContextManager.activeSpan();
if (statusCode >= 400) {
span.errorOccurred();
Tags.STATUS_CODE.set(span, Integer.toString(statusCode));
}
return ret;
}
Aggregations