测试非Spring-boot应用程序的Spring侦探
我有一个非常简单的Maven子模块 - “ Unified -Logging” - 提供了一些记录配置和一个Logutil类。该子模块不是弹簧启动应用程序,而是其他应用程序(作为POM中的编译时间依赖性)。
我还添加了该子模块的POM中的弹簧云侦探依赖性,以注入Spanid和Traceid。记录式配置为这些字段提供了模式:
<nestedField>
<fieldName>trace</fieldName>
<providers>
<pattern>
<pattern>
{
"traceId": "%X{traceId:-}",
"parentSpanId": "%X{parentSpanId:-}",
"spanId": "%X{spanId:-}"
}
</pattern>
</pattern>
</providers>
</nestedField>
如何测试TraceID和Spanid是否真正生成并注入日志中,因为这不是Spring Boot应用程序,并且整个自动配置部分不会加载Spring的整个自动配置部分? 谢谢
I have a very simple maven sub-module - "unified-logging" - providing some logback configuration and a LogUtil class. This sub-module is not a spring boot application and is used by other applications (as compile time dependecy in pom).
I have added, additionally, spring cloud sleuth dependency in pom of this sub-module to inject spanId and traceId. Logback configuration provides the pattern for these fields:
<nestedField>
<fieldName>trace</fieldName>
<providers>
<pattern>
<pattern>
{
"traceId": "%X{traceId:-}",
"parentSpanId": "%X{parentSpanId:-}",
"spanId": "%X{spanId:-}"
}
</pattern>
</pattern>
</providers>
</nestedField>
How can I test whether the traceId and spanId is really generated and injected in the logs as this is not a spring boot application and the whole auto-configuration part of spring will not be loaded?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过将Spring Boot作为测试依赖项进行测试,并编写一个简单的测试应用程序来测试集成。
You can test it by bringing in Spring Boot as a test dependency and write a simple test app that tests the integration.