spring_reference/V. Spring Boot Actuator: Pr.../46.1. Custom tracing.md

6 lines
626 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

### 46.1. 自定义追踪
如果需要追踪其他的事件,你可以将一个[TraceRepository](http://github.com/spring-projects/spring-boot/tree/master/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/trace/TraceRepository.java)注入到你的Spring Beans中。`add`方法接收一个将被转化为JSON的`Map`结构,该数据将被记录下来。
默认情况下,使用的`InMemoryTraceRepository`将存储最新的100个事件。如果需要扩展该容量你可以定义自己的`InMemoryTraceRepository`实例。如果需要,你可以创建自己的替代`TraceRepository`实现。