【问题标题】:Spring cloud sleuth not appending keys to Hibernate query logsSpring cloud sleuth 未将密钥附加到 Hibernate 查询日志
【发布时间】:2019-08-11 08:04:35
【问题描述】:

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

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

有什么方法可以使用侦探来实现这一点

【问题讨论】:

    标签: spring spring-data-jpa spring-cloud spring-cloud-sleuth


    【解决方案1】:

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

    从文档中摘录:

    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.
    

    【讨论】:

      猜你喜欢
      • 2017-08-03
      • 2021-04-27
      • 2016-08-22
      • 2022-12-12
      • 2021-12-29
      • 2021-06-07
      • 2017-05-04
      • 2017-03-06
      • 2020-08-08
      相关资源
      最近更新 更多