lib/opentelemetry/instrumentation/trilogy/patches/client.rb in opentelemetry-instrumentation-trilogy-0.55.0 vs lib/opentelemetry/instrumentation/trilogy/patches/client.rb in opentelemetry-instrumentation-trilogy-0.55.1

- old
+ new

@@ -84,11 +84,15 @@ attributes end def obfuscate_sql(sql) if sql.size > config[:obfuscation_limit] - truncated_sql = sql[..sql.index(FULL_SQL_REGEXP) - 1] - truncated_sql + "...\nSQL truncated (> #{config[:obfuscation_limit]} characters)" + first_match_index = sql.index(FULL_SQL_REGEXP) + truncation_message = "SQL truncated (> #{config[:obfuscation_limit]} characters)" + return truncation_message unless first_match_index + + truncated_sql = sql[..first_match_index - 1] + "#{truncated_sql}...\n#{truncation_message}" else obfuscated = OpenTelemetry::Common::Utilities.utf8_encode(sql, binary: true) obfuscated = obfuscated.gsub(FULL_SQL_REGEXP, '?') obfuscated = 'Failed to obfuscate SQL query - quote characters remained after obfuscation' if detect_unmatched_pairs(obfuscated) obfuscated