/// <summary> /// SQL obfuscation is expensive. It is performed when a transaction has ended in the creation of SQL traces and transaction traces. /// Whether we obfuscate SQL for traces depends on configuration. We reduce the number of times SQL obfuscation is performed by caching /// results. /// </summary> /// <param name="sql"></param> /// <returns></returns> private string GetObfuscatedSqlFromCache(string sql, DatastoreVendor vendor) { return(_cache.GetOrAdd(vendor, sql, ObfuscateSql)); string ObfuscateSql() { return(SqlObfuscator.GetObfuscatingSqlObfuscator().GetObfuscatedSql(sql, vendor)); } }
/// <summary> /// If the SQL obfuscation settings are set to obfuscate, this will return the obfuscated SQL using the cache. Otherwise, it just returns /// the value returned from the SQL obfuscator defined by the configuration because there is no need to cache the value of the no sql and raw sql obfuscators. /// </summary> /// <param name="sql"></param> /// <returns></returns> public string GetObfuscatedSql(string sql, DatastoreVendor vendor) { return(_sqlObfuscator != SqlObfuscator.GetObfuscatingSqlObfuscator() ? _sqlObfuscator.GetObfuscatedSql(sql, vendor) : GetObfuscatedSqlFromCache(sql, vendor)); }