fix(syncing-server): add debug logs to redis metrics store
This commit is contained in:
parent
73c2cc1222
commit
a4ad37f309
2 changed files with 24 additions and 1 deletions
|
@ -585,7 +585,11 @@ export class ContainerConfigLoader {
|
|||
container
|
||||
.bind<MetricsStoreInterface>(TYPES.Sync_MetricsStore)
|
||||
.toConstantValue(
|
||||
new RedisMetricStore(container.get<Redis>(TYPES.Sync_Redis), container.get<TimerInterface>(TYPES.Sync_Timer)),
|
||||
new RedisMetricStore(
|
||||
container.get<Redis>(TYPES.Sync_Redis),
|
||||
container.get<TimerInterface>(TYPES.Sync_Timer),
|
||||
container.get<Logger>(TYPES.Sync_Logger),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import { MetricsStoreInterface } from '../../Domain/Metrics/MetricsStoreInterfac
|
|||
import { Metric } from '../../Domain/Metrics/Metric'
|
||||
import { Uuid } from '@standardnotes/domain-core'
|
||||
import { MetricsSummary } from '../../Domain/Metrics/MetricsSummary'
|
||||
import { Logger } from 'winston'
|
||||
|
||||
export class RedisMetricStore implements MetricsStoreInterface {
|
||||
private readonly METRIC_PREFIX = 'metric'
|
||||
|
@ -13,6 +14,7 @@ export class RedisMetricStore implements MetricsStoreInterface {
|
|||
constructor(
|
||||
private redisClient: IORedis.Redis,
|
||||
private timer: TimerInterface,
|
||||
private logger: Logger,
|
||||
) {}
|
||||
|
||||
async getUserBasedMetricsSummaryWithinTimeRange(dto: {
|
||||
|
@ -21,8 +23,20 @@ export class RedisMetricStore implements MetricsStoreInterface {
|
|||
from: Date
|
||||
to: Date
|
||||
}): Promise<MetricsSummary> {
|
||||
this.logger.debug(`Fetching user based metrics summary for ${dto.metricName}.`, {
|
||||
codeTag: 'RedisMetricStore',
|
||||
userId: dto.userUuid.value,
|
||||
from: dto.from.toISOString(),
|
||||
to: dto.to.toISOString(),
|
||||
})
|
||||
|
||||
const keys = this.getKeysRepresentingMinutesBetweenFromAndTo(dto.from, dto.to)
|
||||
|
||||
this.logger.debug(`Fetching user based metrics summary for ${dto.metricName} - keys: ${keys.join(', ')}.`, {
|
||||
codeTag: 'RedisMetricStore',
|
||||
userId: dto.userUuid.value,
|
||||
})
|
||||
|
||||
let sum = 0
|
||||
let max = 0
|
||||
let min = 0
|
||||
|
@ -32,6 +46,11 @@ export class RedisMetricStore implements MetricsStoreInterface {
|
|||
keys.map((key) => `${this.METRIC_PER_USER_PREFIX}:${dto.userUuid.value}:${dto.metricName}:${key}`),
|
||||
)
|
||||
|
||||
this.logger.debug(`Fetching user based metrics summary for ${dto.metricName} - values: ${values.join(', ')}.`, {
|
||||
codeTag: 'RedisMetricStore',
|
||||
userId: dto.userUuid.value,
|
||||
})
|
||||
|
||||
for (const value of values) {
|
||||
if (!value) {
|
||||
continue
|
||||
|
|
Loading…
Reference in a new issue