You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2020/12/30 11:45:31 UTC

[GitHub] [skywalking] xuanyu66 opened a new issue #6105: agent's switch at runtime

xuanyu66 opened a new issue #6105:
URL: https://github.com/apache/skywalking/issues/6105


   Please answer these questions before submitting your issue.
   
   - Why do you submit this issue?
   - [ ] Question or discussion
   
   
   ___
   ### Question
   - What do you want to know?
   We want to unload agent without restarting our application.Maybe it's not proper to use "unload". It's something like agent's switch at runtime
   
   I read code and figure out that these are 5 class which are actual byte-buddy's interceptor to intercept class instance methods.
   - StaticMethodsInter
   - InstMethodsInter
   - InstMethodsInterWithOverrideArgs
   - ConstructorInter
   - StaticMethodsInterWithOverrideArgs
   
   So I decide to add some if/else statement to control whether to execute plugin's logic, such as beforeMethod() in class  InstanceMethodsAroundInterceptor.
   
   I want to know is it appropriate to do in this way? Is there a better way to do?
   Anyway, we will maintain code ourselves.
   
   ```
          try {
               if(tracingEnable) {
                   interceptor.beforeMethod(targetObject, method, allArguments, method.getParameterTypes(), result);
               }
           } catch (Throwable t) {
               LOGGER.error(t, "class[{}] before method[{}] intercept failure", obj.getClass(), method.getName());
           }
   
   ```
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [skywalking] wu-sheng commented on issue #6105: agent's switch at runtime

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on issue #6105:
URL: https://github.com/apache/skywalking/issues/6105#issuecomment-753235053


   > Did you mean set sample rate to 0?
   
   @xuanyu66 I think correctly, you can't. Check the source codes, `<=0` means sampling is off. Also, we don't provide agent dynamic configuration mechanism from the backend. Are you planning to contribute to the upstream?
   
   cc @zifeihan From my recently thinking, the dynamic disable plugin mechanism, only should be injected through TracingContext from the beginning.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [skywalking] xuanyu66 commented on issue #6105: agent's switch at runtime

Posted by GitBox <gi...@apache.org>.
xuanyu66 commented on issue #6105:
URL: https://github.com/apache/skywalking/issues/6105#issuecomment-752920171


   > My suggestion would be disable the `sampling` mechanism to stop creating the TracingContext. What do you think?
   
   Did you mean set sample rate to 0?


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [skywalking] xuanyu66 commented on issue #6105: agent's switch at runtime

Posted by GitBox <gi...@apache.org>.
xuanyu66 commented on issue #6105:
URL: https://github.com/apache/skywalking/issues/6105#issuecomment-753247604


   And trySample() is invoked in Interceptor


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [skywalking] xuanyu66 edited a comment on issue #6105: agent's switch at runtime

Posted by GitBox <gi...@apache.org>.
xuanyu66 edited a comment on issue #6105:
URL: https://github.com/apache/skywalking/issues/6105#issuecomment-752505368


   we will not invoke all method in the interceptor
   ```
   public Object intercept(@This Object obj, @AllArguments Object[] allArguments, @SuperCall Callable<?> zuper,
           @Origin Method method) throws Throwable {
           EnhancedInstance targetObject = (EnhancedInstance) obj;
    
           MethodInterceptResult result = new MethodInterceptResult();
           try {
               if(tracingEnable) {
                      interceptor.beforeMethod(targetObject, method, allArguments, method.getParameterTypes(), result);
               }
           } catch (Throwable t) {
               LOGGER.error(t, "class[{}] before method[{}] intercept failure", obj.getClass(), method.getName());
           }
    
           Object ret = null;
           try {
               if (!result.isContinue()) {
                   ret = result._ret();
               } else {
                   ret = zuper.call();
               }
           } catch (Throwable t) {
               try {
                   if(tracingEnable) {
                           interceptor.handleMethodException(targetObject, method, allArguments, method.getParameterTypes(), t);
                   }
               } catch (Throwable t2) {
                   LOGGER.error(t2, "class[{}] handle method[{}] exception failure", obj.getClass(), method.getName());
               }
               throw t;
           } finally {
               try {
                   if(tracingEnable) {
                         ret = interceptor.afterMethod(targetObject, method, allArguments, method.getParameterTypes(), ret);
                   }
               } catch (Throwable t) {
                   LOGGER.error(t, "class[{}] after method[{}] intercept failure", obj.getClass(), method.getName());
               }
           }
           return ret;
       }
   ```
   if tracingEnable == false, it only invoke the origin call ref, which would'nt cause memory leak.
   And tracingEnable is a Immutable copy value.
   Is it OK?


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [skywalking] wu-sheng commented on issue #6105: agent's switch at runtime

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on issue #6105:
URL: https://github.com/apache/skywalking/issues/6105#issuecomment-752476476


   First `unload` is not correct word, because what you proposed is actually not invoking the interceptor. All codes are changed.
   Then, this would be very dangerous, which wouldn't release the memory of tracing context.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [skywalking] zifeihan edited a comment on issue #6105: agent's switch at runtime

