Files
awesome-reviewers/_reviewers/posthog-add-monitoring-metrics.json
2025-08-19 12:19:58 +00:00

70 lines
8.8 KiB
JSON

[
{
"discussion_id": "2284256153",
"pr_number": 36307,
"pr_file": "plugin-server/src/main/ingestion-queues/session-recording-v2/retention/retention-service.ts",
"created_at": "2025-08-19T06:33:51+00:00",
"commented_code": "+import { RedisPool, Team } from '../../../../types'\n+import { TeamId } from '../../../../types'\n+import { BackgroundRefresher } from '../../../../utils/background-refresher'\n+import { PostgresRouter, PostgresUse } from '../../../../utils/db/postgres'\n+import { logger } from '../../../../utils/logger'\n+import { ValidRetentionPeriods } from '../constants'\n+import { MessageWithTeam } from '../teams/types'\n+import { RetentionPeriod } from '../types'\n+import { MessageWithRetention } from './types'\n+\n+function isValidRetentionPeriod(retentionPeriod: string): retentionPeriod is RetentionPeriod {\n+ return ValidRetentionPeriods.includes(retentionPeriod as RetentionPeriod)\n+}\n+\n+export class RetentionService {\n+ private readonly retentionRefresher: BackgroundRefresher<Record<TeamId, RetentionPeriod>>\n+\n+ constructor(\n+ private postgres: PostgresRouter,\n+ private redisPool: RedisPool,\n+ private keyPrefix = '@posthog/replay/'\n+ ) {\n+ this.retentionRefresher = new BackgroundRefresher(\n+ () => this.fetchTeamRetentionPeriods(),\n+ 5 * 60 * 1000, // 5 minutes\n+ (e) => {\n+ // We ignore the error and wait for postgres to recover\n+ logger.error('Error refreshing team retention periods', e)",
"repo_full_name": "PostHog/posthog",
"discussion_comments": [
{
"comment_id": "2284256153",
"repo_full_name": "PostHog/posthog",
"pr_number": 36307,
"pr_file": "plugin-server/src/main/ingestion-queues/session-recording-v2/retention/retention-service.ts",
"discussion_id": "2284256153",
"commented_code": "@@ -0,0 +1,111 @@\n+import { RedisPool, Team } from '../../../../types'\n+import { TeamId } from '../../../../types'\n+import { BackgroundRefresher } from '../../../../utils/background-refresher'\n+import { PostgresRouter, PostgresUse } from '../../../../utils/db/postgres'\n+import { logger } from '../../../../utils/logger'\n+import { ValidRetentionPeriods } from '../constants'\n+import { MessageWithTeam } from '../teams/types'\n+import { RetentionPeriod } from '../types'\n+import { MessageWithRetention } from './types'\n+\n+function isValidRetentionPeriod(retentionPeriod: string): retentionPeriod is RetentionPeriod {\n+ return ValidRetentionPeriods.includes(retentionPeriod as RetentionPeriod)\n+}\n+\n+export class RetentionService {\n+ private readonly retentionRefresher: BackgroundRefresher<Record<TeamId, RetentionPeriod>>\n+\n+ constructor(\n+ private postgres: PostgresRouter,\n+ private redisPool: RedisPool,\n+ private keyPrefix = '@posthog/replay/'\n+ ) {\n+ this.retentionRefresher = new BackgroundRefresher(\n+ () => this.fetchTeamRetentionPeriods(),\n+ 5 * 60 * 1000, // 5 minutes\n+ (e) => {\n+ // We ignore the error and wait for postgres to recover\n+ logger.error('Error refreshing team retention periods', e)",
"comment_created_at": "2025-08-19T06:33:51+00:00",
"comment_author": "pauldambra",
"comment_body": "we could have a prom counter here \ud83e\udd14 trying to picture what grafana dashboard I'd want to make to know if this all was working when deployed (and what we might want to alert on...)",
"pr_file_module": null
},
{
"comment_id": "2284549572",
"repo_full_name": "PostHog/posthog",
"pr_number": 36307,
"pr_file": "plugin-server/src/main/ingestion-queues/session-recording-v2/retention/retention-service.ts",
"discussion_id": "2284256153",
"commented_code": "@@ -0,0 +1,111 @@\n+import { RedisPool, Team } from '../../../../types'\n+import { TeamId } from '../../../../types'\n+import { BackgroundRefresher } from '../../../../utils/background-refresher'\n+import { PostgresRouter, PostgresUse } from '../../../../utils/db/postgres'\n+import { logger } from '../../../../utils/logger'\n+import { ValidRetentionPeriods } from '../constants'\n+import { MessageWithTeam } from '../teams/types'\n+import { RetentionPeriod } from '../types'\n+import { MessageWithRetention } from './types'\n+\n+function isValidRetentionPeriod(retentionPeriod: string): retentionPeriod is RetentionPeriod {\n+ return ValidRetentionPeriods.includes(retentionPeriod as RetentionPeriod)\n+}\n+\n+export class RetentionService {\n+ private readonly retentionRefresher: BackgroundRefresher<Record<TeamId, RetentionPeriod>>\n+\n+ constructor(\n+ private postgres: PostgresRouter,\n+ private redisPool: RedisPool,\n+ private keyPrefix = '@posthog/replay/'\n+ ) {\n+ this.retentionRefresher = new BackgroundRefresher(\n+ () => this.fetchTeamRetentionPeriods(),\n+ 5 * 60 * 1000, // 5 minutes\n+ (e) => {\n+ // We ignore the error and wait for postgres to recover\n+ logger.error('Error refreshing team retention periods', e)",
"comment_created_at": "2025-08-19T08:36:45+00:00",
"comment_author": "TueHaulund",
"comment_body": "This code is somewhat plagiarized from the teams service: https://github.com/PostHog/posthog/blob/master/plugin-server/src/main/ingestion-queues/session-recording-v2/teams/team-service.ts#L12\r\n\r\nGiven that it's quite battle tested I consider this part of the PR quite low risk. That being said a counter here (and also in the teams service) would make sense so it's not just failing silently for a long time, eventually we would have a very stale in-memory copy that would start to cause issues.",
"pr_file_module": null
},
{
"comment_id": "2284552442",
"repo_full_name": "PostHog/posthog",
"pr_number": 36307,
"pr_file": "plugin-server/src/main/ingestion-queues/session-recording-v2/retention/retention-service.ts",
"discussion_id": "2284256153",
"commented_code": "@@ -0,0 +1,111 @@\n+import { RedisPool, Team } from '../../../../types'\n+import { TeamId } from '../../../../types'\n+import { BackgroundRefresher } from '../../../../utils/background-refresher'\n+import { PostgresRouter, PostgresUse } from '../../../../utils/db/postgres'\n+import { logger } from '../../../../utils/logger'\n+import { ValidRetentionPeriods } from '../constants'\n+import { MessageWithTeam } from '../teams/types'\n+import { RetentionPeriod } from '../types'\n+import { MessageWithRetention } from './types'\n+\n+function isValidRetentionPeriod(retentionPeriod: string): retentionPeriod is RetentionPeriod {\n+ return ValidRetentionPeriods.includes(retentionPeriod as RetentionPeriod)\n+}\n+\n+export class RetentionService {\n+ private readonly retentionRefresher: BackgroundRefresher<Record<TeamId, RetentionPeriod>>\n+\n+ constructor(\n+ private postgres: PostgresRouter,\n+ private redisPool: RedisPool,\n+ private keyPrefix = '@posthog/replay/'\n+ ) {\n+ this.retentionRefresher = new BackgroundRefresher(\n+ () => this.fetchTeamRetentionPeriods(),\n+ 5 * 60 * 1000, // 5 minutes\n+ (e) => {\n+ // We ignore the error and wait for postgres to recover\n+ logger.error('Error refreshing team retention periods', e)",
"comment_created_at": "2025-08-19T08:37:51+00:00",
"comment_author": "TueHaulund",
"comment_body": "Will add an error counter \ud83d\udc4d ",
"pr_file_module": null
}
]
},
{
"discussion_id": "2259808025",
"pr_number": 36291,
"pr_file": "plugin-server/src/worker/ingestion/event-pipeline/runner.ts",
"created_at": "2025-08-07T10:11:07+00:00",
"commented_code": "if (!key) {\n return false // for safety don't drop events here, they are later dropped in teamDataPopulation\n }\n+\n+ if (event.event === '$exception') {",
"repo_full_name": "PostHog/posthog",
"discussion_comments": [
{
"comment_id": "2259808025",
"repo_full_name": "PostHog/posthog",
"pr_number": 36291,
"pr_file": "plugin-server/src/worker/ingestion/event-pipeline/runner.ts",
"discussion_id": "2259808025",
"commented_code": "@@ -85,6 +84,13 @@ export class EventPipelineRunner {\n if (!key) {\n return false // for safety don't drop events here, they are later dropped in teamDataPopulation\n }\n+\n+ if (event.event === '$exception') {",
"comment_created_at": "2025-08-07T10:11:07+00:00",
"comment_author": "oliverb123",
"comment_body": "Might be nice to add a metric here we can have an alert on?",
"pr_file_module": null
}
]
}
]