Skip to content

Commit a1d2622

Browse files
committed
remove todo and add comments
1 parent e620325 commit a1d2622

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

newrelic-agent/src/main/java/com/newrelic/agent/sql/DefaultSlowQueryListener.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ public <T> void noticeTracer(Tracer tracer, SlowQueryDatastoreParameters<T> slow
5555
}
5656

5757
// This allows transaction traces to show slow queries directly in the trace details
58-
//todo: obfuscatedQueryString isn't correct, it could be Raw or Obfuscated. The queryConverter
59-
// has conditional obfuscation, respecting recrod_sql setting.
58+
// Unfortunately, SQL_OBFUSCATED_PARAMETER_NAME is misleading. Before reaching here, the query has already
59+
// been processed by SqlQueryConverter in DefaultSqlTracer. The result could be Raw, Obfuscated, or null.
6060
tracer.setAgentAttribute(SqlTracer.SQL_OBFUSCATED_PARAMETER_NAME, query);
6161

6262
DatastoreConfig datastoreConfig = ServiceFactory.getConfigService().getDefaultAgentConfig().getDatastoreConfig();

newrelic-agent/src/main/java/com/newrelic/agent/tracers/DefaultSqlTracer.java

+8-7
Original file line numberDiff line numberDiff line change
@@ -305,13 +305,8 @@ protected void recordMetrics(TransactionStats transactionStats) {
305305
}
306306

307307
/**
308-
* This method is named this way because the docs on toObfuscatedQueryString imply obfuscation certainty.
309-
* The reality is the SqlQueryConverter implementation of this method has introduced conditional
310-
* logic that respects the agent configuration setting `record_sql`.
311-
*
312-
* If OBFUSCATED, sql is obfuscated.
313-
* If RAW, sql is returned, unchanged.
314-
* If OFF, null is returned.
308+
* This method is named this way because {@link SqlQueryConverter#toObfuscatedQueryString(String)} has
309+
* unexpected conditional logic.
315310
*/
316311
private String getNoRawOrObfuscatedSql(String rawSql, String appName) {
317312
SqlQueryConverter converter = new SqlQueryConverter(appName, getDatabaseVendor());
@@ -559,6 +554,12 @@ public String toRawQueryString(String rawQuery) {
559554
return rawQuery;
560555
}
561556

557+
/**
558+
* For this implementation, the getSqlfuscator has conditional
559+
* logic to return an obfuscator that respects the agent configuration setting `record_sql`
560+
*
561+
* See {@link com.newrelic.agent.database.DatabaseService#createSqlObfuscator(TransactionTracerConfig) }
562+
*/
562563
@Override
563564
public String toObfuscatedQueryString(String rawQuery) {
564565
SqlObfuscator sqlObfuscator = ServiceFactory.getDatabaseService().getSqlObfuscator(appName);

0 commit comments

Comments
 (0)