Skip to content

Commit

Permalink
revert a few changes
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardomourar committed Nov 28, 2020
1 parent 33174ee commit ad1e32b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 18 deletions.
5 changes: 3 additions & 2 deletions src/log-delivery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export class CloudWatchLogPublisher extends LogPublisher {
}
try {
// Delay to avoid throttling
await delay(0.1);
await delay(0.25);
const record: InputLogEvent = {
message,
timestamp: Math.round(eventTime.getTime()),
Expand Down Expand Up @@ -222,6 +222,7 @@ export class CloudWatchLogPublisher extends LogPublisher {
* * logs:CreateLogGroup
* * logs:CreateLogStream
* * logs:DescribeLogGroups
* * logs:DescribeLogStreams
*/
export class CloudWatchLogHelper {
private client: CloudWatchLogs;
Expand Down Expand Up @@ -261,7 +262,7 @@ export class CloudWatchLogHelper {
);
await this.emitMetricsForLoggingFailure(err);
}
return Promise.resolve(null);
return null;
}

private async doesLogGroupExist(): Promise<boolean> {
Expand Down
44 changes: 28 additions & 16 deletions src/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,19 +200,25 @@ export class MetricsPublisherProxy {
timestamp: Date,
action: Action,
error: Error
): Promise<void> {
for (const publisher of this.publishers) {
await publisher.publishExceptionMetric(timestamp, action, error);
}
): Promise<any> {
const promises: Array<Promise<void>> = this.publishers.map(
(publisher: MetricsPublisher) => {
return publisher.publishExceptionMetric(timestamp, action, error);
}
);
return await Promise.all(promises);
}

/**
* Publishes a metric related to invocations to the list of publishers
*/
async publishInvocationMetric(timestamp: Date, action: Action): Promise<void> {
for (const publisher of this.publishers) {
await publisher.publishInvocationMetric(timestamp, action);
}
async publishInvocationMetric(timestamp: Date, action: Action): Promise<any> {
const promises: Array<Promise<void>> = this.publishers.map(
(publisher: MetricsPublisher) => {
return publisher.publishInvocationMetric(timestamp, action);
}
);
return await Promise.all(promises);
}

/**
Expand All @@ -222,10 +228,13 @@ export class MetricsPublisherProxy {
timestamp: Date,
action: Action,
milliseconds: number
): Promise<void> {
for (const publisher of this.publishers) {
await publisher.publishDurationMetric(timestamp, action, milliseconds);
}
): Promise<any> {
const promises: Array<Promise<void>> = this.publishers.map(
(publisher: MetricsPublisher) => {
return publisher.publishDurationMetric(timestamp, action, milliseconds);
}
);
return await Promise.all(promises);
}

/**
Expand All @@ -234,9 +243,12 @@ export class MetricsPublisherProxy {
async publishLogDeliveryExceptionMetric(
timestamp: Date,
error: Error
): Promise<void> {
for (const publisher of this.publishers) {
await publisher.publishLogDeliveryExceptionMetric(timestamp, error);
}
): Promise<any> {
const promises: Array<Promise<void>> = this.publishers.map(
(publisher: MetricsPublisher) => {
return publisher.publishLogDeliveryExceptionMetric(timestamp, error);
}
);
return await Promise.all(promises);
}
}

0 comments on commit ad1e32b

Please sign in to comment.