Created
April 14, 2019 14:07
-
-
Save shirou/b794901efc56c8dc13035d77c52bd63d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
spring: | |
application: | |
name: sqltesting-src | |
jpa: | |
properties: | |
hibernate: | |
session_factory: | |
statement_inspector: info.tdoc.spring.example.tracer.SQLTracer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package info.tdoc.spring.example.tracer; | |
import io.opencensus.trace.Tracing; | |
import io.opencensus.trace.Tracer; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
import org.hibernate.resource.jdbc.spi.StatementInspector; | |
import io.opencensus.trace.AttributeValue; | |
import org.springframework.stereotype.Component; | |
@Component | |
public class SQLTracer implements StatementInspector { | |
private static final Logger log = LoggerFactory.getLogger(SQLTracer.class); | |
private static final Tracer tracer = Tracing.getTracer(); | |
public String inspect(String sql) { | |
tracer.getCurrentSpan().putAttribute("sql.query", AttributeValue.stringAttributeValue(sql)); | |
return sql; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment