diff --git a/src/backend/src/services/MeteringService/MeteringService.ts b/src/backend/src/services/MeteringService/MeteringService.ts index 84cb20764..cb5d1aeb9 100644 --- a/src/backend/src/services/MeteringService/MeteringService.ts +++ b/src/backend/src/services/MeteringService/MeteringService.ts @@ -14,8 +14,8 @@ import { toMicroCents } from './utils.js'; */ export class MeteringService { - static GLOBAL_SHARD_COUNT = 1000; // number of global usage shards to spread writes across - static APP_SHARD_COUNT = 1000; // number of app usage shards to spread writes across + static GLOBAL_SHARD_COUNT = 10000; // number of global usage shards to spread writes across + static APP_SHARD_COUNT = 10000; // number of app usage shards to spread writes across static MAX_GLOBAL_USAGE_PER_MINUTE = toMicroCents(.2); // 20 cents per minute max global usage to help detect abuse #kvStore: DynamoKVStore; #superUserService: SUService; @@ -137,7 +137,7 @@ export class MeteringService { key: puterConsumptionKey, pathAndAmountMap, }).catch((e: Error) => { - console.warn('Failed to increment aux usage data \'puterConsumptionKey\' with error: ', e); + console.warn(`Failed to increment aux usage data 'puterConsumptionKey' with error: ${ e.message} for userId: ${userId} appId: ${appId}`); }); const actorAppUsageKey = `${METRICS_PREFIX}:actor:${userId}:app:${appId}:${currentMonth}`; @@ -145,7 +145,7 @@ export class MeteringService { key: actorAppUsageKey, pathAndAmountMap, }).catch((e: Error) => { - console.warn('Failed to increment aux usage data \'actorAppUsageKey\' with error: ', e); + console.warn(`Failed to increment aux usage data 'actorAppUsageKey' with error: ${ e.message} for userId: ${userId} appId: ${appId}`); }); if ( appId !== GLOBAL_APP_KEY ) { @@ -154,7 +154,7 @@ export class MeteringService { key: appUsageKey, pathAndAmountMap, }).catch((e: Error) => { - console.warn('Failed to increment aux usage data \'appUsageKey\' with error: ', e); + console.warn(`Failed to increment aux usage data 'appUsageKey' with error: ${ e.message} for userId: ${userId} appId: ${appId}`); }); } @@ -166,7 +166,7 @@ export class MeteringService { [`${appId}.count`]: 1, }, }).catch((e: Error) => { - console.warn('Failed to increment aux usage data \'actorAppTotalsKey\' with error: ', e); + console.warn(`Failed to increment aux usage data 'actorAppTotalsKey' with error: ${ e.message} for userId: ${userId} appId: ${appId}`); }); const lastUpdatedKey = `${METRICS_PREFIX}:actor:${userId}:lastUpdated`; @@ -174,7 +174,7 @@ export class MeteringService { key: lastUpdatedKey, value: Date.now(), }).catch((e: Error) => { - console.warn('Failed to set lastUpdatedKey with error: ', e); + console.warn('Failed to set lastUpdatedKey with error: ', e.message); }); // update addon usage if we are over the allowance @@ -317,7 +317,7 @@ export class MeteringService { key: puterConsumptionKey, pathAndAmountMap: aggregatedPathAndAmountMap, }).catch((e: Error) => { - console.warn('Failed to increment aux usage data \'puterConsumptionKey\' with error: ', e); + console.warn(`Failed to increment aux usage data 'puterConsumptionKey' with error: ${ e.message} for userId: ${userId} appId: ${appId}`); }); const actorAppUsageKey = `${METRICS_PREFIX}:actor:${userId}:app:${appId}:${currentMonth}`; @@ -325,7 +325,7 @@ export class MeteringService { key: actorAppUsageKey, pathAndAmountMap: aggregatedPathAndAmountMap, }).catch((e: Error) => { - console.warn('Failed to increment aux usage data \'actorAppUsageKey\' with error: ', e); + console.warn(`Failed to increment aux usage data 'actorAppUsageKey' with error: ${ e.message} for userId: ${userId} appId: ${appId}`); }); const appUsageKey = this.#generateAppUsageKey(appId, userId, currentMonth); @@ -333,7 +333,7 @@ export class MeteringService { key: appUsageKey, pathAndAmountMap: aggregatedPathAndAmountMap, }).catch((e: Error) => { - console.warn('Failed to increment aux usage data \'appUsageKey\' with error: ', e); + console.warn(`Failed to increment aux usage data 'appUsageKey' with error: ${ e.message} for userId: ${userId} appId: ${appId}`); }); const actorAppTotalsKey = `${METRICS_PREFIX}:actor:${userId}:apps:${currentMonth}`; @@ -344,7 +344,7 @@ export class MeteringService { [`${appId}.count`]: usages.length, }, }).catch((e: Error) => { - console.warn('Failed to increment aux usage data \'actorAppTotalsKey\' with error: ', e); + console.warn(`Failed to increment aux usage data 'actorAppTotalsKey' with error: ${ e.message} for userId: ${userId} appId: ${appId}`); }); const lastUpdatedKey = `${METRICS_PREFIX}:actor:${userId}:lastUpdated`; @@ -352,7 +352,7 @@ export class MeteringService { key: lastUpdatedKey, value: Date.now(), }).catch((e: Error) => { - console.warn('Failed to set lastUpdatedKey with error: ', e); + console.warn(`Failed to set lastUpdatedKey with error: ${ e.message}`); }); // update addon usage if we are over the allowance @@ -495,7 +495,7 @@ export class MeteringService { key: puterConsumptionKey, pathAndAmountMap, }).catch((e: Error) => { - console.warn('Failed to increment aux usage data \'puterConsumptionKey\' with error: ', e); + console.warn(`Failed to increment aux usage data 'puterConsumptionKey' with error: ${ e.message} for userId: ${userId} appId: ${appId}`); }); const actorAppUsageKey = `${METRICS_PREFIX}:actor:${userId}:app:${appId}:${currentMonth}`; @@ -503,7 +503,7 @@ export class MeteringService { key: actorAppUsageKey, pathAndAmountMap, }).catch((e: Error) => { - console.warn('Failed to increment aux usage data \'actorAppUsageKey\' with error: ', e); + console.warn(`Failed to increment aux usage data 'actorAppUsageKey' with error: ${ e.message} for userId: ${userId} appId: ${appId}`); }); const actorAppTotalsKey = `${METRICS_PREFIX}:actor:${userId}:apps:${currentMonth}`;