Search in sources :

Example 1 with InterfaceInternalNameMatcherOperand

use of com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.InterfaceInternalNameMatcherOperand in project pinpoint by naver.

the class DefaultMultiClassBasedMatcherTest method getMatcherOperandWithMultiClassNameAndAdditional.

@Test
public void getMatcherOperandWithMultiClassNameAndAdditional() {
    // (class OR class) AND interface
    InterfaceInternalNameMatcherOperand additional = new InterfaceInternalNameMatcherOperand("java/lang/Runnable", false);
    DefaultMultiClassBasedMatcher matcher = new DefaultMultiClassBasedMatcher(Arrays.asList("java.lang.String", "java.lang.Thread"), additional);
    assertTrue(matcher.getBaseClassNames().contains("java.lang.String"));
    assertTrue(matcher.getBaseClassNames().contains("java.lang.Thread"));
    MatcherOperand operand = matcher.getMatcherOperand();
    assertTrue(operand instanceof AndMatcherOperator);
    AndMatcherOperator operator = (AndMatcherOperator) operand;
    // (class OR class)
    assertTrue(operator.getLeftOperand() instanceof OrMatcherOperator);
    // ... AND interface
    assertTrue(operator.getRightOperand() instanceof InterfaceInternalNameMatcherOperand);
    InterfaceInternalNameMatcherOperand rightOperand = (InterfaceInternalNameMatcherOperand) operator.getRightOperand();
    assertEquals("java/lang/Runnable", rightOperand.getInterfaceInternalName());
}
Also used : InterfaceInternalNameMatcherOperand(com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.InterfaceInternalNameMatcherOperand) MatcherOperand(com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.MatcherOperand) ClassInternalNameMatcherOperand(com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.ClassInternalNameMatcherOperand) InterfaceInternalNameMatcherOperand(com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.InterfaceInternalNameMatcherOperand) AndMatcherOperator(com.navercorp.pinpoint.bootstrap.instrument.matcher.operator.AndMatcherOperator) OrMatcherOperator(com.navercorp.pinpoint.bootstrap.instrument.matcher.operator.OrMatcherOperator) Test(org.junit.Test)

Example 2 with InterfaceInternalNameMatcherOperand

use of com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.InterfaceInternalNameMatcherOperand in project pinpoint by naver.

the class DefaultPackageBasedMatcherTest method getMatcherOperandWithPackageNameAndAdditional.

@Test
public void getMatcherOperandWithPackageNameAndAdditional() {
    InterfaceInternalNameMatcherOperand additional = new InterfaceInternalNameMatcherOperand("java/lang/Runnable", false);
    PackageBasedMatcher packageBasedMatcher = new DefaultPackageBasedMatcher("java.lang", additional);
    assertEquals("java.lang", packageBasedMatcher.getBasePackageName());
    MatcherOperand operand = packageBasedMatcher.getMatcherOperand();
    assertTrue(operand instanceof AndMatcherOperator);
    AndMatcherOperator operator = (AndMatcherOperator) operand;
    assertTrue(operator.getLeftOperand() instanceof PackageInternalNameMatcherOperand);
    assertTrue(operator.getRightOperand() instanceof InterfaceInternalNameMatcherOperand);
}
Also used : InterfaceInternalNameMatcherOperand(com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.InterfaceInternalNameMatcherOperand) MatcherOperand(com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.MatcherOperand) PackageInternalNameMatcherOperand(com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.PackageInternalNameMatcherOperand) InterfaceInternalNameMatcherOperand(com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.InterfaceInternalNameMatcherOperand) AndMatcherOperator(com.navercorp.pinpoint.bootstrap.instrument.matcher.operator.AndMatcherOperator) PackageInternalNameMatcherOperand(com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.PackageInternalNameMatcherOperand) Test(org.junit.Test)

Example 3 with InterfaceInternalNameMatcherOperand

use of com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.InterfaceInternalNameMatcherOperand in project pinpoint by naver.

the class NotMatcherOperatorTest method base.

