Disables jdbc parameter logging by default. You need to opt in. Fixes gh-2073
This commit is contained in:
@@ -46,7 +46,7 @@
|
||||
|spring.sleuth.jdbc.p6spy.log-format | | Custom log format.
|
||||
|spring.sleuth.jdbc.p6spy.logging | | Logging to use for logging queries.
|
||||
|spring.sleuth.jdbc.p6spy.multiline | `true` | Enables multiline output.
|
||||
|spring.sleuth.jdbc.p6spy.tracing.include-parameter-values | `true` | Report the effective sql string (with '?' replaced with real values) to tracing systems. <p> NOTE this setting does not affect the logging message.
|
||||
|spring.sleuth.jdbc.p6spy.tracing.include-parameter-values | `false` | Report the effective sql string (with '?' replaced with real values) to tracing systems. <p> NOTE this setting does not affect the logging message.
|
||||
|spring.sleuth.kafka.enabled | `true` | Enable instrumenting of Apache Kafka clients.
|
||||
|spring.sleuth.messaging.aspect.enabled | `false` | Should {@link MessageMapping} wrapping be enabled.
|
||||
|spring.sleuth.messaging.enabled | `false` | Should messaging be turned on.
|
||||
|
||||
@@ -768,9 +768,11 @@ runtimeOnly "net.ttddyy:datasource-proxy:${datasourceProxyVersion}"
|
||||
|
||||
Please check the <<appendix.adoc#appendix,appendix>> page under `spring.sleuth.jdbc.p6spy` for all p6spy configuration options and `spring.sleuth.jdbc.datasource-proxy` for all datasource proxy configuration options.
|
||||
|
||||
For P6Spy by default logging parameter values will be disabled, set `spring.sleuth.jdbc.p6spy.tracing.include-parameter-values` to `true` to enable it.
|
||||
|
||||
You can configure P6Spy manually using one of available configuration methods. For more information please refer to the http://p6spy.readthedocs.io/en/latest/configandusage.html[P6Spy Configuration Guide].
|
||||
|
||||
By default logging queries will be disabled, set `spring.sleuth.jdbc.datasource-proxy.slow-query.enable-logging` to `true` to enable logging slow queries
|
||||
For Datasource Proxy by default logging queries will be disabled, set `spring.sleuth.jdbc.datasource-proxy.slow-query.enable-logging` to `true` to enable logging slow queries
|
||||
and set `spring.sleuth.jdbc.datasource-proxy.query.enable-logging` to `true` to enable logging all queries.
|
||||
|
||||
In order to disable this instrumentation set `spring.sleuth.jdbc.enabled` to `false`.
|
||||
|
||||
@@ -476,7 +476,7 @@ public class TraceJdbcProperties {
|
||||
* <p>
|
||||
* NOTE this setting does not affect the logging message.
|
||||
*/
|
||||
private boolean includeParameterValues = true;
|
||||
private boolean includeParameterValues;
|
||||
|
||||
public boolean isIncludeParameterValues() {
|
||||
return this.includeParameterValues;
|
||||
|
||||
@@ -21,7 +21,6 @@ import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import org.aopalliance.aop.Advice;
|
||||
import org.aopalliance.intercept.MethodInterceptor;
|
||||
|
||||
@@ -51,7 +51,32 @@ public abstract class TraceJdbcEventListenerTests extends TraceListenerStrategyT
|
||||
|
||||
@Test
|
||||
void testShouldUsePlaceholderInSqlTagOfSpansForPreparedStatementIfIncludeParameterValuesIsSetToFalse() {
|
||||
contextRunner.withPropertyValues("spring.sleuth.jdbc.p6spy.tracing.include-parameter-values=false")
|
||||
contextRunner.run(context -> {
|
||||
DataSource dataSource = context.getBean(DataSource.class);
|
||||
TestSpanHandler spanReporter = context.getBean(TestSpanHandler.class);
|
||||
|
||||
Connection connection = dataSource.getConnection();
|
||||
PreparedStatement preparedStatement = connection
|
||||
.prepareStatement("UPDATE INFORMATION_SCHEMA.TABLES SET table_Name = ? WHERE 0 = ?");
|
||||
preparedStatement.setString(1, "");
|
||||
preparedStatement.setInt(2, 1);
|
||||
preparedStatement.executeUpdate();
|
||||
connection.close();
|
||||
|
||||
assertThat(spanReporter.reportedSpans()).hasSize(2);
|
||||
FinishedSpan connectionSpan = spanReporter.reportedSpans().get(1);
|
||||
FinishedSpan statementSpan = spanReporter.reportedSpans().get(0);
|
||||
assertThat(connectionSpan.getName()).isEqualTo("connection");
|
||||
assertThat(statementSpan.getName()).isEqualTo("update");
|
||||
assertThat(statementSpan.getTags()).containsEntry(SPAN_SQL_QUERY_TAG_NAME,
|
||||
"UPDATE INFORMATION_SCHEMA.TABLES SET table_Name = ? WHERE 0 = ?");
|
||||
assertThat(statementSpan.getTags()).containsEntry(SPAN_ROW_COUNT_TAG_NAME, "0");
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void testShouldNotUsePlaceholderInSqlTagOfSpansForPreparedStatementIfIncludeParameterValuesIsSetToTrue() {
|
||||
contextRunner.withPropertyValues("spring.sleuth.jdbc.p6spy.tracing.include-parameter-values=true")
|
||||
.run(context -> {
|
||||
DataSource dataSource = context.getBean(DataSource.class);
|
||||
TestSpanHandler spanReporter = context.getBean(TestSpanHandler.class);
|
||||
@@ -70,7 +95,7 @@ public abstract class TraceJdbcEventListenerTests extends TraceListenerStrategyT
|
||||
assertThat(connectionSpan.getName()).isEqualTo("connection");
|
||||
assertThat(statementSpan.getName()).isEqualTo("update");
|
||||
assertThat(statementSpan.getTags()).containsEntry(SPAN_SQL_QUERY_TAG_NAME,
|
||||
"UPDATE INFORMATION_SCHEMA.TABLES SET table_Name = ? WHERE 0 = ?");
|
||||
"UPDATE INFORMATION_SCHEMA.TABLES SET table_Name = '' WHERE 0 = 1");
|
||||
assertThat(statementSpan.getTags()).containsEntry(SPAN_ROW_COUNT_TAG_NAME, "0");
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user