Skip to content

Commit

Permalink
remove todo and add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
XiXiaPdx committed Dec 1, 2021
1 parent e620325 commit a1d2622
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public <T> void noticeTracer(Tracer tracer, SlowQueryDatastoreParameters<T> slow
}

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

DatastoreConfig datastoreConfig = ServiceFactory.getConfigService().getDefaultAgentConfig().getDatastoreConfig();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,13 +305,8 @@ protected void recordMetrics(TransactionStats transactionStats) {
}

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

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

0 comments on commit a1d2622

Please sign in to comment.