Skip to content

Commit 17f9b1f

Browse files
authored
fix(usage/ping): avoid stale data when pinging (#9)
Signed-off-by: Niladri Halder <[email protected]>
1 parent cf0a565 commit 17f9b1f

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

usage/ping.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,23 @@ const (
3939
func PingCheck(engineName, category string, pingImmediately bool) {
4040
// Create a new usage field
4141
u := New()
42-
pingSender := u.CommonBuild(engineName).
43-
InstallBuilder(true).
44-
SetCategory(category)
4542

4643
if pingImmediately {
4744
// Ping immediately.
48-
pingSender.Send()
45+
u.CommonBuild(engineName).
46+
InstallBuilder(true).
47+
SetCategory(category).
48+
Send()
4949
}
5050

5151
duration := getPingPeriod()
5252
ticker := time.NewTicker(duration)
5353
for range ticker.C {
5454
// Ping periodically, starting at 'duration'.
55-
pingSender.Send()
55+
u.CommonBuild(engineName).
56+
InstallBuilder(true).
57+
SetCategory(category).
58+
Send()
5659
}
5760
}
5861

0 commit comments

Comments
 (0)