File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
packages/tracing/src/integrations Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -85,6 +85,7 @@ interface MongoCollection {
8585interface MongoOptions {
8686 operations ?: Operation [ ] ;
8787 describeOperations ?: boolean | Operation [ ] ;
88+ useMongoose ?: boolean ;
8889}
8990
9091/** Tracing integration for mongo package */
@@ -101,6 +102,7 @@ export class Mongo implements Integration {
101102
102103 private _operations : Operation [ ] ;
103104 private _describeOperations ?: boolean | Operation [ ] ;
105+ private _useMongoose : boolean ;
104106
105107 /**
106108 * @inheritDoc
@@ -110,19 +112,20 @@ export class Mongo implements Integration {
110112 ? options . operations
111113 : ( ( OPERATIONS as unknown ) as Operation [ ] ) ;
112114 this . _describeOperations = 'describeOperations' in options ? options . describeOperations : true ;
115+ this . _useMongoose = ! ! options . useMongoose ;
113116 }
114117
115118 /**
116119 * @inheritDoc
117120 */
118121 public setupOnce ( _ : ( callback : EventProcessor ) => void , getCurrentHub : ( ) => Hub ) : void {
119122 let collection : MongoCollection ;
120-
123+ const moduleName = this . _useMongoose ? 'mongoose' : 'mongodb' ;
121124 try {
122- const mongodbModule = dynamicRequire ( module , 'mongodb' ) as { Collection : MongoCollection } ;
125+ const mongodbModule = dynamicRequire ( module , moduleName ) as { Collection : MongoCollection } ;
123126 collection = mongodbModule . Collection ;
124127 } catch ( e ) {
125- logger . error ( ' Mongo Integration was unable to require `mongodb ` package.' ) ;
128+ logger . error ( ` Mongo Integration was unable to require \` ${ moduleName } \ ` package.` ) ;
126129 return ;
127130 }
128131
You can’t perform that action at this time.
0 commit comments