@Test
public void base() throws Exception {
    NotMatcherOperator operator = new NotMatcherOperator(new InterfaceInternalNameMatcherOperand("java/lang/Serializable", false));
    assertEquals(3, operator.getPrecedence());
    assertTrue(operator.isOperator());
    assertFalse(operator.isIndex());
    assertEquals(2, operator.getExecutionCost());
}
Also used : InterfaceInternalNameMatcherOperand(com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.InterfaceInternalNameMatcherOperand) Test(org.junit.Test)

Example 4 with InterfaceInternalNameMatcherOperand

use of com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.InterfaceInternalNameMatcherOperand in project pinpoint by naver.

the class ReactorNettyPlugin method setup.

@Override
public void setup(ProfilerPluginSetupContext context) {
    final ReactorNettyPluginConfig config = new ReactorNettyPluginConfig(context.getConfig());
    if (!config.isEnable()) {
        logger.info("{} disabled", this.getClass().getSimpleName());
        return;
    }
    logger.info("{} version range=[0.8.2.RELEASE, 1.0.4.RELEASE], config:{}", this.getClass().getSimpleName(), config);
    if (ServiceType.UNDEFINED.equals(context.getConfiguredApplicationType())) {
        final ReactorNettyDetector detector = new ReactorNettyDetector(config.getBootstrapMains());
        if (detector.detect()) {
            logger.info("Detected application type : {}", ReactorNettyConstants.REACTOR_NETTY);
            if (!context.registerApplicationType(ReactorNettyConstants.REACTOR_NETTY)) {
                logger.info("Application type [{}] already set, skipping [{}] registration.", context.getApplicationType(), ReactorNettyConstants.REACTOR_NETTY);
            }
        }
    }
    // HTTP server
    transformTemplate.transform("reactor.netty.http.server.HttpServerHandle", HttpServerHandleTransform.class);
    // over reactor-netty-1.0
    transformTemplate.transform("reactor.netty.http.server.HttpServer$HttpServerHandle", HttpServerHandleTransform.class);
    transformTemplate.transform("reactor.netty.channel.ChannelOperations", ChannelOperationsTransform.class);
    transformTemplate.transform("reactor.netty.http.server.HttpServerOperations", HttpServerOperationsTransform.class);
    // HTTP client
    if (Boolean.TRUE == config.isClientEnable()) {
        // over reactor-netty-1.0
        transformTemplate.transform("reactor.netty.http.client.HttpClientConnect", HttpClientConnectTransform.class);
        transformTemplate.transform("reactor.netty.http.client.HttpClientConnect$HttpTcpClient", HttpTcpClientTransform.class);
        transformTemplate.transform("reactor.netty.http.client.HttpClientConnect$HttpClientHandler", HttpClientHandleTransform.class);
        transformTemplate.transform("reactor.netty.http.client.HttpClientOperations", HttpClientOperationsTransform.class);
    }
    // Reactor
    final Matcher monoMatcher = Matchers.newPackageBasedMatcher("reactor.netty", new SuperClassInternalNameMatcherOperand("reactor.core.publisher.Mono", true));
    transformTemplate.transform(monoMatcher, FluxAndMonoTransform.class);
    final Matcher fluxMatcher = Matchers.newPackageBasedMatcher("reactor.netty", new SuperClassInternalNameMatcherOperand("reactor.core.publisher.Flux", true));
    transformTemplate.transform(fluxMatcher, FluxAndMonoTransform.class);
    final Matcher coreSubscriberMatcher = Matchers.newPackageBasedMatcher("reactor.netty", new InterfaceInternalNameMatcherOperand("reactor.core.CoreSubscriber", true));
    transformTemplate.transform(coreSubscriberMatcher, CoreSubscriberTransform.class);
}
Also used : InterfaceInternalNameMatcherOperand(com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.InterfaceInternalNameMatcherOperand) Matcher(com.navercorp.pinpoint.bootstrap.instrument.matcher.Matcher) SuperClassInternalNameMatcherOperand(com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.SuperClassInternalNameMatcherOperand)

Example 5 with InterfaceInternalNameMatcherOperand