Posted by GitBox <gi...@apache.org>.
zifeihan edited a comment on issue #6105:
URL: https://github.com/apache/skywalking/issues/6105#issuecomment-752593395


   I agree with Teacher Wu's point of view.
   1.Maybe after closing some plugin, the dynamicField is not initialized, because some dynamicField is set in the interceptor, such as PreparedStatementExecuteMethodsInterceptor.
   2.The opening and closing of spans in some plugin are not in the same interceptor, which will cause some spans to not be closed, resulting in the TracingContext held by ThreadLocal cannot be released. Such as httpasyncclient plugin.
   3.In addition to InstMethodsInter, there are also some interceptors related to bootstrap.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [skywalking] wu-sheng commented on issue #6105: agent's switch at runtime

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on issue #6105:
URL: https://github.com/apache/skywalking/issues/6105#issuecomment-753247617


   We don't have any dynamic configuration mechanism for the agent now. If some one like you wants to contribute, we could discuss this on another thread.
   Backend server dynamic configuration mechanism has shown a good example.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [skywalking] xuanyu66 closed issue #6105: agent's switch at runtime

Posted by GitBox <gi...@apache.org>.
xuanyu66 closed issue #6105:
URL: https://github.com/apache/skywalking/issues/6105


   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [skywalking] xuanyu66 commented on issue #6105: agent's switch at runtime

Posted by GitBox <gi...@apache.org>.
xuanyu66 commented on issue #6105:
URL: https://github.com/apache/skywalking/issues/6105#issuecomment-752920565


   > > My suggestion would be disable the `sampling` mechanism to stop creating the TracingContext. What do you think?
   > 
   > This is a good way, our customized version provides another way, support dynamic close all plugins, but dynamic switches can only be applied to a limited number of plugins. like is,
   > 
   > ```
   > public Object intercept(@This Object obj, @AllArguments Object[] allArguments, @SuperCall Callable<?> zuper,
   >                             @Origin Method method) throws Throwable {
   > 
   >         if (!DynamicPluginService.shouldTrace(targetClassName)) {
   >             return zuper.call();
   >         }
   > 
   >         EnhancedInstance targetObject = (EnhancedInstance) obj;
   > 
   >         MethodInterceptResult result = new MethodInterceptResult();
   >         try {
   >             interceptor.beforeMethod(targetObject, method, allArguments, method.getParameterTypes(), result);
   >         } catch (Throwable t) {
   >             logger.error(t, "class[{}] before method[{}] intercept failure", obj.getClass(), method.getName());
   >         }
   > 
   >         Object ret = null;
   >         try {
   >             if (!result.isContinue()) {
   >                 ret = result._ret();
   >             } else {
   >                 ret = zuper.call();
   >             }
   >         } catch (Throwable t) {
   >             try {
   >                 interceptor.handleMethodException(targetObject, method, allArguments, method.getParameterTypes(), t);
   >             } catch (Throwable t2) {
   >                 logger.error(t2, "class[{}] handle method[{}] exception failure", obj.getClass(), method.getName());
   >             }
   >             throw t;
   >         } finally {
   >             try {
   >                 ret = interceptor.afterMethod(targetObject, method, allArguments, method.getParameterTypes(), ret);
   >             } catch (Throwable t) {
   >                 logger.error(t, "class[{}] after method[{}] intercept failure", obj.getClass(), method.getName());
   >             }
   >         }
   >         return ret;
   >     }
   > ```
   
   Thanks for suggestion. 


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [skywalking] xuanyu66 commented on issue #6105: agent's switch at runtime

Posted by GitBox <gi...@apache.org>.
xuanyu66 commented on issue #6105:
URL: https://github.com/apache/skywalking/issues/6105#issuecomment-752824637


   @wu-sheng Thanks for suggestion. Is there any way to close all plugins on runtime, like dynamic switching


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [skywalking] zifeihan commented on issue #6105: agent's switch at runtime

