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 metrics for command invocation #3185

Merged
merged 1 commit into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,8 @@ func main() {
}

if !*noUpdate {
updateCfg.Fetcher = updater.Fetcher(usingTUI)
topLevelCmd, _, _ := strings.Cut(cmd, " ")
updateCfg.Fetcher = updater.Fetcher(topLevelCmd, usingTUI)
}
if version.BuildVersion == "dev" {
updateCfg.Fetcher = nil
Expand Down
7 changes: 5 additions & 2 deletions pkg/updater/updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ import (
"github.com/trufflesecurity/trufflehog/v3/pkg/version"
)

func Fetcher(tui bool) fetcher.Interface {
return &OSS{TUI: tui}
func Fetcher(cmd string, tui bool) fetcher.Interface {
return &OSS{Cmd: cmd, TUI: tui}
}

type OSS struct {
Interval time.Duration
Cmd string
TUI bool
Updated bool
}
Expand All @@ -41,6 +42,7 @@ type FormData struct {
OS string
Arch string
CurrentVersion string
Cmd string
TUI bool
Timezone string
Binary string
Expand All @@ -58,6 +60,7 @@ func (g *OSS) Fetch() (io.Reader, error) {
OS: runtime.GOOS,
Arch: runtime.GOARCH,
CurrentVersion: version.BuildVersion,
Cmd: g.Cmd,
TUI: g.TUI,
Timezone: zone,
Binary: "trufflehog",
Expand Down
Loading