use of com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.InterfaceInternalNameMatcherOperand in project pinpoint by naver.

the class DefaultTransformerMatcherTest method matchClass.

@Test
public void matchClass() throws Exception {
    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    InstrumentMatcherCacheConfig config = new DefaultInstrumentMatcherCacheConfig();
    TransformerMatcher matcher = new DefaultTransformerMatcher(config);
    InternalClassMetadata stringClassMetadata = readClassMetadata(classLoader, String.class.getName());
    InternalClassMetadata threadClassMetadata = readClassMetadata(classLoader, Thread.class.getName());
    InternalClassMetadata inputStreamClassMetadata = readClassMetadata(classLoader, InputStream.class.getName());
    MatcherOperand operand = null;
    // single operand.
    operand = new ClassInternalNameMatcherOperand("java/lang/String");
    boolean result = matcher.match(classLoader, operand, stringClassMetadata);
    assertTrue(result);
    // not matched.
    operand = new ClassInternalNameMatcherOperand("java/io/InputStream");
    result = matcher.match(classLoader, operand, stringClassMetadata);
    assertFalse(result);
    // and operator
    // package AND interface
    operand = new PackageInternalNameMatcherOperand("java/lang").and(new InterfaceInternalNameMatcherOperand("java/lang/Runnable", false));
    // java.lang.Thread
    result = matcher.match(classLoader, operand, threadClassMetadata);
    assertTrue(result);
    // java.lang.String
    result = matcher.match(classLoader, operand, stringClassMetadata);
    assertFalse(result);
    // or operator
    // package OR interface
    operand = new PackageInternalNameMatcherOperand("java/lang").or(new InterfaceInternalNameMatcherOperand("java/lang/Runnable", false));
    // java.lang.Thread
    result = matcher.match(classLoader, operand, threadClassMetadata);
    assertTrue(result);
    // java.lang.String
    result = matcher.match(classLoader, operand, stringClassMetadata);
    assertTrue(result);
    // not operator
    // NOT interface.
    operand = new InterfaceInternalNameMatcherOperand("java/lang/Runnable", false);
    operand = operand.not();
    // java.lang.Thread
    result = matcher.match(classLoader, operand, threadClassMetadata);
    assertFalse(result);
    // java.lang.String
    result = matcher.match(classLoader, operand, stringClassMetadata);
    assertTrue(result);
    // complex operator
    // (class or interface) AND (class or interface) ==> class, interface
    operand = new ClassInternalNameMatcherOperand("java/lang/String").or(new InterfaceInternalNameMatcherOperand("java/lang/Runnable", false));
    operand = operand.and(new ClassInternalNameMatcherOperand("java/lang/Thread").or(new InterfaceInternalNameMatcherOperand("java/lang/Comparable", false)));
    result = matcher.match(classLoader, operand, stringClassMetadata);
    assertTrue(result);
    result = matcher.match(classLoader, operand, threadClassMetadata);
    assertTrue(result);
    // (class AND interface) OR (class AND interface) ==> class, class
    operand = new ClassInternalNameMatcherOperand("java/lang/String").and(new InterfaceInternalNameMatcherOperand("java/lang/Runnable", false));
    operand = operand.or(new ClassInternalNameMatcherOperand("java/lang/Thread").and(new InterfaceInternalNameMatcherOperand("java/lang/Comparable", false)));
    result = matcher.match(classLoader, operand, stringClassMetadata);
    assertFalse(result);
    result = matcher.match(classLoader, operand, threadClassMetadata);
    assertFalse(result);
    // package AND (interface OR annotation) ==> package
    operand = new PackageInternalNameMatcherOperand("java/lang");
    operand = operand.and(new InterfaceInternalNameMatcherOperand("java/lang/Runnable", false).or(new AnnotationInternalNameMatcherOperand("java/lang/Override", false)));
    result = matcher.match(classLoader, operand, stringClassMetadata);
    assertFalse(result);
    result = matcher.match(classLoader, operand, threadClassMetadata);
    assertTrue(result);
    // class OR (interface AND NOT annotation)
    operand = new ClassInternalNameMatcherOperand("java/lang/String");
    operand = operand.or(new InterfaceInternalNameMatcherOperand("java/lang/Runnable", false).and(new AnnotationInternalNameMatcherOperand("java/lang/Override", false).not()));
    result = matcher.match(classLoader, operand, stringClassMetadata);
    assertTrue(result);
    result = matcher.match(classLoader, operand, threadClassMetadata);
    assertTrue(result);
}
Also used : InterfaceInternalNameMatcherOperand(com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.InterfaceInternalNameMatcherOperand) SuperClassInternalNameMatcherOperand(com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.SuperClassInternalNameMatcherOperand) ClassInternalNameMatcherOperand(com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.ClassInternalNameMatcherOperand) InterfaceInternalNameMatcherOperand(com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.InterfaceInternalNameMatcherOperand) MatcherOperand(com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.MatcherOperand) AnnotationInternalNameMatcherOperand(com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.AnnotationInternalNameMatcherOperand) PackageInternalNameMatcherOperand(com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.PackageInternalNameMatcherOperand) InputStream(java.io.InputStream) PackageInternalNameMatcherOperand(com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.PackageInternalNameMatcherOperand) DefaultInstrumentMatcherCacheConfig(com.navercorp.pinpoint.profiler.instrument.config.DefaultInstrumentMatcherCacheConfig) InstrumentMatcherCacheConfig(com.navercorp.pinpoint.profiler.instrument.config.InstrumentMatcherCacheConfig) DefaultInstrumentMatcherCacheConfig(com.navercorp.pinpoint.profiler.instrument.config.DefaultInstrumentMatcherCacheConfig) InternalClassMetadata(com.navercorp.pinpoint.profiler.instrument.classreading.InternalClassMetadata) AnnotationInternalNameMatcherOperand(com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.AnnotationInternalNameMatcherOperand) SuperClassInternalNameMatcherOperand(com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.SuperClassInternalNameMatcherOperand) ClassInternalNameMatcherOperand(com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.ClassInternalNameMatcherOperand) Test(org.junit.Test)

