use of org.apache.skywalking.apm.agent.core.context.ContextCarrier 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);
}
use of org.apache.skywalking.apm.agent.core.context.ContextCarrier 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);
}
use of org.apache.skywalking.apm.agent.core.context.ContextCarrier in project incubator-skywalking by apache.
the class MongoDBMethodInterceptor method beforeMethod.
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
Object[] arguments = allArguments;
String executeMethod = arguments[0].getClass().getSimpleName();
String remotePeer = (String) objInst.getSkyWalkingDynamicField();
AbstractSpan span = ContextManager.createExitSpan(MONGO_DB_OP_PREFIX + executeMethod, new ContextCarrier(), remotePeer);
span.setComponent(ComponentsDefine.MONGODB);
Tags.DB_TYPE.set(span, DB_TYPE);
SpanLayer.asDB(span);
if (Config.Plugin.MongoDB.TRACE_PARAM) {
Tags.DB_STATEMENT.set(span, executeMethod + " " + this.getTraceParam(arguments[0]));
}
}
use of org.apache.skywalking.apm.agent.core.context.ContextCarrier in project incubator-skywalking by apache.
the class MotanProviderInterceptor method beforeMethod.
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
Request request = (Request) allArguments[0];
ContextCarrier contextCarrier = new ContextCarrier();
CarrierItem next = contextCarrier.items();
while (next.hasNext()) {
next = next.next();
next.setHeadValue(request.getAttachments().get(next.getHeadKey()));
}
AbstractSpan span = ContextManager.createEntrySpan(generateViewPoint(request), contextCarrier);
SpanLayer.asRPCFramework(span);
span.setComponent(ComponentsDefine.MOTAN);
}
use of org.apache.skywalking.apm.agent.core.context.ContextCarrier 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());
}
}
}
Aggregations