use of org.apache.skywalking.apm.plugin.spring.mvc.commons.EnhanceRequireObjectCache in project incubator-skywalking by apache.
the class ControllerConstructorInterceptorTest method testOnConstruct_Accuracy1.
@Test
public void testOnConstruct_Accuracy1() throws Throwable {
controllerConstructorInterceptor.onConstruct(inst1, null);
EnhanceRequireObjectCache cache = (EnhanceRequireObjectCache) inst1.getSkyWalkingDynamicField();
Assert.assertNotNull(cache);
Object obj = new Object();
Method m = obj.getClass().getMethods()[0];
cache.addPathMapping(m, "#toString");
Assert.assertEquals("the two value should be equal", cache.findPathMapping(m), "/test1#toString");
}
use of org.apache.skywalking.apm.plugin.spring.mvc.commons.EnhanceRequireObjectCache in project incubator-skywalking by apache.
the class ControllerConstructorInterceptorTest method testOnConstruct_Accuracy2.
@Test
public void testOnConstruct_Accuracy2() throws Throwable {
controllerConstructorInterceptor.onConstruct(inst2, null);
EnhanceRequireObjectCache cache = (EnhanceRequireObjectCache) inst2.getSkyWalkingDynamicField();
Assert.assertNotNull(cache);
Object obj = new Object();
Method m = obj.getClass().getMethods()[0];
cache.addPathMapping(m, "#toString");
Assert.assertEquals("the two value should be equal", cache.findPathMapping(m), "#toString");
}
use of org.apache.skywalking.apm.plugin.spring.mvc.commons.EnhanceRequireObjectCache in project incubator-skywalking by apache.
the class AbstractMethodInterceptor method afterMethod.
@Override
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, Object ret) throws Throwable {
try {
HttpServletResponse response = ((EnhanceRequireObjectCache) objInst.getSkyWalkingDynamicField()).getHttpServletResponse();
AbstractSpan span = ContextManager.activeSpan();
if (response.getStatus() >= 400) {
span.errorOccurred();
Tags.STATUS_CODE.set(span, Integer.toString(response.getStatus()));
}
ContextManager.stopSpan();
return ret;
} finally {
((EnhanceRequireObjectCache) objInst.getSkyWalkingDynamicField()).clearRequestAndResponse();
}
}
Aggregations