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);
}
}
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);
}
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();
}
});
}
Aggregations