use of org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan in project incubator-skywalking by apache.
the class StreamCallClientInterceptor method start.
@Override
public void start(Listener responseListener, Metadata headers) {
final ContextCarrier contextCarrier = new ContextCarrier();
final AbstractSpan span = ContextManager.createExitSpan(serviceName, contextCarrier, remotePeer);
span.setComponent(ComponentsDefine.GRPC);
SpanLayer.asRPCFramework(span);
CarrierItem contextItem = contextCarrier.items();
while (contextItem.hasNext()) {
contextItem = contextItem.next();
Metadata.Key<String> headerKey = Metadata.Key.of(contextItem.getHeadKey(), Metadata.ASCII_STRING_MARSHALLER);
headers.put(headerKey, contextItem.getHeadValue());
}
delegate().start(new CallListener(responseListener, ContextManager.capture()), headers);
ContextManager.stopSpan();
}
use of org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan in project incubator-skywalking by apache.
the class HttpClientExecuteInterceptor method afterMethod.
@Override
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, Object ret) throws Throwable {
if (allArguments[0] == null || allArguments[1] == null) {
return ret;
}
HttpResponse response = (HttpResponse) ret;
StatusLine responseStatusLine = response.getStatusLine();
if (responseStatusLine != null) {
int statusCode = responseStatusLine.getStatusCode();
AbstractSpan span = ContextManager.activeSpan();
if (statusCode >= 400) {
span.errorOccurred();
Tags.STATUS_CODE.set(span, Integer.toString(statusCode));
}
}
ContextManager.stopSpan();
return ret;
}
use of org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan in project incubator-skywalking by apache.
the class HttpClientExecuteInterceptor method beforeMethod.
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
if (allArguments[0] == null || allArguments[1] == null) {
// illegal args, can't trace. ignore.
return;
}
final HttpHost httpHost = (HttpHost) allArguments[0];
HttpRequest httpRequest = (HttpRequest) allArguments[1];
final ContextCarrier contextCarrier = new ContextCarrier();
AbstractSpan span = null;
String remotePeer = httpHost.getHostName() + ":" + (httpHost.getPort() > 0 ? httpHost.getPort() : "https".equals(httpHost.getSchemeName().toLowerCase()) ? 443 : 80);
try {
URL url = new URL(httpRequest.getRequestLine().getUri());
span = ContextManager.createExitSpan(url.getPath(), contextCarrier, remotePeer);
} catch (MalformedURLException e) {
throw e;
}
span.setComponent(ComponentsDefine.HTTPCLIENT);
Tags.URL.set(span, httpRequest.getRequestLine().getUri());
Tags.HTTP.METHOD.set(span, httpRequest.getRequestLine().getMethod());
SpanLayer.asHttp(span);
CarrierItem next = contextCarrier.items();
while (next.hasNext()) {
next = next.next();
httpRequest.setHeader(next.getHeadKey(), next.getHeadValue());
}
}
use of org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan in project incubator-skywalking by apache.
the class HttpClientExecuteInterceptor method handleMethodException.
@Override
public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, Throwable t) {
AbstractSpan activeSpan = ContextManager.activeSpan();
activeSpan.errorOccurred();
activeSpan.log(t);
}
use of org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan in project incubator-skywalking by apache.
the class DefaultConnectingIOReactorIterceptor method beforeMethod.
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
Object[] cacheValue = (Object[]) objInst.getSkyWalkingDynamicField();
final ContextCarrier contextCarrier = new ContextCarrier();
AbstractSpan span = ContextManager.createExitSpan("httpasyncclient/" + method.getName(), contextCarrier, cacheValue[1].toString());
ContextManager.continued((ContextSnapshot) cacheValue[0]);
span.setComponent(ComponentsDefine.HTTP_ASYNC_CLIENT).setLayer(SpanLayer.HTTP);
}
Aggregations