@@ -200,19 +200,25 @@ export class MetricsPublisherProxy {
200
200
timestamp : Date ,
201
201
action : Action ,
202
202
error : Error
203
- ) : Promise < void > {
204
- for ( const publisher of this . publishers ) {
205
- await publisher . publishExceptionMetric ( timestamp , action , error ) ;
206
- }
203
+ ) : Promise < any > {
204
+ const promises : Array < Promise < void > > = this . publishers . map (
205
+ ( publisher : MetricsPublisher ) => {
206
+ return publisher . publishExceptionMetric ( timestamp , action , error ) ;
207
+ }
208
+ ) ;
209
+ return await Promise . all ( promises ) ;
207
210
}
208
211
209
212
/**
210
213
* Publishes a metric related to invocations to the list of publishers
211
214
*/
212
- async publishInvocationMetric ( timestamp : Date , action : Action ) : Promise < void > {
213
- for ( const publisher of this . publishers ) {
214
- await publisher . publishInvocationMetric ( timestamp , action ) ;
215
- }
215
+ async publishInvocationMetric ( timestamp : Date , action : Action ) : Promise < any > {
216
+ const promises : Array < Promise < void > > = this . publishers . map (
217
+ ( publisher : MetricsPublisher ) => {
218
+ return publisher . publishInvocationMetric ( timestamp , action ) ;
219
+ }
220
+ ) ;
221
+ return await Promise . all ( promises ) ;
216
222
}
217
223
218
224
/**
@@ -222,10 +228,13 @@ export class MetricsPublisherProxy {
222
228
timestamp : Date ,
223
229
action : Action ,
224
230
milliseconds : number
225
- ) : Promise < void > {
226
- for ( const publisher of this . publishers ) {
227
- await publisher . publishDurationMetric ( timestamp , action , milliseconds ) ;
228
- }
231
+ ) : Promise < any > {
232
+ const promises : Array < Promise < void > > = this . publishers . map (
233
+ ( publisher : MetricsPublisher ) => {
234
+ return publisher . publishDurationMetric ( timestamp , action , milliseconds ) ;
235
+ }
236
+ ) ;
237
+ return await Promise . all ( promises ) ;
229
238
}
230
239
231
240
/**
@@ -234,9 +243,12 @@ export class MetricsPublisherProxy {
234
243
async publishLogDeliveryExceptionMetric (
235
244
timestamp : Date ,
236
245
error : Error
237
- ) : Promise < void > {
238
- for ( const publisher of this . publishers ) {
239
- await publisher . publishLogDeliveryExceptionMetric ( timestamp , error ) ;
240
- }
246
+ ) : Promise < any > {
247
+ const promises : Array < Promise < void > > = this . publishers . map (
248
+ ( publisher : MetricsPublisher ) => {
249
+ return publisher . publishLogDeliveryExceptionMetric ( timestamp , error ) ;
250
+ }
251
+ ) ;
252
+ return await Promise . all ( promises ) ;
241
253
}
242
254
}
0 commit comments