Skip to content

Commit ad1e32b

Browse files
committed
revert a few changes
1 parent 33174ee commit ad1e32b

File tree

2 files changed

+31
-18
lines changed

2 files changed

+31
-18
lines changed

src/log-delivery.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ export class CloudWatchLogPublisher extends LogPublisher {
126126
}
127127
try {
128128
// Delay to avoid throttling
129-
await delay(0.1);
129+
await delay(0.25);
130130
const record: InputLogEvent = {
131131
message,
132132
timestamp: Math.round(eventTime.getTime()),
@@ -222,6 +222,7 @@ export class CloudWatchLogPublisher extends LogPublisher {
222222
* * logs:CreateLogGroup
223223
* * logs:CreateLogStream
224224
* * logs:DescribeLogGroups
225+
* * logs:DescribeLogStreams
225226
*/
226227
export class CloudWatchLogHelper {
227228
private client: CloudWatchLogs;
@@ -261,7 +262,7 @@ export class CloudWatchLogHelper {
261262
);
262263
await this.emitMetricsForLoggingFailure(err);
263264
}
264-
return Promise.resolve(null);
265+
return null;
265266
}
266267

267268
private async doesLogGroupExist(): Promise<boolean> {

src/metrics.ts

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -200,19 +200,25 @@ export class MetricsPublisherProxy {
200200
timestamp: Date,
201201
action: Action,
202202
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);
207210
}
208211

209212
/**
210213
* Publishes a metric related to invocations to the list of publishers
211214
*/
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);
216222
}
217223

218224
/**
@@ -222,10 +228,13 @@ export class MetricsPublisherProxy {
222228
timestamp: Date,
223229
action: Action,
224230
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);
229238
}
230239

231240
/**
@@ -234,9 +243,12 @@ export class MetricsPublisherProxy {
234243
async publishLogDeliveryExceptionMetric(
235244
timestamp: Date,
236245
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);
241253
}
242254
}

0 commit comments

Comments
 (0)