Skip to content

Commit 46616da

Browse files
committed
Capture table names in double quotes
1 parent e73b23a commit 46616da

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

instrumentation/mysql2/lib/opentelemetry/instrumentation/mysql2/patches/client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module Patches
1414
# Module to prepend to Mysql2::Client for instrumentation
1515
module Client
1616
# Capture the first word (including letters, digits, underscores, & '.', ) that follows common table commands
17-
TABLE_NAME = /\b(?:(?:FROM|INTO|UPDATE)|(?:(?:CREATE|DROP|ALTER)\s+TABLE(?:\s+IF\s+(?:NOT\s+)?EXISTS)?))\s+["']?([\w.]+)["']?/i
17+
TABLE_NAME = /\b(?:(?:FROM|INTO|UPDATE)|(?:(?:CREATE|DROP|ALTER)\s+TABLE(?:\s+IF\s+(?:NOT\s+)?EXISTS)?))\s+["]?([\w.]+)["]?/i
1818

1919
def query(sql, options = {})
2020
tracer.in_span(

instrumentation/mysql2/test/fixtures/sql_table_name.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,9 @@
5050
{
5151
"name": "from_with_join",
5252
"sql": "SELECT columns FROM test_table JOIN table2 ON test_table.column = table2.column"
53+
},
54+
{
55+
"name": "table_name_with_double_quotes",
56+
"sql": "SELECT columns FROM \"test_table\""
5357
}
5458
]

instrumentation/trilogy/lib/opentelemetry/instrumentation/trilogy/patches/client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module Patches
1414
# Module to prepend to Trilogy for instrumentation
1515
module Client
1616
# Capture the first word (including letters, digits, underscores, & '.', ) that follows common table commands
17-
TABLE_NAME = /\b(?:(?:FROM|INTO|UPDATE)|(?:(?:CREATE|DROP|ALTER)\s+TABLE(?:\s+IF\s+(?:NOT\s+)?EXISTS)?))\s+["']?([\w.]+)["']?/i
17+
TABLE_NAME = /\b(?:(?:FROM|INTO|UPDATE)|(?:(?:CREATE|DROP|ALTER)\s+TABLE(?:\s+IF\s+(?:NOT\s+)?EXISTS)?))\s+["]?([\w.]+)["]?/i
1818

1919
def initialize(options = {})
2020
@connection_options = options # This is normally done by Trilogy#initialize

instrumentation/trilogy/test/fixtures/sql_table_name.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,9 @@
5050
{
5151
"name": "from_with_join",
5252
"sql": "SELECT columns FROM test_table JOIN table2 ON test_table.column = table2.column"
53+
},
54+
{
55+
"name": "table_name_with_double_quotes",
56+
"sql": "SELECT columns FROM \"test_table\""
5357
}
5458
]

0 commit comments

Comments
 (0)