Skip to content

Commit

Permalink
Use same approach in connection.query
Browse files Browse the repository at this point in the history
  • Loading branch information
uurien committed Sep 23, 2024
1 parent d09f6f9 commit 8cbae0f
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions packages/datadog-instrumentations/src/mysql2.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,14 @@ addHook({ name: 'mysql2', file: 'lib/connection.js', versions: ['>=1'] }, (Conne
startOuterQueryCh.publish({ sql: sqlString, abortController })

if (abortController.signal.aborted) {
let queryCommand = sql
if (sqlIsString) {
queryCommand = Connection.createQuery(sqlString, values, cb, this.config)
const addCommand = this.addCommand
this.addCommand = function (cmd) { return cmd }

let queryCommand
try {
queryCommand = query.apply(this, arguments)
} finally {
this.addCommand = addCommand
}

cb = queryCommand.onResult
Expand Down Expand Up @@ -78,7 +83,7 @@ addHook({ name: 'mysql2', file: 'lib/connection.js', versions: ['>=1'] }, (Conne

if (abortController.signal.aborted) {
const addCommand = this.addCommand
this.addCommand = function () {}
this.addCommand = function (cmd) { return cmd }

let result
try {
Expand Down

0 comments on commit 8cbae0f

Please sign in to comment.