Skip to content

Metrics gc#6562

Draft
pablogrs wants to merge 2 commits into
runatlantis:mainfrom
pablogrs:metrics-gc
Draft

Metrics gc#6562
pablogrs wants to merge 2 commits into
runatlantis:mainfrom
pablogrs:metrics-gc

Conversation

@pablogrs

Copy link
Copy Markdown

what

This pull request introduces a new configurable retention period for metrics related to inactive pull requests (PRs), adds a mechanism to clean up metric scopes for closed PRs, and refactors metric tagging to use a centralized PR scope manager. It also updates documentation and improves the way metrics are tagged for PR-related events and VCS operations.

Metrics retention and cleanup:

  • Adds a new --metrics-inactive-pr-retention server flag (and corresponding environment variable) to control how long metrics for inactive PRs are retained before cleanup, with validation and documentation updates. [1] [2] [3] [4] [5] [6] [7]
  • Introduces the ScopeCleaner interface and integrates it into the PR cleanup flow to mark closed PRs for metric cleanup and periodically remove stale metric scopes. [1] [2] [3]

Metric tagging and scope management:

  • Refactors project and VCS metric tagging to use a centralized PRScopeManager, ensuring consistent and closeable PR-specific metric scopes throughout the codebase. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]

Metrics tagging improvements:

  • Updates GitHub event handling to use direct tag assignment for base_repo and pr_number instead of a helper function, improving clarity and consistency.

Codebase cleanup and test improvements:

  • Removes redundant project scope tagging in the command context builder, as this is now handled by the PR scope manager.
  • Minor test import ordering cleanup.

why

tests

references

nferch and others added 2 commits February 4, 2026 17:53
Ensure Prometheus cleanup removes all per-PR counter metrics emitted by
InstrumentedProjectCommandRunner, not just success and error counters.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants