Repository navigation
feat(flags): push coverage stats for the flag definitions cache - #96662
Merged
Merged
Conversation
The hourly definitions refresh task never called get_cache_stats, so
posthog_hypercache_coverage_percent{cache_name="flag_definitions"} did not
exist and the backfill-coverage question could only be answered from a
management command's stdout. Call the generic with the definitions config,
mirroring the flags task.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
😎 Merged successfully - details. |
Contributor
Contributor
🤖 CI report
|
Contributor
Prompt To Fix All With AI### Issue 1
products/feature_flags/backend/tasks.py:495
**Comment narrates the code**
This comment only restates that the next call scans and pushes cache statistics. The repository requires comments to explain non-obvious rationale rather than narrate the code, so this requirement must be satisfied before merging.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (1): Last reviewed commit: "feat(flags): push coverage stats for the..." | Re-trigger Greptile |
| successful_gauge.set(counts.successful) | ||
| failed_gauge.set(counts.failed) | ||
|
|
||
| # Scan after refresh for metrics (pushes to Pushgateway via get_cache_stats) |
Contributor
There was a problem hiding this comment.
This comment only restates that the next call scans and pushes cache statistics. The repository requires comments to explain non-obvious rationale rather than narrate the code, so this requirement must be satisfied before merging.
Context Used: AGENTS.MD (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: products/feature_flags/backend/tasks.py
Line: 495
Comment:
**Comment narrates the code**
This comment only restates that the next call scans and pushes cache statistics. The repository requires comments to explain non-obvious rationale rather than narrate the code, so this requirement must be satisfied before merging.
**Context Used:** AGENTS.MD ([source](https://github.com/posthog/posthog/blob/master/AGENTS.MD))
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Member
Author
|
/trunk merge |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Problem
Nobody can see how much of the flag definitions cache is populated without running a management command and reading its stdout.
posthog_hypercache_coverage_percent{cache_name="flag_definitions"}returns nothing, whilecache_name="flags"returns a series.get_cache_stats. The sibling flags task does.Changes
get_cache_statswithFLAG_DEFINITIONS_HYPERCACHE_MANAGEMENT_CONFIG, which already carriescache_name="flag_definitions".SCANplus a sampledMEMORY USAGEpass. The flags cache runs the identical pass on the same cluster 20 minutes earlier, at :15 against this task's :35.Note
The coverage percent divides cached entries by every team, and only teams that have had a flag are cached. The number therefore reads low. The arithmetic is right and the panel is easy to misread. Presentation is a separate change.
How did you test this code?
test_refreshes_cacheinproducts/feature_flags/backend/test/test_flag_definitions_cache_tasks.pyto assert the task callsget_cache_statswith the definitions config.flagsand double-counts the flags cache under a name that looks right.posthog_hypercache_coverage_percent{cache_name="flag_definitions"}.Automatic notifications
Docs update
None. No user-facing behavior, API, or config changes.
🤖 Agent context
Autonomy: Human-driven (agent-assisted)
/writing-tests,/writing-code-comments,/writing-pr-descriptions,review-code --fix,simplify.review-code --fixandsimplifyran nine agents and applied no fixes. Two suggestions were declined: a zero-argget_cache_stats()wrapper inlocal_evaluation.py, which the spec ruled out, and an import alias rename, where the current spelling matches three other cache modules.get_cache_statsswallows exceptions and returns an error dict, so all five callers log "Completed" on a failed scan and drop the error string.gh pr list --state open --search "flag definitions cache stats coverage"found nothing covering this.