Posted by GitBox <gi...@apache.org>.
zifeihan commented on issue #6105:
URL: https://github.com/apache/skywalking/issues/6105#issuecomment-752593395


   I agree with Teacher Wu's point of view.
   1.Maybe after closing some plugin, the dynamicField is not initialized, because some dynamicField is set in the interceptor, such as PreparedStatementExecuteMethodsInterceptor.
   2.The opening and closing of spans in some plug-ins are not in the same interceptor, which will cause some spans to not be closed, resulting in the TracingContext held by ThreadLocal cannot be released. Such as httpasyncclient plugin.
   3.In addition to InstMethodsInter, there are also some interceptors related to bootstrap.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [skywalking] xuanyu66 removed a comment on issue #6105: agent's switch at runtime

Posted by GitBox <gi...@apache.org>.
xuanyu66 removed a comment on issue #6105:
URL: https://github.com/apache/skywalking/issues/6105#issuecomment-753247604


   And trySample() is invoked in Interceptor


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [skywalking] xuanyu66 commented on issue #6105: agent's switch at runtime

Posted by GitBox <gi...@apache.org>.
xuanyu66 commented on issue #6105:
URL: https://github.com/apache/skywalking/issues/6105#issuecomment-752823854


   @zifeihan  we want to close all plugins. Is that possible?
    And I also want to how you support dynamic switching of some plugin.
   
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [skywalking] zifeihan commented on issue #6105: agent's switch at runtime

Posted by GitBox <gi...@apache.org>.
zifeihan commented on issue #6105:
URL: https://github.com/apache/skywalking/issues/6105#issuecomment-752825090


   @xuanyu66 I think you can dynamic close all plugins. Based on the above problems, dynamic switches can only be applied to a limited number of plugins.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [skywalking] wu-sheng closed issue #6105: agent's switch at runtime

Posted by GitBox <gi...@apache.org>.
wu-sheng closed issue #6105:
URL: https://github.com/apache/skywalking/issues/6105


   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [skywalking] wu-sheng commented on issue #6105: agent's switch at runtime

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on issue #6105:
URL: https://github.com/apache/skywalking/issues/6105#issuecomment-753248303


   We should open another issue to discuss the agent dynamic configuration with sampling setting as first implementation. 


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [skywalking] xuanyu66 edited a comment on issue #6105: agent's switch at runtime

Posted by GitBox <gi...@apache.org>.
xuanyu66 edited a comment on issue #6105:
URL: https://github.com/apache/skywalking/issues/6105#issuecomment-753246872


   @wu-sheng 
   ```
           if (Config.Agent.SAMPLE_N_PER_3_SECS > 0) {
               on = true;
               this.resetSamplingFactor();
               ScheduledExecutorService service = Executors.newSingleThreadScheduledExecutor(
                   new DefaultNamedThreadFactory("SamplingService"));
               scheduledFuture = service.scheduleAtFixedRate(new RunnableWithExceptionProtection(
                   this::resetSamplingFactor, t -> LOGGER.error("unexpected exception.", t)), 0, 3, TimeUnit.SECONDS);
               LOGGER.debug(
                   "Agent sampling mechanism started. Sample {} traces in 3 seconds.", Config.Agent.SAMPLE_N_PER_3_SECS);
           }
   ```
   you are right.So how to disable the sampling mechanism?
   
   > Also, we don't provide agent dynamic configuration mechanism from the backend. Are you planning to contribute to the upstream?
   Yes, but agent dynamic configuration mechanism need to de deeply discussed.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [skywalking] xuanyu66 edited a comment on issue #6105: agent's switch at runtime

