kuko126 commented on issue #2279: Can skywalking ClassMatch support regex 
classname match?
URL: 
https://github.com/apache/incubator-skywalking/issues/2279#issuecomment-466330918
 
 
   I implement a classmatch , but no class was instrumented.
   ```
   public class RegClassNameMatch implements IndirectMatch {
   
       private List<String> matchClassNames;
       private Pattern pattern;
   
       public RegClassNameMatch(String regex) {
           if (regex == null) {
               throw new IllegalArgumentException("reg class names is null");
           }
           pattern = Pattern.compile(regex);
           matchClassNames = new ArrayList<String>();
       }
   
       @Override
       public ElementMatcher.Junction buildJunction() {
           ElementMatcher.Junction junction = null;
           for (String name : matchClassNames) {
               if (junction == null) {
                   junction = named(name);
               } else {
                   junction = junction.or(named(name));
               }
           }
           return junction;
       }
   
       @Override
       public boolean isMatch(TypeDescription typeDescription) {
           Matcher matcher = pattern.matcher(typeDescription.getTypeName());
           if (matcher.matches()) {
               matchClassNames.add(typeDescription.getTypeName());
               return true;
           }
           return false;
       }
   }
   ```
   
   Skywalking execute `buildJunction` first and then `isMatch` , therefore 
`matchClassNames` is empty. In my guess, method `buildJunction()` is 
responsible to match the class(cause I didnot find doc on the method). 
   Am I doing this right?
   Any suggestion on how to implement `buildJunction()`?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to