Search in sources :

Example 6 with ApiMetaDataService

use of com.navercorp.pinpoint.profiler.metadata.ApiMetaDataService in project pinpoint by naver.

the class JavassistEngineTest method newJavassistEngine.

private InstrumentEngine newJavassistEngine() {
    Instrumentation instrumentation = mock(Instrumentation.class);
    ObjectBinderFactory objectBinderFactory = mock(ObjectBinderFactory.class);
    Provider<ApiMetaDataService> apiMetaDataService = Providers.of(mock(ApiMetaDataService.class));
    InterceptorRegistryBinder binder = new TestInterceptorRegistryBinder();
    return new JavassistEngine(instrumentation, objectBinderFactory, binder, apiMetaDataService, null);
}
Also used : TestInterceptorRegistryBinder(com.navercorp.pinpoint.profiler.util.TestInterceptorRegistryBinder) InterceptorRegistryBinder(com.navercorp.pinpoint.profiler.interceptor.registry.InterceptorRegistryBinder) TestInterceptorRegistryBinder(com.navercorp.pinpoint.profiler.util.TestInterceptorRegistryBinder) Instrumentation(java.lang.instrument.Instrumentation) ObjectBinderFactory(com.navercorp.pinpoint.profiler.objectfactory.ObjectBinderFactory) ApiMetaDataService(com.navercorp.pinpoint.profiler.metadata.ApiMetaDataService)

Example 7 with ApiMetaDataService

use of com.navercorp.pinpoint.profiler.metadata.ApiMetaDataService in project pinpoint by naver.

the class ObjectBinderFactory method newInterceptorArgumentProvider.

public InterceptorArgumentProvider newInterceptorArgumentProvider(InstrumentClass instrumentClass) {
    ApiMetaDataService apiMetaDataService = this.apiMetaDataServiceProvider.get();
    UriStatRecorderFactory uriStatRecorderFactory = uriStatRecorderFactoryProvider.get();
    return new InterceptorArgumentProvider(dataSourceMonitorRegistry, customMetricRegistry, apiMetaDataService, requestRecorderFactory, uriStatRecorderFactory, instrumentClass);
}
Also used : UriStatRecorderFactory(com.navercorp.pinpoint.bootstrap.plugin.uri.UriStatRecorderFactory) ApiMetaDataService(com.navercorp.pinpoint.profiler.metadata.ApiMetaDataService)

Example 8 with ApiMetaDataService

use of com.navercorp.pinpoint.profiler.metadata.ApiMetaDataService in project pinpoint by naver.

the class ObjectBinderFactory method newAnnotatedInterceptorFactory.

public AnnotatedInterceptorFactory newAnnotatedInterceptorFactory(InstrumentContext pluginContext) {
    final TraceContext traceContext = this.traceContextProvider.get();
    ApiMetaDataService apiMetaDataService = this.apiMetaDataServiceProvider.get();
    UriStatRecorderFactory uriStatRecorderFactory = uriStatRecorderFactoryProvider.get();
    return new AnnotatedInterceptorFactory(profilerConfig, traceContext, dataSourceMonitorRegistry, customMetricRegistry, apiMetaDataService, pluginContext, exceptionHandlerFactory, requestRecorderFactory, uriStatRecorderFactory);
}
Also used : UriStatRecorderFactory(com.navercorp.pinpoint.bootstrap.plugin.uri.UriStatRecorderFactory) TraceContext(com.navercorp.pinpoint.bootstrap.context.TraceContext) ApiMetaDataService(com.navercorp.pinpoint.profiler.metadata.ApiMetaDataService) AnnotatedInterceptorFactory(com.navercorp.pinpoint.profiler.interceptor.factory.AnnotatedInterceptorFactory)

Example 9 with ApiMetaDataService

use of com.navercorp.pinpoint.profiler.metadata.ApiMetaDataService in project pinpoint by naver.

the class InvokeAfterCodeGeneratorTest method testGenerate_AroundInterceptor3_catchClause.

@Test
public void testGenerate_AroundInterceptor3_catchClause() {
    final Class<AroundInterceptor3> aroundInterceptor3Class = AroundInterceptor3.class;
    final InterceptorDefinition interceptorDefinition = interceptorDefinitionFactory.createInterceptorDefinition(aroundInterceptor3Class);
    final InstrumentClass mockClass = mock(InstrumentClass.class);
    Mockito.when(mockClass.getName()).thenReturn("TestClass");
    final InstrumentMethod mockMethod = mock(InstrumentMethod.class);
    Mockito.when(mockMethod.getName()).thenReturn("TestMethod");
    Mockito.when(mockMethod.getParameterTypes()).thenReturn(new String[] { "java.lang.Object", "java.lang.Object", "java.lang.Object" });
    Mockito.when(mockMethod.getReturnType()).thenReturn("java.lang.Object");
    ApiMetaDataService apiMetaDataService = mock(ApiMetaDataService.class);
    final InvokeAfterCodeGenerator invokeAfterCodeGenerator = new InvokeAfterCodeGenerator(100, interceptorDefinition, mockClass, mockMethod, apiMetaDataService, false, true);
    final String generate = invokeAfterCodeGenerator.generate();
    logger.debug("testGenerate_AroundInterceptor3_catchClause:{}", generate);
    Assert.assertTrue(generate.contains("($w)$1"));
    Assert.assertTrue(generate.contains("($w)$2"));
    Assert.assertTrue(generate.contains("($w)$3"));
    Assert.assertTrue(generate.contains("$e"));
}
Also used : AroundInterceptor3(com.navercorp.pinpoint.bootstrap.interceptor.AroundInterceptor3) InstrumentClass(com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass) InstrumentMethod(com.navercorp.pinpoint.bootstrap.instrument.InstrumentMethod) ApiMetaDataService(com.navercorp.pinpoint.profiler.metadata.ApiMetaDataService) Test(org.junit.Test)

