use of org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan in project incubator-skywalking by apache.
the class MotanConsumerInterceptor method beforeMethod.
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
URL url = (URL) objInst.getSkyWalkingDynamicField();
Request request = (Request) allArguments[0];
if (url != null) {
ContextCarrier contextCarrier = new ContextCarrier();
String remotePeer = url.getHost() + ":" + url.getPort();
AbstractSpan span = ContextManager.createExitSpan(generateOperationName(url, request), contextCarrier, remotePeer);
span.setComponent(ComponentsDefine.MOTAN);
Tags.URL.set(span, url.getIdentity());
SpanLayer.asRPCFramework(span);
CarrierItem next = contextCarrier.items();
while (next.hasNext()) {
next = next.next();
request.setAttachment(next.getHeadKey(), next.getHeadValue());
}
}
}
use of org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan in project incubator-skywalking by apache.
the class MotanConsumerInterceptor method afterMethod.
@Override
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, Object ret) throws Throwable {
Response response = (Response) ret;
if (response != null && response.getException() != null) {
AbstractSpan span = ContextManager.activeSpan();
span.errorOccurred();
span.log(response.getException());
}
ContextManager.stopSpan();
return ret;
}
use of org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan in project incubator-skywalking by apache.
the class SyncHttpRequestSendInterceptor method beforeMethod.
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
HttpRequest request = (HttpRequest) objInst;
ContextCarrier contextCarrier = new ContextCarrier();
AbstractSpan span = ContextManager.createExitSpan(request.getURI().getPath(), contextCarrier, request.getHost() + ":" + request.getPort());
span.setComponent(ComponentsDefine.JETTY_CLIENT);
Tags.HTTP.METHOD.set(span, getHttpMethod(request));
Tags.URL.set(span, request.getURI().toString());
SpanLayer.asHttp(span);
CarrierItem next = contextCarrier.items();
HttpFields field = request.getHeaders();
while (next.hasNext()) {
next = next.next();
field.add(next.getHeadKey(), next.getHeadValue());
}
}
use of org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan in project incubator-skywalking by apache.
the class HandleInterceptor method beforeMethod.
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
HttpChannel httpChannel = (HttpChannel) allArguments[0];
HttpServletRequest servletRequest = httpChannel.getRequest();
ContextCarrier contextCarrier = new ContextCarrier();
CarrierItem next = contextCarrier.items();
while (next.hasNext()) {
next = next.next();
next.setHeadValue(servletRequest.getHeader(next.getHeadKey()));
}
AbstractSpan span = ContextManager.createEntrySpan(servletRequest.getRequestURI(), contextCarrier);
Tags.URL.set(span, servletRequest.getRequestURL().toString());
Tags.HTTP.METHOD.set(span, servletRequest.getMethod());
span.setComponent(ComponentsDefine.JETTY_SERVER);
SpanLayer.asHttp(span);
}
use of org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan in project incubator-skywalking by apache.
the class HandleInterceptor method afterMethod.
@Override
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, Object ret) throws Throwable {
HttpChannel httpChannel = (HttpChannel) allArguments[0];
HttpServletResponse servletResponse = httpChannel.getResponse();
AbstractSpan span = ContextManager.activeSpan();
if (servletResponse.getStatus() >= 400) {
span.errorOccurred();
Tags.STATUS_CODE.set(span, Integer.toString(servletResponse.getStatus()));
}
ContextManager.stopSpan();
return ret;
}
Aggregations