首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Spring cloud sleuth不向Hibernate查询日志追加密钥

Spring cloud sleuth不向Hibernate查询日志追加密钥
EN

Stack Overflow用户
提问于 2019-03-20 23:02:39
回答 1查看 547关注 0票数 2

当我使用spring cloud sleuth时,我观察到它为所有应用程序日志附加了应用程序名称和关键细节。

但这不会发生在Hibernate日志或jpa查询中。

有没有什么方法可以使用侦察来实现这一点呢?

EN

回答 1

Stack Overflow用户

发布于 2019-04-05 20:34:23

您可以通过py6spy - https://github.com/openzipkin/brave/tree/master/instrumentation/p6spy查看与JDBC的勇敢集成。

摘自文档:

代码语言:javascript
运行
复制
brave-instrumentation-p6spy

This includes a tracing event listener for P6Spy (a proxy for calls to your JDBC driver). It reports to Zipkin how long each statement takes, along with relevant tags like the query.

P6Spy requires a spy.properties in your application classpath (ex src/main/resources). brave.p6spy.TracingP6Factory must be in the modulelist to enable tracing.

modulelist=brave.p6spy.TracingP6Factory
url=jdbc:p6spy:derby:memory:p6spy;create=true

In addition, you can specify the following options in spy.properties

remoteServiceName

By default the zipkin service name for your database is the name of the database. Set this property to override it

remoteServiceName=myProductionDatabase

includeParameterValues

When set to to true, the tag sql.query will also include the JDBC parameter values.

Note: if you enable this please also consider enabling 'excludebinary' to avoid logging large blob values as hex (see http://p6spy.readthedocs.io/en/latest/configandusage.html#excludebinary).

includeParameterValues=true
excludebinary=true

spy.properties applies globally to any instrumented jdbc connection. To override this, add the zipkinServiceName property to your connection string.

jdbc:mysql://127.0.0.1:3306/mydatabase?zipkinServiceName=myServiceName

This will override the remoteServiceName set in spy.properties.

The current tracing component is used at runtime. Until you have instantiated brave.Tracing, no traces will appear.
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55263974

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档