-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add commitsScanned metrics #1533
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What makes this a "metric"/how is it going to be used? I initially assumed that as a "metric" it would be a counter or something, not a set.
pkg/sources/git/git.go
Outdated
@@ -371,6 +383,7 @@ func (s *Git) ScanCommits(ctx context.Context, repo *git.Repository, path string | |||
break | |||
} | |||
depth++ | |||
s.metrics.commitsScanned[commit.Hash] = struct{}{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like it would use a lot of memory for large repos. Just trufflehog
would be 88KB (barring the overhead of maps).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I used the method from thog without really considering if it was the best. Switched to just counting since thats all that is used.
Its used in some places to count the number of commits scanned. I think this method of using a map is left over from when the git log was handled differently. Switched it over to an int since thats all we really use. |
I know you already merged, but to follow up on my question: What's going to consume it? |
Track which commits have been scanned. Adding to source so that this doesn't need to be implemented in other places.