Skip to content

Export Prometheus telemetry in daemon mode #573

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

Merged
merged 39 commits into from
Mar 10, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
ba172c3
Apply cosmetics
Jan 22, 2020
2c6634d
Implement ugly telemetry POC
Jan 23, 2020
11d1bdb
Added prefix and moved Insrumentation inside the command package
Jan 23, 2020
bb6a490
Refactor the telemetry module
Jan 24, 2020
18cdce8
Implement configuration via Viper
Jan 24, 2020
1262ba6
Add stats flush in case of a not daemonized cli daemon proces
Jan 24, 2020
a9d1b31
Add repertory to store installation id and secret
Jan 24, 2020
74fe852
Repertory force write
Jan 30, 2020
ab0a98c
Cosmetics
Jan 30, 2020
315cf00
Use viper config for repertory dir
Jan 30, 2020
b961a48
Add test for repertory file creation
Jan 30, 2020
e1ea063
Add testing for telemetry deaemon and repertory
Jan 30, 2020
30e7a2b
Wait for repertory and kill daemon
Jan 30, 2020
eb33588
Updated pyinvoke to use async feature to test the daemon
Jan 31, 2020
8974523
Updated daemon test timeout
Jan 31, 2020
e98c271
Cosmetics
Jan 31, 2020
ead55a3
Set getDefaultArduinoDataDir as unexported
Jan 31, 2020
216303f
Cosmetics
Jan 31, 2020
18481c0
Cosmetics
Jan 31, 2020
c448704
Cosmetics
Jan 31, 2020
0aea65c
Lint on repertory module
Jan 31, 2020
855b377
Set SIGTERM as kill signal in case of win platform to overcome pyinvo…
Feb 5, 2020
b203b7e
Import platform as a module
Feb 5, 2020
d0f448c
Reverse platform if for signal value
Feb 5, 2020
dc61b78
Extract pid value
Feb 5, 2020
040dc85
Remove print leftover
Mar 3, 2020
2d0808a
Add better error handling in repertory creation
Mar 5, 2020
b3bbdc6
Update docs with old README extract
Mar 5, 2020
90477d5
Remove telemetry.pattern setting from docs
Mar 5, 2020
4d5af7a
Remove serverPattern config option for telemetry
Mar 6, 2020
0fdc125
Upgrade viper to 1.6.2
Mar 6, 2020
965a70f
Defer stats Increment in compile command and explicit set for success…
Mar 6, 2020
e1582e7
Fix board list help message
Mar 6, 2020
ce6f4fa
Implement stats flush anyway to leverage module no-op in case of no h…
Mar 6, 2020
4e7b4cf
Rename "repertory" module in "inventory" and refactor Sanitize function
Mar 9, 2020
aaed29d
Sanitize ExportFile in command/compile
Mar 9, 2020
8b425a7
Refactor daemon start fixture to include daemon process cleanup
Mar 9, 2020
0625b39
Use defer function to push success tag correctly updated
Mar 9, 2020
3300d4d
Use named return parameters to handle success tagging for a command stat
Mar 10, 2020
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
12 changes: 8 additions & 4 deletions commands/board/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,19 @@ func List(instanceID int32) ([]*rpc.DetectedPort, error) {
m.Lock()
defer m.Unlock()

tags := map[string]string{}
// Use defer func() to evaluate tags map when function returns
defer func() { stats.Incr("board.list", stats.M(tags)...) }()

pm := commands.GetPackageManager(instanceID)
if pm == nil {
stats.Incr("board.list", stats.T("success", "false"))
tags["success"] = "false"
return nil, errors.New("invalid instance")
}

ports, err := commands.ListBoards(pm)
if err != nil {
stats.Incr("board.list", stats.T("success", "false"))
tags["success"] = "false"
return nil, errors.Wrap(err, "error getting port list from serial-discovery")
}

Expand All @@ -139,7 +143,7 @@ func List(instanceID int32) ([]*rpc.DetectedPort, error) {
logrus.Debug("Board not recognized")
} else if err != nil {
// this is bad, bail out
stats.Incr("board.list", stats.T("success", "false"))
tags["success"] = "false"
return nil, errors.Wrap(err, "error getting board info from Arduino Cloud")
}

Expand All @@ -160,6 +164,6 @@ func List(instanceID int32) ([]*rpc.DetectedPort, error) {
retVal = append(retVal, p)
}

stats.Incr("board.list", stats.T("success", "true"))
tags["success"] = "true"
return retVal, nil
}
4 changes: 3 additions & 1 deletion commands/compile/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ func Compile(ctx context.Context, req *rpc.CompileReq, outStream, errStream io.W
"libraries": strings.Join(req.Libraries, ","),
}

defer stats.Incr("compile", stats.M(tags)...)
// Use defer func() to evaluate tags map when function returns
defer func() { stats.Incr("compile", stats.M(tags)...) }()

pm := commands.GetPackageManager(req.GetInstance().GetId())
if pm == nil {
tags["success"] = "false"
return nil, errors.New("invalid instance")
}

Expand Down