Skip to content

remove duplicated metric capture #383

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 2 additions & 18 deletions src/cache/redis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import EventEmitter from 'events'
import Redis, { Result } from 'ioredis'
import Redlock from 'redlock'
import { CMD_SENT_STATUS, recordRedisCommandMetric } from '../metrics'
import { AdapterResponse, censorLogs, makeLogger, sleep } from '../util'
import { censorLogs, makeLogger, sleep } from '../util'
import { Cache, CacheEntry, LocalCache } from './index'
import { CacheTypes, cacheMetricsLabel, cacheSet } from './metrics'
import { CacheTypes } from './metrics'

declare module 'ioredis' {
interface RedisCommander<Context> {
Expand Down Expand Up @@ -108,22 +108,6 @@ export class RedisCache<T = unknown> implements Cache<T> {

await chain.exec()

// Loop again, but this time to record these in metrics
const now = Date.now()
for (const entry of entries) {
// Only record metrics if feed Id is present, otherwise assuming value is not adapter response to record
const response = entry.value as unknown as AdapterResponse
const feedId = response.meta?.metrics?.feedId
if (feedId) {
const providerTime = response.timestamps?.providerIndicatedTimeUnixMs
const timeDelta = providerTime ? now - providerTime : undefined

// Record cache set count, max age, and staleness (set to 0 for cache set)
const label = cacheMetricsLabel(entry.key, feedId, CacheTypes.Redis)
cacheSet(label, ttl, timeDelta)
}
}

// Record exec command sent to Redis
recordRedisCommandMetric(CMD_SENT_STATUS.SUCCESS, 'exec')
}
Expand Down