evilester opened a new issue #6104:
URL: https://github.com/apache/skywalking/issues/6104


   Please answer these questions before submitting your issue.
   
   - Why do you submit this issue?
   - [ ] Question or discussion
   - [x] Bug
   - [ ] Requirement
   - [ ] Feature or performance improvement
   
   ___
   ### Question
   - What do you want to know?
   Sample rate configuration failure
   ___
   ### Bug
   - Which version of SkyWalking, OS, and JRE?
   v8.3.0
   - Which company or project?
    XiaoMai
   - What happened?
   Traceignoreextendservice inherits from contextmanagerextendservice to 
samplingservice. When servicemanger manages class loadallservices, this will 
conflict with the default sampling rate configuration samplingservice. The keys 
of both are the same,so the SamplingService whil not boot
   
   ```
    private Map<Class, BootService> loadAllServices() {
           Map<Class, BootService> bootedServices = new LinkedHashMap<>();
           List<BootService> allServices = new LinkedList<>();
           load(allServices);
        // plugin TraceIgnoreExtendService and SamplingService has the same key
           for (final BootService bootService : allServices) {
               Class<? extends BootService> bootServiceClass = 
bootService.getClass();
               boolean isDefaultImplementor = 
bootServiceClass.isAnnotationPresent(DefaultImplementor.class);
               if (isDefaultImplementor) {
                   if (!bootedServices.containsKey(bootServiceClass)) {
                       bootedServices.put(bootServiceClass, bootService);
                   } else {
                       //ignore the default service
                   }
               } else {
                   OverrideImplementor overrideImplementor = 
bootServiceClass.getAnnotation(OverrideImplementor.class);
                   if (overrideImplementor == null) {
                       if (!bootedServices.containsKey(bootServiceClass)) {
                           bootedServices.put(bootServiceClass, bootService);
                       } else {
                           throw new ServiceConflictException("Duplicate 
service define for :" + bootServiceClass);
                       }
                   } else {
                       Class<? extends BootService> targetService = 
overrideImplementor.value();
                       if (bootedServices.containsKey(targetService)) {
                           boolean presentDefault = 
bootedServices.get(targetService)
                                                                  .getClass()
                                                                  
.isAnnotationPresent(DefaultImplementor.class);
                           if (presentDefault) {
                               bootedServices.put(targetService, bootService);
                           } else {
                               throw new ServiceConflictException(
                                   "Service " + bootServiceClass + " overrides 
conflict, " + "exist more than one service want to override :" + targetService);
                           }
                       } else {
                           bootedServices.put(targetService, bootService);
                       }
                   }
               }
   
           }
           return bootedServices;
       }
   ```
   :class 
org.apache.skywalking.apm.agent.core.sampling.SamplingService=org.apache.skywalking.apm.plugin.trace.ignore.TraceIgnoreExtendService@6622fc65
   
   
![image](https://user-images.githubusercontent.com/4954490/103336240-6f7c8e00-4ab2-11eb-8672-8909a4faaf25.png)
    
   ___
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to