@@ -3,7 +3,6 @@ import { EventProcessor, Integration } from '@sentry/types';
3
3
import { dynamicRequire , fill , logger } from '@sentry/utils' ;
4
4
5
5
interface MysqlConnection {
6
- end : ( ) => void ;
7
6
prototype : {
8
7
query : ( ) => void ;
9
8
} ;
@@ -28,23 +27,18 @@ export class Mysql implements Integration {
28
27
let connection : MysqlConnection ;
29
28
30
29
try {
31
- const mysqlModule = dynamicRequire ( module , 'mysql' ) as {
32
- createConnection : ( options : unknown ) => MysqlConnection ;
33
- } ;
34
- const conn = mysqlModule . createConnection ( { } ) ;
35
- connection = ( conn . constructor as unknown ) as MysqlConnection ;
36
- conn . end ( ) ;
30
+ // Unfortunatelly mysql is using some custom loading system and `Connection` is not exported directly.
31
+ connection = dynamicRequire ( module , 'mysql/lib/Connection.js' ) ;
37
32
} catch ( e ) {
38
33
logger . error ( 'Mysql Integration was unable to require `mysql` package.' ) ;
39
34
return ;
40
35
}
41
36
42
37
// The original function will have one of these signatures:
43
- // function (query, callback) => void
44
- // function (query, params, callback) => void
45
- // function (query) => Promise
46
- // function (query, params) => Promise
47
- fill ( connection , 'query' , function ( orig : ( ) => void | Promise < unknown > ) {
38
+ // function (callback) => void
39
+ // function (options, callback) => void
40
+ // function (options, values, callback) => void
41
+ fill ( connection . prototype , 'query' , function ( orig : ( ) => void ) {
48
42
return function ( this : unknown , options : unknown , values : unknown , callback : unknown ) {
49
43
const scope = getCurrentHub ( ) . getScope ( ) ;
50
44
const transaction = scope ?. getTransaction ( ) ;
0 commit comments