File tree Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ class ClientPrintConnectHandler extends Handler {
67
67
}
68
68
this . response . body = { doc : code } ;
69
69
if ( params . printer && params . printer !== client . printer ) this . response . body . setPrinter = client . printer ;
70
- await this . ctx . parallel ( 'print/sendTask' ) ;
70
+ await this . ctx . parallel ( 'print/sendTask' , client . _id ) ;
71
71
logger . info ( `Client ${ client . name } connected, print task ${ code . tid } #${ code . _id } sent.` ) ;
72
72
await this . ctx . db . code . updateOne ( { _id : code . _id } , { $set : { printer : params . cid , receivedAt : new Date ( ) . getTime ( ) } } ) ;
73
73
}
@@ -81,7 +81,7 @@ class ClientPrintDoneHandler extends Handler {
81
81
if ( ! code ) throw new ValidationError ( 'Code' , null , 'Code not found' ) ;
82
82
if ( code . printer !== params . cid ) throw new BadRequestError ( 'Client' , null , 'Client not match' ) ;
83
83
await this . ctx . db . code . updateOne ( { _id : params . tid } , { $set : { done : 1 , doneAt : new Date ( ) . getTime ( ) } } ) ;
84
- await this . ctx . parallel ( 'print/doneTask' ) ;
84
+ await this . ctx . parallel ( 'print/doneTask' , client . _id ) ;
85
85
this . response . body = { code : 1 } ;
86
86
logger . info ( `Client ${ client . name } connected, print task ${ code . tid } #${ code . _id } completed.` ) ;
87
87
}
Original file line number Diff line number Diff line change @@ -9,8 +9,8 @@ declare module 'cordis' {
9
9
}
10
10
interface Events {
11
11
'print/newTask' : ( ) => void ;
12
- 'print/sendTask' : ( ) => void ;
13
- 'print/doneTask' : ( ) => void ;
12
+ 'print/sendTask' : ( client : string ) => void ;
13
+ 'print/doneTask' : ( client : string ) => void ;
14
14
}
15
15
}
16
16
@@ -36,13 +36,13 @@ export function createMetricsRegistry(ctx: Context) {
36
36
} ) ;
37
37
38
38
const printTaskCounter = createMetric ( Counter , 'xcpc_printcount' , 'printcount' , {
39
- labelNames : [ 'status' ] ,
39
+ labelNames : [ 'status' , 'client' ] ,
40
40
} ) ;
41
41
ctx . on ( 'print/newTask' , ( ) => printTaskCounter . inc ( { status : 'new' } ) ) ;
42
42
43
- ctx . on ( 'print/sendTask' , ( ) => printTaskCounter . inc ( { status : 'sent' } ) ) ;
43
+ ctx . on ( 'print/sendTask' , ( client ) => printTaskCounter . inc ( { status : 'sent' , client } ) ) ;
44
44
45
- ctx . on ( 'print/doneTask' , ( ) => printTaskCounter . inc ( { status : 'done' } ) ) ;
45
+ ctx . on ( 'print/doneTask' , ( client ) => printTaskCounter . inc ( { status : 'done' , client } ) ) ;
46
46
47
47
collectDefaultMetrics ( { register : registry } ) ;
48
48
You can’t perform that action at this time.
0 commit comments