Search in sources :

Example 6 with Matcher

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

the class TransformTemplate method transform.

// @Override
// public void transform(String className, Class<? extends TransformCallback> transformCallbackClass, Object[] parameters) {
// Objects.requireNonNull(className, "className");
// Objects.requireNonNull(transformCallbackClass, "transformCallbackClass");
// 
// //        if (ParameterUtils.hasNull(parameters)) {
// //            throw new IllegalArgumentException("null parameter not supported");
// //        }
// 
// final Class<?>[] parameterType = ParameterUtils.toClass(parameters);
// // commons-lang
// // ConstructorUtils.getMatchingAccessibleConstructor()
// 
// transform(className, transformCallbackClass, parameters, parameterType);
// }
@Override
public void transform(String className, Class<? extends TransformCallback> transformCallbackClass, Object[] parameters, Class<?>[] parameterTypes) {
    Objects.requireNonNull(className, "className");
    Objects.requireNonNull(transformCallbackClass, "transformCallbackClass");
    TransformCallbackChecker.validate(transformCallbackClass, parameterTypes);
    if (ParameterUtils.hasNull(parameterTypes)) {
        throw new IllegalArgumentException("null parameterType not supported");
    }
    ParameterUtils.checkParameterType(parameterTypes);
    final Matcher matcher = Matchers.newClassNameMatcher(className);
    // release class reference
    final String transformCallbackName = transformCallbackClass.getName();
    this.instrumentContext.addClassFileTransformer(matcher, transformCallbackName, parameters, parameterTypes);
}
Also used : Matcher(com.navercorp.pinpoint.bootstrap.instrument.matcher.Matcher)

Example 7 with Matcher

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

the class TransformTemplate method transform.

/**
 * @deprecated Since 1.9.0 Use {@link #transform(String, Class)}
 */
@Deprecated
@Override
public void transform(String className, TransformCallback transformCallback) {
    Objects.requireNonNull(className, "className");
    Objects.requireNonNull(transformCallback, "transformCallback");
    final Matcher matcher = Matchers.newClassNameMatcher(className);
    this.instrumentContext.addClassFileTransformer(matcher, transformCallback);
}
Also used : Matcher(com.navercorp.pinpoint.bootstrap.instrument.matcher.Matcher)

Example 8 with Matcher

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

the class ThreadPlugin method addInterceptor.

private void addInterceptor(String threadMatchPackage, String className, Class<? extends TransformCallback> transformCallback) {
    Matcher matcher = Matchers.newPackageBasedMatcher(threadMatchPackage, new InterfaceInternalNameMatcherOperand(className, true));
    transformTemplate.transform(matcher, transformCallback);
}
Also used : InterfaceInternalNameMatcherOperand(com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.InterfaceInternalNameMatcherOperand) Matcher(com.navercorp.pinpoint.bootstrap.instrument.matcher.Matcher)

Example 9 with Matcher

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

the class RocketMQPlugin method setup.

@Override
public void setup(ProfilerPluginSetupContext context) {
    final RocketMQConfig config = new RocketMQConfig(context.getConfig());
    logger.info("{} config:{}", this.getClass().getSimpleName(), config);
    final List<String> basePackageNames = new ArrayList<>();
    // rocketmq spring boot support
    basePackageNames.add("org.apache.rocketmq.spring.support");
    // rocketmq spring cloud stream support
    basePackageNames.add("com.alibaba.cloud.stream.binder.rocketmq");
    final List<String> basePackages = config.getBasePackages();
    if (!basePackages.isEmpty()) {
        basePackageNames.addAll(basePackages);
    }
    if (config.isProducerEnable()) {
        transformTemplate.transform("org.apache.rocketmq.client.impl.MQClientAPIImpl", MQClientAPIImplTransform.class);
        final Matcher matcher = Matchers.newPackageBasedMatcher(basePackageNames, new InterfaceInternalNameMatcherOperand("org.apache.rocketmq.client.producer.SendCallback", true));
        transformTemplate.transform(matcher, SendCallbackTransform.class);
    }
    if (config.isConsumerEnable()) {
        transformTemplate.transform("org.apache.rocketmq.client.impl.consumer.DefaultMQPushConsumerImpl", ConsumerTransform.class);
        transformTemplate.transform("org.apache.rocketmq.remoting.netty.NettyRemotingClient", RemotingTransform.class);
        transformTemplate.transform("org.apache.rocketmq.remoting.netty.NettyRemotingClient$ChannelWrapper", ChannelWrapperTransform.class);
        final Matcher matcher = Matchers.newPackageBasedMatcher(basePackageNames, new InterfaceInternalNameMatcherOperand("org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently", true));
        transformTemplate.transform(matcher, MessageListenerConcurrentlyTransform.class);
        final Matcher orderlyMatcher = Matchers.newPackageBasedMatcher(basePackageNames, new InterfaceInternalNameMatcherOperand("org.apache.rocketmq.client.consumer.listener.MessageListenerOrderly", true));
        transformTemplate.transform(orderlyMatcher, MessageListenerOrderlyTransform.class);
    }
}
Also used : InterfaceInternalNameMatcherOperand(com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.InterfaceInternalNameMatcherOperand) Matcher(com.navercorp.pinpoint.bootstrap.instrument.matcher.Matcher) ArrayList(java.util.ArrayList)

Example 10 with Matcher

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

the class TestClassLoader method addTransformer.

public void addTransformer(final String targetClassName, final TransformCallback transformer) {
    if (logger.isLoggable(Level.FINE)) {
        logger.fine("addTransformer targetClassName:{}" + targetClassName + " callback:{}" + transformer);
    }
    final Matcher matcher = Matchers.newClassNameMatcher(targetClassName);
    final TransformCallbackProvider transformCallbackProvider = new InstanceTransformCallbackProvider(transformer);
    final MatchableClassFileTransformerDelegate guard = new MatchableClassFileTransformerDelegate(applicationContext.getProfilerConfig(), instrumentContext, matcher, transformCallbackProvider);
    this.instrumentTranslator.addTransformer(guard);
}
Also used : MatchableClassFileTransformerDelegate(com.navercorp.pinpoint.profiler.plugin.MatchableClassFileTransformerDelegate) Matcher(com.navercorp.pinpoint.bootstrap.instrument.matcher.Matcher) TransformCallbackProvider(com.navercorp.pinpoint.profiler.plugin.TransformCallbackProvider) InstanceTransformCallbackProvider(com.navercorp.pinpoint.profiler.plugin.InstanceTransformCallbackProvider) InstanceTransformCallbackProvider(com.navercorp.pinpoint.profiler.plugin.InstanceTransformCallbackProvider)

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