Skip to content

Commit

Permalink
internal/scan: increase telemetry counter for show flag
Browse files Browse the repository at this point in the history
Change-Id: I9bb24cb7943f8a6abd8a4c7128bfc1560b97f466
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/589415
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Maceo Thompson <[email protected]>
Run-TryBot: Zvonimir Pavlinovic <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
  • Loading branch information
zpavlinovic committed Jun 4, 2024
1 parent fb2a687 commit 84735a3
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions internal/scan/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ func RunGovulncheck(ctx context.Context, env []string, r io.Reader, stdout io.Wr
return err
}

counter.Inc(fmt.Sprintf("govulncheck/mode:%s", cfg.ScanMode))
counter.Inc(fmt.Sprintf("govulncheck/scan:%s", cfg.ScanLevel))
counter.Inc(fmt.Sprintf("govulncheck/format:%s", cfg.format))
incTelemetryFlagCounters(cfg)

switch cfg.ScanMode {
case govulncheck.ScanModeSource:
Expand Down Expand Up @@ -141,6 +139,19 @@ func scannerVersion(cfg *config, bi *debug.BuildInfo) {
cfg.ScannerVersion = buf.String()
}

func incTelemetryFlagCounters(cfg *config) {
counter.Inc(fmt.Sprintf("govulncheck/mode:%s", cfg.ScanMode))
counter.Inc(fmt.Sprintf("govulncheck/scan:%s", cfg.ScanLevel))
counter.Inc(fmt.Sprintf("govulncheck/format:%s", cfg.format))

if len(cfg.show) == 0 {
counter.Inc("govulncheck/show:none")
}
for _, s := range cfg.show {
counter.Inc(fmt.Sprintf("govulncheck/show:%s", s))
}
}

func Flush(h govulncheck.Handler) error {
if th, ok := h.(interface{ Flush() error }); ok {
return th.Flush()
Expand Down

0 comments on commit 84735a3

Please sign in to comment.