Castile opened a new issue, #4632:
URL: https://github.com/apache/servicecomb-java-chassis/issues/4632

   ## 场景
   
集成spring-boot-actuator组件,业务通过curl命令调用actuator/health接口检测服务状态,业务自定义AbstractHealthIndicator里面调用cse的health接口,代码如下:
   ```java
   @Component
   public class HealthChecker extends AbstractHealthIndicator {
   
       @Override
       protected void doHealthCheck(Health.Builder builder) throws Exception {
           RestTemplate restTemplate = RestTemplateBuilder.create();
           String result = 
restTemplate.getForObject("cse://provider/test/health", String.class);
           if ("UP".equals(result)) {
               builder.up().withDetail("cseState", "UP");
           } else {
               builder.down().withDetail("cseState", "DOWN");
           }
       }
   }
   ```
   <img width="851" alt="image" 
src="https://github.com/user-attachments/assets/7e86c408-4d09-49d4-905c-7bf755e72bde";>
   
   
   curl命令:携带x-cse-context header信息
   ```shell
   curl  -ki -H 'x-cse-context: {"x-biz-tenantId": "1002"}' 
http://localhost:9093/provider/actuator/health
   ```
   ## 期望
   在provider/test/health 
这个cse接口内可以通过handler在invocationcontext中获取到'x-cse-context: {"x-biz-tenantId": 
"1002"}' 信息。
   
   ## 现状
   由于actuator组件的endpoint接口是由Spring 
MVC的DispatchServlet处理的,而cse接口是由RestServlet处理的,这个header信息无法带过来。
   其实,任何restcontroller接口调用cse接口都无法传递header信息, 
我们希望在前台设置header上下文,调用rest接口的时候,将这个上下文传递到cse接口中
   ```java
   @RestController("/")
   public class HelloController {
   
       @GetMapping("/hello")
       public String hello(){
           RestTemplate restTemplate = RestTemplateBuilder.create();
           return  restTemplate.getForObject("cse://provider/test/health", 
String.class);
       }
   }
   
   ```
   <img width="858" alt="image" 
src="https://github.com/user-attachments/assets/65f42018-793e-4d6e-b749-1fb0f8a7ccce";>
   
   
   
   请问有什么方案?
   
   
   
   
   
   


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

To unsubscribe, e-mail: [email protected]

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

Reply via email to