Conversation
- Rename CountRecovered to CountRescued to match naming convention - Rename starter_recovered_runs metric to starter_rescued_runs - Add logic to increment counter when rescue jobs are enqueued - Fix issue where metric was always zero
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a bug where the starter_rescued_runs metric was always reporting zero values and addresses naming inconsistencies in the codebase.
- Renamed
starter_recovered_runsmetric tostarter_rescued_runsfor consistent naming convention - Added missing increment logic in
enqueueRescueJobto properly track rescued jobs - Updated internal variable names from
CountRecoveredtoCountRescuedfor consistency
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pkg/starter/starter.go | Renamed variable and added missing counter increment logic in rescue job handler |
| pkg/metric/scrape_memory.go | Updated metric name and references to use consistent "rescued" terminology |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
pkg/starter/starter.go
Outdated
Comment on lines
+574
to
+578
| if count, ok := CountRescued.Load(target.Scope); ok { | ||
| CountRescued.Store(target.Scope, count.(int)+1) | ||
| } else { | ||
| CountRescued.Store(target.Scope, 1) | ||
| } |
There was a problem hiding this comment.
This increment operation is not thread-safe. Multiple goroutines could read the same value and increment it simultaneously, leading to lost increments. Consider using atomic operations or a mutex to ensure thread safety.
Changed from non-thread-safe Load+Store pattern to atomic operations using LoadOrStore with atomic.Int64 to prevent race conditions when multiple goroutines increment the counter simultaneously.
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.
fixes: #242
Summary
starter_recovered_runsmetric tostarter_rescued_runsto match naming conventionCountRecoveredtoCountRescuedfor consistencyTest plan
enqueueRescueJobstarter_rescued_runs