use of org.apache.skywalking.apm.agent.core.context.ContextCarrier in project incubator-skywalking by apache.
the class SkywalkingTracerExtractInterceptor method afterMethod.
@Override
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, Object ret) throws Throwable {
Format format = (Format) allArguments[0];
if (Format.Builtin.TEXT_MAP.equals(format) || Format.Builtin.HTTP_HEADERS.equals(format)) {
TextMap textMapCarrier = (TextMap) allArguments[1];
ContextCarrier contextCarrier = new ContextCarrier();
CarrierItem next = contextCarrier.items();
while (next.hasNext()) {
next = next.next();
Iterator<Map.Entry<String, String>> iterator = textMapCarrier.iterator();
while (iterator.hasNext()) {
Map.Entry<String, String> entry = iterator.next();
if (next.getHeadKey().equals(entry.getKey())) {
next.setHeadValue(entry.getValue());
break;
}
}
}
ContextManager.extract(contextCarrier);
}
return new SkywalkingContext();
}
use of org.apache.skywalking.apm.agent.core.context.ContextCarrier in project incubator-skywalking by apache.
the class Struts2Interceptor method beforeMethod.
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
HttpServletRequest request = ServletActionContext.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(request.getRequestURI(), contextCarrier);
Tags.URL.set(span, request.getRequestURL().toString());
Tags.HTTP.METHOD.set(span, request.getMethod());
span.setComponent(ComponentsDefine.STRUTS2);
SpanLayer.asHttp(span);
}
use of org.apache.skywalking.apm.agent.core.context.ContextCarrier in project incubator-skywalking by apache.
the class RestRequestInterceptor method afterMethod.
@Override
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, Object ret) throws Throwable {
AsyncClientHttpRequest clientHttpRequest = (AsyncClientHttpRequest) ret;
if (ret != null) {
Object[] cacheValues = (Object[]) objInst.getSkyWalkingDynamicField();
ContextCarrier contextCarrier = (ContextCarrier) cacheValues[1];
CarrierItem next = contextCarrier.items();
while (next.hasNext()) {
next = next.next();
clientHttpRequest.getHeaders().set(next.getHeadKey(), next.getHeadValue());
}
}
return ret;
}
use of org.apache.skywalking.apm.agent.core.context.ContextCarrier in project incubator-skywalking by apache.
the class ProducerOperationHandlerInterceptor method beforeMethod.
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
Invocation invocation = (Invocation) allArguments[0];
ContextCarrier contextCarrier = new ContextCarrier();
CarrierItem next = contextCarrier.items();
while (next.hasNext()) {
next = next.next();
next.setHeadValue(invocation.getContext().get(next.getHeadKey()));
}
String operationName = invocation.getMicroserviceQualifiedName();
AbstractSpan span = ContextManager.createEntrySpan(operationName, contextCarrier);
String url = invocation.getOperationMeta().getOperationPath();
Tags.URL.set(span, url);
span.setComponent(ComponentsDefine.SERVICECOMB);
SpanLayer.asRPCFramework(span);
}
use of org.apache.skywalking.apm.agent.core.context.ContextCarrier in project incubator-skywalking by apache.
the class ProducerOperationHandlerInterceptor method beforeMethod.
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
Invocation invocation = (Invocation) allArguments[0];
ContextCarrier contextCarrier = new ContextCarrier();
CarrierItem next = contextCarrier.items();
while (next.hasNext()) {
next = next.next();
next.setHeadValue(invocation.getContext().get(next.getHeadKey()));
}
String operationName = invocation.getMicroserviceQualifiedName();
AbstractSpan span = ContextManager.createEntrySpan(operationName, contextCarrier);
String url = invocation.getOperationMeta().getOperationPath();
Tags.URL.set(span, url);
span.setComponent(ComponentsDefine.SERVICECOMB);
SpanLayer.asRPCFramework(span);
}
Aggregations