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 printouts for network calls #746
Draft
kemzeb
wants to merge
4
commits into
google:main
Choose a base branch
from
kemzeb:print-networking-calls-verbosely
base: main
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains 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
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #746 +/- ##
==========================================
- Coverage 79.08% 78.54% -0.55%
==========================================
Files 86 86
Lines 6121 6181 +60
==========================================
+ Hits 4841 4855 +14
- Misses 1075 1119 +44
- Partials 205 207 +2 ☔ View full report in Codecov by Sentry. |
Here's a truncated example of how it currently prints out:
|
kemzeb
changed the title
Implement printouts for network calls
Add printouts for network calls
Jan 18, 2024
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.
Since in #698 it was deemed that a dry run mode may not be feasible, it was determined that printing these network calls during runtime maybe a good alternative.
I'm not quite sure if this is still desired, but I believe this would add more transparency as to what the runtime of OSV-Scanner is doing without the need to look at the code or docs. While implementing this, the following guided my thought process:
VerboseLevel
?For point 3, I wasn't too sure how to display the data, so I decided to marshall it into JSON and took a page out of
curl
's book and prefixed these messages with>
and<
to represent an HTTP request and response respectfully. I also prefixed the JSON result for better readability. As a side note I have been using the osv.dev API docs as a reference.For point 4, I went with doing lazy evaluation. I implemented a
CanPrintLevel()
method in theReporter
interface and used it to determine if I should create these expensive messages. I also used this method across the Warnf, Errorf, and other methods to try and keep things DRY. Another approach I thought of was to have aPrintFunc(lvl VerbosityLevel, func() string)
where callers would need to build these expensive messages in the callback (and we check lvl to see if we even should build it), but theCanPrintLevel()
approach seems simpler.If there is interest, I'll go ahead and try to tackle the following endpoints as well: