lib/opentelemetry/instrumentation/mysql2/patches/client.rb in opentelemetry-instrumentation-mysql2-0.18.1 vs lib/opentelemetry/instrumentation/mysql2/patches/client.rb in opentelemetry-instrumentation-mysql2-0.19.0

- old
+ new

@@ -49,25 +49,28 @@ comments multi_line_comments ].freeze def query(sql, options = {}) + attributes = client_attributes + case config[:db_statement] + when :include + attributes['db.statement'] = sql + when :obfuscate + attributes['db.statement'] = obfuscate_sql(sql) + end tracer.in_span( database_span_name(sql), - attributes: client_attributes.merge( - 'db.statement' => obfuscate_sql(sql) - ), + attributes: attributes, kind: :client ) do super(sql, options) end end private def obfuscate_sql(sql) - return sql unless config[:enable_sql_obfuscation] - if sql.size > 2000 'SQL query too large to remove sensitive data ...' else obfuscated = sql.gsub(generated_mysql_regex, '?') obfuscated = 'Failed to obfuscate SQL query - quote characters remained after obfuscation' if detect_unmatched_pairs(obfuscated)