Search in sources :

Example 51 with AbstractSpan

use of org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan in project incubator-skywalking by apache.

the class MessageOrderlyConsumeInterceptor method afterMethod.

@Override
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, Object ret) throws Throwable {
    ConsumeOrderlyStatus status = (ConsumeOrderlyStatus) ret;
    if (status == ConsumeOrderlyStatus.SUSPEND_CURRENT_QUEUE_A_MOMENT) {
        AbstractSpan activeSpan = ContextManager.activeSpan();
        activeSpan.errorOccurred();
        Tags.STATUS_CODE.set(activeSpan, status.name());
    }
    ContextManager.stopSpan();
    return ret;
}
Also used : ConsumeOrderlyStatus(com.alibaba.rocketmq.client.consumer.listener.ConsumeOrderlyStatus) AbstractSpan(org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan)

Example 52 with AbstractSpan

use of org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan in project incubator-skywalking by apache.

the class OnExceptionInterceptor 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);
    activeSpan.errorOccurred().log((Throwable) allArguments[0]);
    ContextManager.continued(enhanceInfo.getContextSnapshot());
}
Also used : SendCallBackEnhanceInfo(org.apache.skywalking.apm.plugin.rocketMQ.v3.define.SendCallBackEnhanceInfo) AbstractSpan(org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan)

Example 53 with AbstractSpan

use of org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan in project incubator-skywalking by apache.

the class AbstractMethodInterceptor method beforeMethod.

@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
    EnhanceRequireObjectCache pathMappingCache = (EnhanceRequireObjectCache) objInst.getSkyWalkingDynamicField();
    String requestURL = pathMappingCache.findPathMapping(method);
    if (requestURL == null) {
        requestURL = getRequestURL(method);
        pathMappingCache.addPathMapping(method, requestURL);
        requestURL = pathMappingCache.findPathMapping(method);
    }
    HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
    ContextCarrier contextCarrier = new ContextCarrier();
    CarrierItem next = contextCarrier.items();
    while (next.hasNext()) {
        next = next.next();
        next.setHeadValue(request.getHeader(next.getHeadKey()));
    }
    AbstractSpan span = ContextManager.createEntrySpan(requestURL, contextCarrier);
    Tags.URL.set(span, request.getRequestURL().toString());
    Tags.HTTP.METHOD.set(span, request.getMethod());
    span.setComponent(ComponentsDefine.SPRING_MVC_ANNOTATION);
    SpanLayer.asHttp(span);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ContextCarrier(org.apache.skywalking.apm.agent.core.context.ContextCarrier) CarrierItem(org.apache.skywalking.apm.agent.core.context.CarrierItem) ServletRequestAttributes(org.springframework.web.context.request.ServletRequestAttributes) EnhanceRequireObjectCache(org.apache.skywalking.apm.plugin.spring.mvc.commons.EnhanceRequireObjectCache) AbstractSpan(org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan)

Example 54 with AbstractSpan

use of org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan in project incubator-skywalking by apache.

the class TransportClientHandlerInterceptor method beforeMethod.

@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
    Invocation invocation = (Invocation) allArguments[0];
    if (!checkRegisterStatus(invocation)) {
        return;
    }
    URI uri = new URI(invocation.getEndpoint().toString());
    String peer = uri.getHost() + ":" + uri.getPort();
    String operationName = invocation.getMicroserviceQualifiedName();
    final ContextCarrier contextCarrier = new ContextCarrier();
    AbstractSpan span = ContextManager.createExitSpan(operationName, contextCarrier, peer);
    CarrierItem next = contextCarrier.items();
    while (next.hasNext()) {
        next = next.next();
        invocation.getContext().put(next.getHeadKey(), next.getHeadValue());
    }
    String url = invocation.getOperationMeta().getOperationPath();
    Tags.URL.set(span, url);
    span.setComponent(ComponentsDefine.SERVICECOMB);
    SpanLayer.asRPCFramework(span);
}
Also used : ContextCarrier(org.apache.skywalking.apm.agent.core.context.ContextCarrier) Invocation(org.apache.servicecomb.core.Invocation) CarrierItem(org.apache.skywalking.apm.agent.core.context.CarrierItem) URI(java.net.URI) AbstractSpan(org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan)

Example 55 with AbstractSpan

use of org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan in project incubator-skywalking by apache.

the class SuccessCallbackInterceptor method beforeMethod.

@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
    Object[] cacheValues = (Object[]) objInst.getSkyWalkingDynamicField();
    if (cacheValues == null) {
        return;
    }
    URI uri = (URI) cacheValues[0];
    AbstractSpan span = ContextManager.createLocalSpan("future/successCallback:" + uri.getPath());
    span.setComponent(ComponentsDefine.SPRING_REST_TEMPLATE).setLayer(SpanLayer.HTTP);
    Tags.URL.set(span, uri.getPath());
    ContextManager.continued((ContextSnapshot) cacheValues[2]);
}
Also used : URI(java.net.URI) AbstractSpan(org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan)

Aggregations

AbstractSpan (org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan)141 ContextCarrier (org.apache.skywalking.apm.agent.core.context.ContextCarrier)36 CarrierItem (org.apache.skywalking.apm.agent.core.context.CarrierItem)29 URI (java.net.URI)7 AbstractTracingSpan (org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan)7 TraceSegment (org.apache.skywalking.apm.agent.core.context.trace.TraceSegment)7 ConnectionInfo (org.apache.skywalking.apm.plugin.jdbc.trace.ConnectionInfo)7 HttpServletResponse (javax.servlet.http.HttpServletResponse)6 StatementEnhanceInfos (org.apache.skywalking.apm.plugin.jdbc.define.StatementEnhanceInfos)6 Invocation (io.servicecomb.core.Invocation)5 HttpServletRequest (javax.servlet.http.HttpServletRequest)5 Invocation (org.apache.servicecomb.core.Invocation)5 SQLException (java.sql.SQLException)4 Metadata (io.grpc.Metadata)3 Field (java.lang.reflect.Field)3 List (java.util.List)3 TraceSegmentRef (org.apache.skywalking.apm.agent.core.context.trace.TraceSegmentRef)3 EnhancedInstance (org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance)3 Request (com.weibo.api.motan.rpc.Request)2 Response (com.weibo.api.motan.rpc.Response)2