Search in sources :

Example 11 with Matcher

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

the class DefaultTranslator method addTransformer.

public void addTransformer(MatchableClassFileTransformer transformer) {
    // TODO extract matcher process
    final Matcher matcher = transformer.getMatcher();
    if (matcher instanceof ClassNameMatcher) {
        ClassNameMatcher classNameMatcher = (ClassNameMatcher) matcher;
        String className = classNameMatcher.getClassName();
        addTransformer0(transformer, className);
    } else if (matcher instanceof MultiClassNameMatcher) {
        final MultiClassNameMatcher classNameMatcher = (MultiClassNameMatcher) matcher;
        List<String> classNameList = classNameMatcher.getClassNames();
        for (String className : classNameList) {
            addTransformer0(transformer, className);
        }
    } else {
        throw new IllegalArgumentException("unsupported Matcher " + matcher);
    }
}
Also used : ClassNameMatcher(com.navercorp.pinpoint.bootstrap.instrument.matcher.ClassNameMatcher) MultiClassNameMatcher(com.navercorp.pinpoint.bootstrap.instrument.matcher.MultiClassNameMatcher) Matcher(com.navercorp.pinpoint.bootstrap.instrument.matcher.Matcher) List(java.util.List) ClassNameMatcher(com.navercorp.pinpoint.bootstrap.instrument.matcher.ClassNameMatcher) MultiClassNameMatcher(com.navercorp.pinpoint.bootstrap.instrument.matcher.MultiClassNameMatcher) MultiClassNameMatcher(com.navercorp.pinpoint.bootstrap.instrument.matcher.MultiClassNameMatcher)

Example 12 with Matcher

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

the class ReactorPlugin method addPublisher.

private void addPublisher() {
    final Matcher monoMatcher = Matchers.newPackageBasedMatcher("reactor.core.publisher", new SuperClassInternalNameMatcherOperand("reactor.core.publisher.Mono", true));
    transformTemplate.transform(monoMatcher, FluxAndMonoTransform.class);
    final Matcher fluxMatcher = Matchers.newPackageBasedMatcher("reactor.core.publisher", new SuperClassInternalNameMatcherOperand("reactor.core.publisher.Flux", true));
    transformTemplate.transform(fluxMatcher, FluxAndMonoTransform.class);
    final Matcher parallelFluxMatcher = Matchers.newPackageBasedMatcher("reactor.core.publisher", new SuperClassInternalNameMatcherOperand("reactor.core.publisher.ParallelFlux", true));
    transformTemplate.transform(parallelFluxMatcher, ParallelFluxTransform.class);
    final Matcher coreSubscriberMatcher = Matchers.newPackageBasedMatcher("reactor.core.publisher", 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 13 with Matcher

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

the class VertxPlugin method addHandlerInterceptor.

private void addHandlerInterceptor(final List<String> basePackageNames) {
    // basepackageNames AND io.vertx.core.Handler
    final Matcher matcher = Matchers.newPackageBasedMatcher(basePackageNames, new InterfaceInternalNameMatcherOperand("io.vertx.core.Handler", true));
    transformTemplate.transform(matcher, new TransformCallback() {

        @Override
        public byte[] doInTransform(Instrumentor instrumentor, ClassLoader classLoader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws InstrumentException {
            final InstrumentClass target = instrumentor.getInstrumentClass(classLoader, className, classfileBuffer);
            if (!target.isInterceptable()) {
                return null;
            }
            target.addField(AsyncContextAccessor.class);
            final InstrumentMethod handleMethod = target.getDeclaredMethod("handle", "java.lang.Object");
            if (handleMethod != null) {
                handleMethod.addInterceptor(HandlerInterceptor.class);
            }
            return target.toBytecode();
        }
    });
}
Also used : InterfaceInternalNameMatcherOperand(com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.InterfaceInternalNameMatcherOperand) ProtectionDomain(java.security.ProtectionDomain) InstrumentException(com.navercorp.pinpoint.bootstrap.instrument.InstrumentException) Matcher(com.navercorp.pinpoint.bootstrap.instrument.matcher.Matcher) Instrumentor(com.navercorp.pinpoint.bootstrap.instrument.Instrumentor) HandlerInterceptor(com.navercorp.pinpoint.plugin.vertx.interceptor.HandlerInterceptor) AsyncContextAccessor(com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor) TransformCallback(com.navercorp.pinpoint.bootstrap.instrument.transformer.TransformCallback) InstrumentClass(com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass) InstrumentMethod(com.navercorp.pinpoint.bootstrap.instrument.InstrumentMethod)

Aggregations

Matcher (com.navercorp.pinpoint.bootstrap.instrument.matcher.Matcher)13 InterfaceInternalNameMatcherOperand (com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.InterfaceInternalNameMatcherOperand)5 SuperClassInternalNameMatcherOperand (com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.SuperClassInternalNameMatcherOperand)3 ClassNameMatcher (com.navercorp.pinpoint.bootstrap.instrument.matcher.ClassNameMatcher)2 MultiClassNameMatcher (com.navercorp.pinpoint.bootstrap.instrument.matcher.MultiClassNameMatcher)2 List (java.util.List)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 TransformCallback (com.navercorp.pinpoint.bootstrap.instrument.transformer.TransformCallback)1 HandlerInterceptor (com.navercorp.pinpoint.plugin.vertx.interceptor.HandlerInterceptor)1 InstanceTransformCallbackProvider (com.navercorp.pinpoint.profiler.plugin.InstanceTransformCallbackProvider)1 MatchableClassFileTransformerDelegate (com.navercorp.pinpoint.profiler.plugin.MatchableClassFileTransformerDelegate)1 TransformCallbackProvider (com.navercorp.pinpoint.profiler.plugin.TransformCallbackProvider)1 ProtectionDomain (java.security.ProtectionDomain)1 ArrayList (java.util.ArrayList)1