Example 10 with ApiMetaDataService

use of com.navercorp.pinpoint.profiler.metadata.ApiMetaDataService in project pinpoint by naver.

the class InvokeAfterCodeGeneratorTest method testGenerate_AroundInterceptor3_methodParam4.

@Test
public void testGenerate_AroundInterceptor3_methodParam4() {
    final Class<AroundInterceptor3> aroundInterceptor3Class = AroundInterceptor3.class;
    final InterceptorDefinition interceptorDefinition = interceptorDefinitionFactory.createInterceptorDefinition(aroundInterceptor3Class);
    final InstrumentClass mockClass = mock(InstrumentClass.class);
    Mockito.when(mockClass.getName()).thenReturn("TestClass");
    final InstrumentMethod mockMethod = mock(InstrumentMethod.class);
    Mockito.when(mockMethod.getName()).thenReturn("TestMethod");
    Mockito.when(mockMethod.getParameterTypes()).thenReturn(new String[] { "java.lang.Object", "java.lang.Object", "java.lang.Object", "java.lang.Object" });
    Mockito.when(mockMethod.getReturnType()).thenReturn("java.lang.Object");
    ApiMetaDataService apiMetaDataService = mock(ApiMetaDataService.class);
    final InvokeAfterCodeGenerator invokeAfterCodeGenerator = new InvokeAfterCodeGenerator(100, interceptorDefinition, mockClass, mockMethod, apiMetaDataService, false, true);
    final String generate = invokeAfterCodeGenerator.generate();
    logger.debug("testGenerate_AroundInterceptor3_methodParam4:{}", generate);
    Assert.assertTrue(generate.contains("($w)$1"));
    Assert.assertTrue(generate.contains("($w)$2"));
    Assert.assertTrue(generate.contains("($w)$3"));
    Assert.assertFalse(generate.contains("($w)$4"));
    Assert.assertTrue(generate.contains("$e"));
}
Also used : AroundInterceptor3(com.navercorp.pinpoint.bootstrap.interceptor.AroundInterceptor3) InstrumentClass(com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass) InstrumentMethod(com.navercorp.pinpoint.bootstrap.instrument.InstrumentMethod) ApiMetaDataService(com.navercorp.pinpoint.profiler.metadata.ApiMetaDataService) Test(org.junit.Test)

Aggregations

ApiMetaDataService (com.navercorp.pinpoint.profiler.metadata.ApiMetaDataService)12 InstrumentClass (com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass)5 InstrumentMethod (com.navercorp.pinpoint.bootstrap.instrument.InstrumentMethod)5 Test (org.junit.Test)5 AroundInterceptor3 (com.navercorp.pinpoint.bootstrap.interceptor.AroundInterceptor3)4 TraceContext (com.navercorp.pinpoint.bootstrap.context.TraceContext)2 UriStatRecorderFactory (com.navercorp.pinpoint.bootstrap.plugin.uri.UriStatRecorderFactory)2 AnnotatedInterceptorFactory (com.navercorp.pinpoint.profiler.interceptor.factory.AnnotatedInterceptorFactory)2 ObjectBinderFactory (com.navercorp.pinpoint.profiler.objectfactory.ObjectBinderFactory)2 Instrumentation (java.lang.instrument.Instrumentation)2 NotFoundInstrumentException (com.navercorp.pinpoint.bootstrap.instrument.NotFoundInstrumentException)1 AroundInterceptor0 (com.navercorp.pinpoint.bootstrap.interceptor.AroundInterceptor0)1 JavassistEngine (com.navercorp.pinpoint.profiler.instrument.JavassistEngine)1 GlobalInterceptorRegistryBinder (com.navercorp.pinpoint.profiler.interceptor.registry.GlobalInterceptorRegistryBinder)1 InterceptorRegistryBinder (com.navercorp.pinpoint.profiler.interceptor.registry.InterceptorRegistryBinder)1 TestInterceptorRegistryBinder (com.navercorp.pinpoint.profiler.util.TestInterceptorRegistryBinder)1 ClassReader (org.objectweb.asm.ClassReader)1 ClassNode (org.objectweb.asm.tree.ClassNode)1