feat: add comprehensive git sync metrics for v2 #4587
Draft
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.
Summary
Implements comprehensive git synchronization metrics for Flipt v2, providing visibility into git-based flag synchronization operations.
Addresses: https://github.com/orgs/flipt-io/discussions/4556
New Metrics
This PR adds the following Prometheus metrics to track git sync operations:
flipt_git_sync_total
remote
,branch
,status
flipt_git_sync_duration
remote
,branch
flipt_git_sync_errors_total
remote
,branch
,error_type
flipt_git_files_changed_total
remote
,branch
,operation
Error Types
auth
- Authentication/authorization failuresnetwork
- Network/repository access issuesconflict
- Merge conflicts or repository state issuesrepository
- Repository structure problemsunknown
- Unrecognized errorsFile Operations
added
- New files created during syncmodified
- Existing files changed during syncdeleted
- Files removed during syncImplementation Details
Core Changes
repoMetrics
struct with new sync-specific counters and histogramsFetch()
method to track sync operations and detect file changescategorizeError()
function using go-git v6 error types witherrors.Is()
trackSyncChanges()
to analyze commit diffs and count file modificationsKey Features
Bonus Fix
Also fixes the mage formatting task to exclude all hidden directories (starting with
.
) instead of hardcoding specific ones like.git
and.devenv
. This prevents formatting issues with various hidden directories.Example Usage
Users can now create Prometheus alerts and dashboards:
Test Plan
Breaking Changes
None - this is an additive feature that extends the existing metrics system.
Documentation
The new metrics will be documented in the monitoring/observability documentation as part of the existing git storage metrics section.