diff --git a/instrumentation/mysql2/lib/opentelemetry/instrumentation/mysql2/patches/client.rb b/instrumentation/mysql2/lib/opentelemetry/instrumentation/mysql2/patches/client.rb index d1094f4cd..0b50b8d99 100644 --- a/instrumentation/mysql2/lib/opentelemetry/instrumentation/mysql2/patches/client.rb +++ b/instrumentation/mysql2/lib/opentelemetry/instrumentation/mysql2/patches/client.rb @@ -53,7 +53,7 @@ def _otel_span_attributes(sql) attributes = _otel_client_attributes(sql) if sql - attributes[SemanticConventions::Trace::DB_SQL_TABLE] = db_sql_table_name(sql) if config[:db_sql_table] == :include + attributes[SemanticConventions::Trace::DB_SQL_TABLE] = db_sql_table_name(sql) if db_sql_table_name(sql) && config[:db_sql_table] == :include case config[:db_statement] when :include @@ -98,6 +98,7 @@ def _otel_client_attributes(sql) def db_sql_table_name(sql) Regexp.last_match(1) if sql =~ TABLE_NAME rescue StandardError + OpenTelemetry.handle_error(message: 'Error extracting collection name', exception: e) nil end