File tree Expand file tree Collapse file tree 1 file changed +20
-3
lines changed
packages/core/src/tracing/instrumentation/database Expand file tree Collapse file tree 1 file changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -29,9 +29,26 @@ function instrumentMysql(mysql) {
29
29
}
30
30
31
31
function instrumentMysql2 ( mysql ) {
32
- instrumentConnection ( mysql . Connection . prototype , true ) ;
33
- if ( mysql . Pool ) {
34
- instrumentPool ( mysql . Pool . prototype ) ;
32
+ /**
33
+ * In mysql2 version 3.11.5 and later, the internal structure of the `Connection` and `Pool` classes was reorganized.
34
+ * Methods like `query` and `execute` were moved into the `BaseConnection` class located in `lib/base/connection.js`,
35
+ * and similar changes were applied to the `Pool` class. See: https://github.com/sidorares/node-mysql2/pull/3081
36
+ *
37
+ * Prior to v3.11.5, the `Connection` and `Pool` prototypes were directly used for instrumentation.
38
+ */
39
+ const connectionPrototype =
40
+ Object . getPrototypeOf ( mysql . Connection . prototype ) ?. constructor ?. name === 'BaseConnection'
41
+ ? Object . getPrototypeOf ( mysql . Connection . prototype )
42
+ : mysql . Connection . prototype ;
43
+
44
+ const poolPrototype =
45
+ mysql . Pool && Object . getPrototypeOf ( mysql . Pool . prototype ) ?. constructor ?. name === 'BasePool'
46
+ ? Object . getPrototypeOf ( mysql . Pool . prototype )
47
+ : mysql . Pool ?. prototype ;
48
+
49
+ instrumentConnection ( connectionPrototype , true ) ;
50
+ if ( poolPrototype ) {
51
+ instrumentPool ( poolPrototype ) ;
35
52
}
36
53
}
37
54
You can’t perform that action at this time.
0 commit comments