Aggregations

InterfaceInternalNameMatcherOperand (com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.InterfaceInternalNameMatcherOperand)14 Test (org.junit.Test)9 ClassInternalNameMatcherOperand (com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.ClassInternalNameMatcherOperand)6 Matcher (com.navercorp.pinpoint.bootstrap.instrument.matcher.Matcher)5 MatcherOperand (com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.MatcherOperand)5 SuperClassInternalNameMatcherOperand (com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.SuperClassInternalNameMatcherOperand)5 AnnotationInternalNameMatcherOperand (com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.AnnotationInternalNameMatcherOperand)3 PackageInternalNameMatcherOperand (com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.PackageInternalNameMatcherOperand)3 AndMatcherOperator (com.navercorp.pinpoint.bootstrap.instrument.matcher.operator.AndMatcherOperator)3 InternalClassMetadata (com.navercorp.pinpoint.profiler.instrument.classreading.InternalClassMetadata)2 DefaultInstrumentMatcherCacheConfig (com.navercorp.pinpoint.profiler.instrument.config.DefaultInstrumentMatcherCacheConfig)2 InstrumentMatcherCacheConfig (com.navercorp.pinpoint.profiler.instrument.config.InstrumentMatcherCacheConfig)2 AsyncContextAccessor (com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor)1 InstrumentClass (com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass)1 InstrumentException (com.navercorp.pinpoint.bootstrap.instrument.InstrumentException)1 InstrumentMethod (com.navercorp.pinpoint.bootstrap.instrument.InstrumentMethod)1 Instrumentor (com.navercorp.pinpoint.bootstrap.instrument.Instrumentor)1 OrMatcherOperator (com.navercorp.pinpoint.bootstrap.instrument.matcher.operator.OrMatcherOperator)1 TransformCallback (com.navercorp.pinpoint.bootstrap.instrument.transformer.TransformCallback)1 HandlerInterceptor (com.navercorp.pinpoint.plugin.vertx.interceptor.HandlerInterceptor)1