我们正在使用基于注释的跨度标签来标记方法值和控制器中的请求对象。我们已经看到了两种行为
我们无法在跨度中包含api响应对象。 控制器API调用如下:
@PostMapping(path = "/{reuqestParam}/submit")
@ContinueSpan(log = "submit")
public IngestionResponse submit(final InputStream inputStream,
@SpanTag("reuqestParam") @PathVariable String reuqestParam,
@SpanTag("HttpHeaders") @RequestHeader HttpHeaders httpHeaders) {
LOGGER.info("[Upload to Stream]: Begin");
final IngestionResponse ingestionResponse = ingestionService
.ingestInputStream(inputStream, reuqestParam, httpHeaders);
LOGGER.info("[Upload to Stream]: Completed");
return ingestionResponse;
}
Span对象包含方法参数/方法名称,但HTTP状态代码也缺少响应对象。无论api成功与否,我们都需要捕获这两个信息。
答案 0 :(得分:0)
您将需要创建一个HttpServerParser实例来覆盖此bean:https://github.com/spring-cloud/spring-cloud-sleuth/blob/master/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/web/TraceHttpAutoConfiguration.java#L109
您应该能够以最小的更改覆盖它