use of com.navercorp.pinpoint.bootstrap.context.TraceContext in project pinpoint by naver.
the class InvokeMethodInterceptorTest method testValidHeaderExists.
@Test
public void testValidHeaderExists() {
when(request.getRequestURI()).thenReturn("/hellotest.nhn");
when(request.getRemoteAddr()).thenReturn("10.0.0.1");
TraceId traceId = new DefaultTraceId("agentTest", System.currentTimeMillis(), 1);
when(request.getHeader(Header.HTTP_TRACE_ID.toString())).thenReturn(traceId.getTransactionId());
when(request.getHeader(Header.HTTP_PARENT_SPAN_ID.toString())).thenReturn("PARENTSPANID");
when(request.getHeader(Header.HTTP_SPAN_ID.toString())).thenReturn("SPANID");
when(request.getHeader(Header.HTTP_SAMPLED.toString())).thenReturn("false");
when(request.getHeader(Header.HTTP_FLAGS.toString())).thenReturn("0");
Enumeration<?> enumeration = mock(Enumeration.class);
when(request.getParameterNames()).thenReturn(enumeration);
TraceContext traceContext = spyTraceContext();
StandardHostValveInvokeInterceptor interceptor = new StandardHostValveInvokeInterceptor(traceContext, descriptor);
interceptor.before("target", new Object[] { request, response });
interceptor.after("target", new Object[] { request, response }, new Object(), null);
verify(traceContext, times(1)).continueTraceObject(any(TraceId.class));
interceptor.before("target", new Object[] { request, response });
interceptor.after("target", new Object[] { request, response }, new Object(), null);
verify(traceContext, times(2)).continueTraceObject(any(TraceId.class));
}
use of com.navercorp.pinpoint.bootstrap.context.TraceContext in project pinpoint by naver.
the class InvokeMethodInterceptorTest method testInvalidHeaderExists.
@Test
public void testInvalidHeaderExists() {
when(request.getRequestURI()).thenReturn("/hellotest.nhn");
when(request.getRemoteAddr()).thenReturn("10.0.0.1");
when(request.getHeader(Header.HTTP_TRACE_ID.toString())).thenReturn("TRACEID");
when(request.getHeader(Header.HTTP_PARENT_SPAN_ID.toString())).thenReturn("PARENTSPANID");
when(request.getHeader(Header.HTTP_SPAN_ID.toString())).thenReturn("SPANID");
when(request.getHeader(Header.HTTP_SAMPLED.toString())).thenReturn("false");
when(request.getHeader(Header.HTTP_FLAGS.toString())).thenReturn("0");
Enumeration<?> enumeration = mock(Enumeration.class);
when(request.getParameterNames()).thenReturn(enumeration);
TraceContext traceContext = spyTraceContext();
StandardHostValveInvokeInterceptor interceptor = new StandardHostValveInvokeInterceptor(traceContext, descriptor);
interceptor.before("target", new Object[] { request, response });
interceptor.after("target", new Object[] { request, response }, new Object(), null);
verify(traceContext, never()).newTraceObject();
verify(traceContext, never()).disableSampling();
verify(traceContext, never()).continueTraceObject(any(TraceId.class));
interceptor.before("target", new Object[] { request, response });
interceptor.after("target", new Object[] { request, response }, new Object(), null);
verify(traceContext, never()).newTraceObject();
verify(traceContext, never()).disableSampling();
verify(traceContext, never()).continueTraceObject(any(TraceId.class));
}
use of com.navercorp.pinpoint.bootstrap.context.TraceContext in project pinpoint by naver.
the class InvokeMethodInterceptorTest method spyTraceContext.
private TraceContext spyTraceContext() {
ProfilerConfig profilerConfig = new DefaultProfilerConfig();
TraceContext traceContext = MockTraceContextFactory.newTestTraceContext(profilerConfig);
return spy(traceContext);
}
use of com.navercorp.pinpoint.bootstrap.context.TraceContext in project pinpoint by naver.
the class PluginTestAgent method initialize.
@Override
public void initialize(boolean createTraceObject) {
if (createTraceObject) {
final TraceContext traceContext = getTraceContext();
traceContext.newTraceObject();
}
getRecorder().clear();
getTestTcpDataSender().clear();
ignoredServiceTypes.clear();
}
use of com.navercorp.pinpoint.bootstrap.context.TraceContext in project pinpoint by naver.
the class PluginTestAgent method cleanUp.
@Override
public void cleanUp(boolean detachTraceObject) {
if (detachTraceObject) {
final TraceContext traceContext = getTraceContext();
traceContext.removeTraceObject();
}
getRecorder().clear();
getTestTcpDataSender().clear();
ignoredServiceTypes.clear();
}
Aggregations