lib/opentelemetry/instrumentation/mysql2/patches/client.rb in opentelemetry-instrumentation-mysql2-0.24.0 vs lib/opentelemetry/instrumentation/mysql2/patches/client.rb in opentelemetry-instrumentation-mysql2-0.24.1

- old
+ new

@@ -70,11 +70,15 @@ private def obfuscate_sql(sql) if sql.size > config[:obfuscation_limit] - truncated_sql = sql[..sql.index(generated_mysql_regex) - 1] - truncated_sql + "...\nSQL truncated (> #{config[:obfuscation_limit]} characters)" + first_match_index = sql.index(generated_mysql_regex) + 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(generated_mysql_regex, '?') obfuscated = 'Failed to obfuscate SQL query - quote characters remained after obfuscation' if detect_unmatched_pairs(obfuscated) obfuscated