diff --git a/lib/elastic_apm/sql_summarizer.rb b/lib/elastic_apm/sql_summarizer.rb
index <HASH>..<HASH> 100644
--- a/lib/elastic_apm/sql_summarizer.rb
+++ b/lib/elastic_apm/sql_summarizer.rb
@@ -25,7 +25,7 @@ module ElasticAPM
     end
 
     def summarize(sql)
-      sql = sql.encode(UTF8, invalid: :replace, replace: nil)
+      sql = sql.encode(UTF8, invalid: :replace, undef: :replace)
       self.class.cache[sql] ||=
         REGEXES.find do |regex, sig|
           if (match = sql[0...1000].match(regex))
Handle undefined characters as well (#<I>)