@@ -26,7 +26,8 @@ type BeforeQueryHook = (
26
26
) => Promise < void > ;
27
27
28
28
type QueryOptions = {
29
- beforeQuery : BeforeQueryHook ;
29
+ beforeQuery ?: BeforeQueryHook ;
30
+ metadata ?: object ;
30
31
} ;
31
32
32
33
export class DBM {
@@ -44,7 +45,7 @@ export class DBM {
44
45
* Timestamp when the query was added to the queue
45
46
*/
46
47
timestamp : number ;
47
- options ?: { beforeQuery : BeforeQueryHook } ;
48
+ options ?: QueryOptions ;
48
49
} [ ] = [ ] ;
49
50
private beforeQuery ?: ( {
50
51
query,
@@ -149,6 +150,7 @@ export class DBM {
149
150
this . _emitEvent ( {
150
151
event_name : 'mount_file_buffer_duration' ,
151
152
duration : endMountTime - startMountTime ,
153
+ metadata : options ?. metadata ,
152
154
} ) ;
153
155
154
156
const tablesFileData = await this . fileManager . getFilesNameForTables (
@@ -181,6 +183,7 @@ export class DBM {
181
183
this . _emitEvent ( {
182
184
event_name : 'query_execution_duration' ,
183
185
duration : queryQueueDuration ,
186
+ metadata : options ?. metadata ,
184
187
} ) ;
185
188
186
189
/**
@@ -200,6 +203,7 @@ export class DBM {
200
203
this . _emitEvent ( {
201
204
event_name : 'unmount_file_buffer_duration' ,
202
205
duration : endUnmountTime - startUnmountTime ,
206
+ metadata : options ?. metadata ,
203
207
} ) ;
204
208
205
209
return result ;
@@ -223,12 +227,13 @@ export class DBM {
223
227
* If there is no query in the queue, stop the queue
224
228
* Recursively call itself to execute the next query
225
229
*/
226
- private async _startQueryExecution ( ) {
230
+ private async _startQueryExecution ( metadata ?: object ) {
227
231
this . logger . debug ( 'Query queue length:' , this . queriesQueue . length ) ;
228
232
229
233
this . _emitEvent ( {
230
234
event_name : 'query_queue_length' ,
231
235
value : this . queriesQueue . length ,
236
+ metadata,
232
237
} ) ;
233
238
234
239
/**
@@ -255,6 +260,7 @@ export class DBM {
255
260
this . _emitEvent ( {
256
261
event_name : 'query_queue_duration' ,
257
262
duration : startTime - queueElement . timestamp ,
263
+ metadata,
258
264
} ) ;
259
265
260
266
/**
@@ -288,7 +294,7 @@ export class DBM {
288
294
/**
289
295
* Start the next query
290
296
*/
291
- this . _startQueryExecution ( ) ;
297
+ this . _startQueryExecution ( queueElement . options ?. metadata ) ;
292
298
}
293
299
294
300
/**
@@ -315,7 +321,7 @@ export class DBM {
315
321
public async queryWithTableNames (
316
322
query : string ,
317
323
tableNames : string [ ] ,
318
- options ?: { beforeQuery : BeforeQueryHook }
324
+ options ?: QueryOptions
319
325
) {
320
326
const promise = new Promise ( ( resolve , reject ) => {
321
327
this . queriesQueue . push ( {
0 commit comments