1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-07-21 13:47:39 +02:00

Revert "chore: use logger instead of console.error" (#10153)

Reverts Unleash/unleash#10150
This commit is contained in:
Mateusz Kwasniewski 2025-06-17 17:20:39 +02:00 committed by GitHub
parent 9bce7b9675
commit 6f7f48a361
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 21 deletions

View File

@ -72,13 +72,7 @@ export default class ClientMetricsServiceV2 {
}
async clearMetrics(hoursAgo: number) {
try {
await this.clientMetricsStoreV2.clearMetrics(hoursAgo);
} catch (e) {
this.logger.warn(
`Failed to clear client metrics older than ${hoursAgo} hours: ${e.message}`,
);
}
return this.clientMetricsStoreV2.clearMetrics(hoursAgo);
}
async clearDailyMetrics(daysAgo: number) {
@ -266,18 +260,12 @@ export default class ClientMetricsServiceV2 {
async bulkAdd(): Promise<void> {
if (this.unsavedMetrics.length > 0) {
try {
// Make a copy of `unsavedMetrics` in case new metrics
// arrive while awaiting `batchInsertMetrics`.
const copy = [...this.unsavedMetrics];
this.unsavedMetrics = [];
await this.clientMetricsStoreV2.batchInsertMetrics(copy);
this.config.eventBus.emit(CLIENT_METRICS_ADDED, copy);
} catch (error) {
this.logger.warn(
`Failed to bulk add client metrics: ${error.message}`,
);
}
// Make a copy of `unsavedMetrics` in case new metrics
// arrive while awaiting `batchInsertMetrics`.
const copy = [...this.unsavedMetrics];
this.unsavedMetrics = [];
await this.clientMetricsStoreV2.batchInsertMetrics(copy);
this.config.eventBus.emit(CLIENT_METRICS_ADDED, copy);
}
}

View File

@ -152,13 +152,13 @@ export const scheduleServices = (
);
schedulerService.schedule(
() => clientMetricsServiceV2.bulkAdd(),
() => clientMetricsServiceV2.bulkAdd().catch(console.error),
secondsToMilliseconds(5),
'bulkAddMetrics',
);
schedulerService.schedule(
() => clientMetricsServiceV2.clearMetrics(48),
() => clientMetricsServiceV2.clearMetrics(48).catch(console.error),
hoursToMilliseconds(12),
'clearMetrics',
);