Skip to content
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

Merged
merged 2 commits into from
Jul 25, 2023
Merged

Add commitsScanned metrics #1533

merged 2 commits into from
Jul 25, 2023

Conversation

bill-rich
Copy link
Collaborator

@bill-rich bill-rich commented Jul 24, 2023

Track which commits have been scanned. Adding to source so that this doesn't need to be implemented in other places.

Copy link
Collaborator

@rosecodym rosecodym left a 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.

@@ -371,6 +383,7 @@ func (s *Git) ScanCommits(ctx context.Context, repo *git.Repository, path string
break
}
depth++
s.metrics.commitsScanned[commit.Hash] = struct{}{}
Copy link
Collaborator

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).

Copy link
Collaborator Author

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.

@bill-rich
Copy link
Collaborator Author

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.

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.

@bill-rich bill-rich merged commit f393034 into main Jul 25, 2023
9 checks passed
@bill-rich bill-rich deleted the git_metrics branch July 25, 2023 18:31
@rosecodym
Copy link
Collaborator

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.

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants