Search in sources :

Example 6 with TraceContext

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);
}
Also used : ProfilerConfig(com.navercorp.pinpoint.bootstrap.config.ProfilerConfig) DefaultProfilerConfig(com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig) DefaultProfilerConfig(com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig) TraceContext(com.navercorp.pinpoint.bootstrap.context.TraceContext)

Example 7 with TraceContext

use of com.navercorp.pinpoint.bootstrap.context.TraceContext in project pinpoint by naver.

the class SpanSimpleAroundInterceptorTest method traceCreateFail.

@Test
public void traceCreateFail() {
    TraceContext context = mock(TraceContext.class);
    when(context.newTraceObject()).thenReturn(null);
    TestSpanSimpleAroundInterceptor interceptor = new TestSpanSimpleAroundInterceptor(context);
    checkTraceCreateFailInterceptor(context, interceptor);
}
Also used : TraceContext(com.navercorp.pinpoint.bootstrap.context.TraceContext) Test(org.junit.Test)

Example 8 with TraceContext

use of com.navercorp.pinpoint.bootstrap.context.TraceContext in project pinpoint by naver.

the class SpanSimpleAroundInterceptorTest method afterExceptionLifeCycle.

@Test
public void afterExceptionLifeCycle() throws Exception {
    Trace trace = newTrace();
    TraceContext context = newTraceContext(trace);
    TestSpanSimpleAroundInterceptor interceptor = new TestSpanSimpleAroundInterceptor(context) {

        @Override
        protected void doInAfterTrace(SpanRecorder trace, Object target, Object[] args, Object result, Throwable throwable) {
            touchAfter();
            throw new RuntimeException();
        }
    };
    checkSpanInterceptor(context, interceptor);
}
Also used : Trace(com.navercorp.pinpoint.bootstrap.context.Trace) SpanRecorder(com.navercorp.pinpoint.bootstrap.context.SpanRecorder) TraceContext(com.navercorp.pinpoint.bootstrap.context.TraceContext) Test(org.junit.Test)

Example 9 with TraceContext

use of com.navercorp.pinpoint.bootstrap.context.TraceContext in project pinpoint by naver.

the class SpanSimpleAroundInterceptorTest method lifeCycle.

@Test
public void lifeCycle() throws Exception {
    Trace trace = newTrace();
    TraceContext context = newTraceContext(trace);
    TestSpanSimpleAroundInterceptor interceptor = new TestSpanSimpleAroundInterceptor(context);
    checkSpanInterceptor(context, interceptor);
}
Also used : Trace(com.navercorp.pinpoint.bootstrap.context.Trace) TraceContext(com.navercorp.pinpoint.bootstrap.context.TraceContext) Test(org.junit.Test)

Example 10 with TraceContext

use of com.navercorp.pinpoint.bootstrap.context.TraceContext in project pinpoint by naver.

the class DriverConnectInterceptorTest method driverConnect.

@Test
public void driverConnect() throws SQLException {
    TraceContext traceContext = mock(TraceContext.class);
    MethodDescriptor methodDescriptor = mock(MethodDescriptor.class);
    JdbcUrlParser parser = mock(JdbcUrlParser.class);
    when(parser.parse(anyString())).thenReturn(UnKnownDatabaseInfo.INSTANCE);
    String invalidJdbcUrl = "invalidUrl";
    Driver driver = mock(Driver.class);
    DatabaseInfoAccessor setAccessor = mock(DatabaseInfoAccessor.class);
    DatabaseInfoAccessor getAccessor = mock(DatabaseInfoAccessor.class);
    SpanEventRecorder spanEventRecorder = mock(SpanEventRecorder.class);
    DriverConnectInterceptor driverConnectInterceptor = new DriverConnectInterceptor(traceContext, methodDescriptor, parser);
    driverConnectInterceptor.prepareAfterTrace(driver, va(invalidJdbcUrl), setAccessor, null);
    driverConnectInterceptor.doInAfterTrace(spanEventRecorder, driver, va(invalidJdbcUrl), getAccessor, null);
    verify(setAccessor, times(1))._$PINPOINT$_setDatabaseInfo(UnKnownDatabaseInfo.INSTANCE);
    verify(getAccessor, times(1))._$PINPOINT$_getDatabaseInfo();
}
Also used : JdbcUrlParser(com.navercorp.pinpoint.bootstrap.plugin.jdbc.JdbcUrlParser) DatabaseInfoAccessor(com.navercorp.pinpoint.bootstrap.plugin.jdbc.DatabaseInfoAccessor) SpanEventRecorder(com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder) TraceContext(com.navercorp.pinpoint.bootstrap.context.TraceContext) Driver(java.sql.Driver) Matchers.anyString(org.mockito.Matchers.anyString) MethodDescriptor(com.navercorp.pinpoint.bootstrap.context.MethodDescriptor) Test(org.junit.Test)

Aggregations

TraceContext (com.navercorp.pinpoint.bootstrap.context.TraceContext)25 Test (org.junit.Test)17 Trace (com.navercorp.pinpoint.bootstrap.context.Trace)8 DefaultProfilerConfig (com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig)5 ProfilerConfig (com.navercorp.pinpoint.bootstrap.config.ProfilerConfig)5 DefaultTraceId (com.navercorp.pinpoint.profiler.context.id.DefaultTraceId)5 SpanRecorder (com.navercorp.pinpoint.bootstrap.context.SpanRecorder)4 TraceId (com.navercorp.pinpoint.bootstrap.context.TraceId)4 MethodDescriptor (com.navercorp.pinpoint.bootstrap.context.MethodDescriptor)3 StandardHostValveInvokeInterceptor (com.navercorp.pinpoint.plugin.jboss.interceptor.StandardHostValveInvokeInterceptor)3 StandardHostValveInvokeInterceptor (com.navercorp.pinpoint.plugin.tomcat.interceptor.StandardHostValveInvokeInterceptor)3 SpanEventRecorder (com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder)2 JdbcUrlParser (com.navercorp.pinpoint.bootstrap.plugin.jdbc.JdbcUrlParser)2 Driver (java.sql.Driver)2 Matchers.anyString (org.mockito.Matchers.anyString)2 InstrumentClass (com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass)1 InstrumentContext (com.navercorp.pinpoint.bootstrap.instrument.InstrumentContext)1 InstrumentMethod (com.navercorp.pinpoint.bootstrap.instrument.InstrumentMethod)1 DatabaseInfoAccessor (com.navercorp.pinpoint.bootstrap.plugin.jdbc.DatabaseInfoAccessor)1 DefaultTransactionCounter (com.navercorp.pinpoint.profiler.context.id.DefaultTransactionCounter)1