File tree 1 file changed +6
-3
lines changed
packages/tracing/src/integrations
1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -85,6 +85,7 @@ interface MongoCollection {
85
85
interface MongoOptions {
86
86
operations ?: Operation [ ] ;
87
87
describeOperations ?: boolean | Operation [ ] ;
88
+ useMongoose ?: boolean ;
88
89
}
89
90
90
91
/** Tracing integration for mongo package */
@@ -101,6 +102,7 @@ export class Mongo implements Integration {
101
102
102
103
private _operations : Operation [ ] ;
103
104
private _describeOperations ?: boolean | Operation [ ] ;
105
+ private _useMongoose : boolean ;
104
106
105
107
/**
106
108
* @inheritDoc
@@ -110,19 +112,20 @@ export class Mongo implements Integration {
110
112
? options . operations
111
113
: ( ( OPERATIONS as unknown ) as Operation [ ] ) ;
112
114
this . _describeOperations = 'describeOperations' in options ? options . describeOperations : true ;
115
+ this . _useMongoose = ! ! options . useMongoose ;
113
116
}
114
117
115
118
/**
116
119
* @inheritDoc
117
120
*/
118
121
public setupOnce ( _ : ( callback : EventProcessor ) => void , getCurrentHub : ( ) => Hub ) : void {
119
122
let collection : MongoCollection ;
120
-
123
+ const moduleName = this . _useMongoose ? 'mongoose' : 'mongodb' ;
121
124
try {
122
- const mongodbModule = dynamicRequire ( module , 'mongodb' ) as { Collection : MongoCollection } ;
125
+ const mongodbModule = dynamicRequire ( module , moduleName ) as { Collection : MongoCollection } ;
123
126
collection = mongodbModule . Collection ;
124
127
} catch ( e ) {
125
- logger . error ( ' Mongo Integration was unable to require `mongodb ` package.' ) ;
128
+ logger . error ( ` Mongo Integration was unable to require \` ${ moduleName } \ ` package.` ) ;
126
129
return ;
127
130
}
128
131
You can’t perform that action at this time.
0 commit comments