【发布时间】:2023-04-09 20:00:02
【问题描述】:
我在我的应用程序中配置了 Spring cloud sleuth(还有 zipkin)。我有一个调用服务的控制器,它又调用存储库,最后调用数据库。
设置工作正常,Sleuth 正在生成跨度 ID,它在 zipkin 中也可见。我想尝试跨多个内部 bean 和方法创建跨度。我遇到了Managing Spans with Annotations。这似乎不起作用。
当我使用此处提到的任何注释(例如 @NewSpan 或 @ContinueSpan)时,自动装配停止工作。我在 Controller 中自动装配的服务类是 null。如果我删除这些注释,一切都会再次运行。
我正在使用。
spring-boot 2.2.5.RELEASE
spring-cloud.version Hoxton.SR3
我的 pom 中有这些依赖项
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-sleuth</artifactId> // This is pulling 2.2.2.RELEASE version
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zipkin</artifactId>
</dependency>
这是一个示例代码
@RestController
class SomeController {
@Autowired
SomeService someService;
@GetMapping("/init")
@NewSpan("init")
private void init() {
someService.init();
}
}
我的服务类就像
@Service
Class SomeService {
.....
@ContinueSpan(log = "init")
public void init() {
}
}
我的猜测是,Spring-Aop 与它有关。有什么想法吗?
【问题讨论】:
-
你能提供一些额外的信息吗?您使用的是哪个版本的 Sleuth?你是如何使用注释的?
-
@MarcinGrzejszczak 更新了问题的详细信息
标签: spring-boot spring-cloud spring-cloud-sleuth