You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2019/12/27 02:34:05 UTC

[GitHub] [servicecomb-java-chassis] hongfeihuangseu opened a new issue #1497: 业务如果想在发生熔断的时候,在业务日志打个error日志,这个怎么做呢?

hongfeihuangseu opened a new issue #1497: 业务如果想在发生熔断的时候,在业务日志打个error日志,这个怎么做呢?
URL: https://github.com/apache/servicecomb-java-chassis/issues/1497
 
 
   现在业务貌似获取不到熔断这个事件,只有cse知道

----------------------------------------------------------------
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


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] hongfeihuangseu commented on issue #1497: 业务如果想在发生熔断的时候,在业务日志打个error日志,这个怎么做呢?

Posted by GitBox <gi...@apache.org>.
hongfeihuangseu commented on issue #1497: 业务如果想在发生熔断的时候,在业务日志打个error日志,这个怎么做呢?
URL: https://github.com/apache/servicecomb-java-chassis/issues/1497#issuecomment-569206075
 
 
   markEvent通过post把熔断事件放进EventBus,那在业务端是通过com.google.common.eventbus.Subscribe注解来获取事件通知吗

----------------------------------------------------------------
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


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] yhs0092 commented on issue #1497: 业务如果想在发生熔断的时候,在业务日志打个error日志,这个怎么做呢?

Posted by GitBox <gi...@apache.org>.
yhs0092 commented on issue #1497: 业务如果想在发生熔断的时候,在业务日志打个error日志,这个怎么做呢?
URL: https://github.com/apache/servicecomb-java-chassis/issues/1497#issuecomment-569380792
 
 
   是不是没有触发熔断啊。
   我基于[微服务21天培训课程](https://education.huaweicloud.com:8443/courses/course-v1:HuaweiX+CBUCNXP012+Self-paced/courseware/9d1e7d073ba04f6ebc11d984dbc72eb5/4e114502a206474482dd72fa98409caa/)里面第九天的demo,加了一个listener监听事件
   ```java
   package microservice.demo.training21days.edge.listener;
   
   import org.apache.servicecomb.bizkeeper.event.CircutBreakerEvent;
   import org.apache.servicecomb.common.rest.codec.RestObjectMapperFactory;
   import org.apache.servicecomb.foundation.common.event.EventManager;
   import org.slf4j.Logger;
   import org.slf4j.LoggerFactory;
   import org.springframework.beans.factory.InitializingBean;
   import org.springframework.stereotype.Component;
   
   import com.fasterxml.jackson.core.JsonProcessingException;
   import com.google.common.eventbus.Subscribe;
   
   @Component
   public class CircuitBreakListener implements InitializingBean {
   
     private static final Logger LOGGER = LoggerFactory.getLogger(CircuitBreakListener.class);
   
     @Subscribe
     public void onCircuitBreakEventHappen(CircutBreakerEvent event) {
       try {
         LOGGER.info("event happen! {}", RestObjectMapperFactory.getRestObjectMapper().writeValueAsString(event));
       } catch (JsonProcessingException e) {
         LOGGER.info("failed to write ", e);
       }
     }
   
     @Override
     public void afterPropertiesSet() throws Exception {
       EventManager.register(this);
       LOGGER.info("registered!");
     }
   }
   ```
   
   发现是可以生效的。会打印像这样的日志
   熔断触发:
   ```
   2019-12-28 11:18:57,155 [INFO] event happen! {"type":"OPEN","role":"CONSUMER","microservice":"consumer","schema":"helloConsumer","operation":"sayHello","currentTotalRequest":3,"currentErrorCount":100,"currentErrorPercentage":3,"requestVolumeThreshold":3,"sleepWindowInMilliseconds":30000,"errorThresholdPercentage":50} microservice.demo.training21days.edge.listener.CircuitBreakListener.onCircuitBreakEventHappen(CircuitBreakListener.java:22)
   ```
   熔断恢复:
   ```
   2019-12-28 11:25:53,837 [INFO] event happen! {"type":"CLOSE","role":"CONSUMER","microservice":"consumer","schema":"helloConsumer","operation":"sayHello","currentTotalRequest":0,"currentErrorCount":0,"currentErrorPercentage":0,"requestVolumeThreshold":3,"sleepWindowInMilliseconds":30000,"errorThresholdPercentage":50} microservice.demo.training21days.edge.listener.CircuitBreakListener.onCircuitBreakEventHappen(CircuitBreakListener.java:22)
   ```
   
   如果你那边触发不了的话,建议去`CircutBreakerEventNotifier`里面打个断点检查一下

----------------------------------------------------------------
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


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] yhs0092 commented on issue #1497: 业务如果想在发生熔断的时候,在业务日志打个error日志,这个怎么做呢?

Posted by GitBox <gi...@apache.org>.
yhs0092 commented on issue #1497: 业务如果想在发生熔断的时候,在业务日志打个error日志,这个怎么做呢?
URL: https://github.com/apache/servicecomb-java-chassis/issues/1497#issuecomment-569172471
 
 
   可以参考一下Java-Chassis中`org.apache.servicecomb.bizkeeper.event.CircutBreakerEventNotifier`类的代码。熔断发生和恢复时这个类会向EventBus中发布事件。
   你可以从`EventManager.getEventBus()`方法获取EventBus,来监听`org.apache.servicecomb.bizkeeper.event.CircutBreakerEvent`事件

----------------------------------------------------------------
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


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] hongfeihuangseu commented on issue #1497: 业务如果想在发生熔断的时候,在业务日志打个error日志,这个怎么做呢?

Posted by GitBox <gi...@apache.org>.
hongfeihuangseu commented on issue #1497: 业务如果想在发生熔断的时候,在业务日志打个error日志,这个怎么做呢?
URL: https://github.com/apache/servicecomb-java-chassis/issues/1497#issuecomment-569259549
 
 
   ![20191227-202329(eSpace)](https://user-images.githubusercontent.com/58418619/71516959-ce7b5600-28e6-11ea-826f-13678ecfa133.png)
   熔断的register这个日志可以打,但是outputToLog这个再触发熔断后没有调进来打印,请问怎么解决呢

----------------------------------------------------------------
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


With regards,
Apache Git Services