Posted by GitBox <gi...@apache.org>.
xuanyu66 edited a comment on issue #6105:
URL: https://github.com/apache/skywalking/issues/6105#issuecomment-753246872


   @wu-sheng 
   ```
           if (Config.Agent.SAMPLE_N_PER_3_SECS > 0) {
               on = true;
               this.resetSamplingFactor();
               ScheduledExecutorService service = Executors.newSingleThreadScheduledExecutor(
                   new DefaultNamedThreadFactory("SamplingService"));
               scheduledFuture = service.scheduleAtFixedRate(new RunnableWithExceptionProtection(
                   this::resetSamplingFactor, t -> LOGGER.error("unexpected exception.", t)), 0, 3, TimeUnit.SECONDS);
               LOGGER.debug(
                   "Agent sampling mechanism started. Sample {} traces in 3 seconds.", Config.Agent.SAMPLE_N_PER_3_SECS);
           }
   ```
   you are right.So how to disable the sampling mechanism?
   
   > Also, we don't provide agent dynamic configuration mechanism from the backend. Are you planning to contribute to the upstream?
   
   Yes, but agent dynamic configuration mechanism need to de deeply discussed.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [skywalking] wu-sheng commented on issue #6105: agent's switch at runtime

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on issue #6105:
URL: https://github.com/apache/skywalking/issues/6105#issuecomment-752862176


   > but dynamic switches can only be applied to a limited number of plugins. like is,
   
   Highly recommend don't do this :) It is mostly impossible for every user to read the plugin's source codes.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [skywalking] wu-sheng commented on issue #6105: agent's switch at runtime

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on issue #6105:
URL: https://github.com/apache/skywalking/issues/6105#issuecomment-752827066


   My suggestion would be disable the `sampling` mechanism to stop creating the TracingContext. What do you think?


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [skywalking] zifeihan commented on issue #6105: agent's switch at runtime

Posted by GitBox <gi...@apache.org>.
zifeihan commented on issue #6105:
URL: https://github.com/apache/skywalking/issues/6105#issuecomment-752875911


   > > but dynamic switches can only be applied to a limited number of plugins. like is,
   > 
   > Highly recommend don't do this :) It is mostly impossible for every user to read the plugin's source codes.
   
   Agree with your point.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [skywalking] dmsolr commented on issue #6105: agent's switch at runtime

Posted by GitBox <gi...@apache.org>.
dmsolr commented on issue #6105:
URL: https://github.com/apache/skywalking/issues/6105#issuecomment-752519865


   @zifeihan I knew you have a work on plugins switch. Maybe you could join in this thread and discuss.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [skywalking] xuanyu66 commented on issue #6105: agent's switch at runtime

Posted by GitBox <gi...@apache.org>.
xuanyu66 commented on issue #6105:
URL: https://github.com/apache/skywalking/issues/6105#issuecomment-753248506


   But, back to the topic, how to disable the sampling mechanism  to stop creating the TracingContext。
   I think we didn't get an conclusion


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [skywalking] wu-sheng commented on issue #6105: agent's switch at runtime

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on issue #6105:
URL: https://github.com/apache/skywalking/issues/6105#issuecomment-752522037


   Still same. TracingContext is being hold in the ThreadLocal(memory), it will be never removed. Also, the `dynamicField` of enhanced class instances may include value, which uses memory, and when you activate the agent back, it could bring the dirty data.
   Your direction is not correct. Don't try to manipulate the interceptor in the tracing status. It is dangerous and will bring unknown status into the agent, which means unexpected and un-understandable bugs.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [skywalking] xuanyu66 commented on issue #6105: agent's switch at runtime

Posted by GitBox <gi...@apache.org>.
xuanyu66 commented on issue #6105:
URL: https://github.com/apache/skywalking/issues/6105#issuecomment-752505368


   we will not invoke all method in the interceptor
   ```
   public Object intercept(@This Object obj, @AllArguments Object[] allArguments, @SuperCall Callable<?> zuper,
           @Origin Method method) throws Throwable {
           EnhancedInstance targetObject = (EnhancedInstance) obj;
    
           MethodInterceptResult result = new MethodInterceptResult();
           try {
               if(tracingEnable) {
                      interceptor.beforeMethod(targetObject, method, allArguments, method.getParameterTypes(), result);
               }
           } catch (Throwable t) {
               LOGGER.error(t, "class[{}] before method[{}] intercept failure", obj.getClass(), method.getName());
           }
    
           Object ret = null;
           try {
               if (!result.isContinue()) {
                   ret = result._ret();
               } else {
                   ret = zuper.call();
               }
           } catch (Throwable t) {
               try {
                   if(tracingEnable) {
                           interceptor.handleMethodException(targetObject, method, allArguments, method.getParameterTypes(), t);
                   }
               } catch (Throwable t2) {
                   LOGGER.error(t2, "class[{}] handle method[{}] exception failure", obj.getClass(), method.getName());
               }
               throw t;
           } finally {
               try {
                   if(tracingEnable) {
                         ret = interceptor.afterMethod(targetObject, method, allArguments, method.getParameterTypes(), ret);
                   }
               } catch (Throwable t) {
                   LOGGER.error(t, "class[{}] after method[{}] intercept failure", obj.getClass(), method.getName());
               }
           }
           return ret;
       }
   ```
   if tracingEnable == false, it only invoke the origin call ref, which would'nt cause memory leak.
   And tracingEnable is a Immutable copy value.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [skywalking] zifeihan commented on issue #6105: agent's switch at runtime

Posted by GitBox <gi...@apache.org>.
zifeihan commented on issue #6105:
URL: https://github.com/apache/skywalking/issues/6105#issuecomment-752600475


   @xuanyu66 Our customized version supports dynamic switching of some plugin. If necessary, I can provide some help.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [skywalking] xuanyu66 commented on issue #6105: agent's switch at runtime

Posted by GitBox <gi...@apache.org>.
xuanyu66 commented on issue #6105:
URL: https://github.com/apache/skywalking/issues/6105#issuecomment-753246872


   @wu-sheng 
   ```
           if (Config.Agent.SAMPLE_N_PER_3_SECS > 0) {
               on = true;
               this.resetSamplingFactor();
               ScheduledExecutorService service = Executors.newSingleThreadScheduledExecutor(
                   new DefaultNamedThreadFactory("SamplingService"));
               scheduledFuture = service.scheduleAtFixedRate(new RunnableWithExceptionProtection(
                   this::resetSamplingFactor, t -> LOGGER.error("unexpected exception.", t)), 0, 3, TimeUnit.SECONDS);
               LOGGER.debug(
                   "Agent sampling mechanism started. Sample {} traces in 3 seconds.", Config.Agent.SAMPLE_N_PER_3_SECS);
           }
   ```
   you are right.So how to disable the sampling mechanism?


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [skywalking] wu-sheng edited a comment on issue #6105: agent's switch at runtime

Posted by GitBox <gi...@apache.org>.
wu-sheng edited a comment on issue #6105:
URL: https://github.com/apache/skywalking/issues/6105#issuecomment-752522037


   Still same. TracingContext is being hold in the ThreadLocal(memory), it will be never removed. Also, the `dynamicField` of enhanced class instances may include value, which uses memory, and when you activate the agent back, it could bring the dirty data.
   Your direction is not correct. Don't try to manipulate the interceptor in the tracing status. It is dangerous and will bring unknown status into the agent, which means unexpected and incomprehensible bugs.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [skywalking] wu-sheng commented on issue #6105: agent's switch at runtime

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on issue #6105:
URL: https://github.com/apache/skywalking/issues/6105#issuecomment-753248867


   As this is not dynamic correctly. There is no point to provide this feature. You could uninstall the agent directly, right?


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [skywalking] zifeihan commented on issue #6105: agent's switch at runtime

Posted by GitBox <gi...@apache.org>.
zifeihan commented on issue #6105:
URL: https://github.com/apache/skywalking/issues/6105#issuecomment-752828917


   > My suggestion would be disable the `sampling` mechanism to stop creating the TracingContext. What do you think?
   
   This is a good way, our customized version provides another way, support dynamic close all plugins, but dynamic switches can only be applied to a limited number of plugins. like is, 
   ```
   public Object intercept(@This Object obj, @AllArguments Object[] allArguments, @SuperCall Callable<?> zuper,
                               @Origin Method method) throws Throwable {
   
           if (!DynamicPluginService.shouldTrace(targetClassName)) {
               return zuper.call();
           }
   
           EnhancedInstance targetObject = (EnhancedInstance) obj;
   
           MethodInterceptResult result = new MethodInterceptResult();
           try {
               interceptor.beforeMethod(targetObject, method, allArguments, method.getParameterTypes(), result);
           } catch (Throwable t) {
               logger.error(t, "class[{}] before method[{}] intercept failure", obj.getClass(), method.getName());
           }
   
           Object ret = null;
           try {
               if (!result.isContinue()) {
                   ret = result._ret();
               } else {
                   ret = zuper.call();
               }
           } catch (Throwable t) {
               try {
                   interceptor.handleMethodException(targetObject, method, allArguments, method.getParameterTypes(), t);
               } catch (Throwable t2) {
                   logger.error(t2, "class[{}] handle method[{}] exception failure", obj.getClass(), method.getName());
               }
               throw t;
           } finally {
               try {
                   ret = interceptor.afterMethod(targetObject, method, allArguments, method.getParameterTypes(), ret);
               } catch (Throwable t) {
                   logger.error(t, "class[{}] after method[{}] intercept failure", obj.getClass(), method.getName());
               }
           }
           return ret;
       }
   ```


----------------------------------------------------------------
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:
users@infra.apache.org