-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: surface the duration and error metrics for each source when enu…
…merating domains (#727) * feat: Surface the time taken in the scrape result - Add a duration field to the `subscraping.Result` struct - Populate the `TimeTaken` field before passing to the result channel Resolves #726 * fix: move the timing into the sources - sources responsible for their own time keeping - step over commoncrawl in the no auth test, it is consistently failing as a timeout * feat: Add statistics - add stats flag to the debug group - print the time taken, number of results and errors for sources that run - print stats for each run of the agent * chore: fix linter error and use gologger rather than fmt print
- Loading branch information
1 parent
27d4087
commit 8f499e9
Showing
44 changed files
with
1,091 additions
and
118 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package runner | ||
|
||
import ( | ||
"fmt" | ||
"sort" | ||
"strings" | ||
"time" | ||
|
||
"github.com/projectdiscovery/gologger" | ||
"github.com/projectdiscovery/subfinder/v2/pkg/subscraping" | ||
"golang.org/x/exp/maps" | ||
) | ||
|
||
func printStatistics(stats map[string]subscraping.Statistics) { | ||
|
||
sources := maps.Keys(stats) | ||
sort.Strings(sources) | ||
|
||
var lines []string | ||
var skipped []string | ||
|
||
for _, source := range sources { | ||
sourceStats := stats[source] | ||
if sourceStats.Skipped { | ||
skipped = append(skipped, fmt.Sprintf(" %s", source)) | ||
} else { | ||
lines = append(lines, fmt.Sprintf(" %-20s %-10s %10d %10d", source, sourceStats.TimeTaken.Round(time.Millisecond).String(), sourceStats.Results, sourceStats.Errors)) | ||
} | ||
} | ||
|
||
if len(lines) > 0 { | ||
gologger.Print().Msgf("\n Source Duration Results Errors\n%s\n", strings.Repeat("─", 56)) | ||
gologger.Print().Msgf(strings.Join(lines, "\n")) | ||
gologger.Print().Msgf("\n") | ||
} | ||
|
||
if len(skipped) > 0 { | ||
gologger.Print().Msgf("\n The following sources were included but skipped...\n\n") | ||
gologger.Print().Msgf(strings.Join(skipped, "\n")) | ||
gologger.Print().Msgf("\n\n") | ||
} | ||
} |
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
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
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
Oops, something went wrong.