Keep statistics on the number of events being sent to the server
This commit is contained in:
parent
11b57cda66
commit
90533c9e2d
@ -209,7 +209,9 @@ func ProcessLocalEvent(globals AsinkGlobals, event *asink.Event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//finally, send it off to the server
|
//finally, send it off to the server
|
||||||
|
StatStartSending()
|
||||||
err = SendEvent(globals, event)
|
err = SendEvent(globals, event)
|
||||||
|
StatStopSending()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err) //TODO handle sensibly
|
panic(err) //TODO handle sensibly
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ var localUpdates int32 = 0
|
|||||||
var remoteUpdates int32 = 0
|
var remoteUpdates int32 = 0
|
||||||
var fileUploads int32 = 0
|
var fileUploads int32 = 0
|
||||||
var fileDownloads int32 = 0
|
var fileDownloads int32 = 0
|
||||||
|
var sendingUpdates int32 = 0
|
||||||
|
|
||||||
func GetStats() string {
|
func GetStats() string {
|
||||||
local := atomic.LoadInt32(&localUpdates)
|
local := atomic.LoadInt32(&localUpdates)
|
||||||
@ -23,7 +24,8 @@ func GetStats() string {
|
|||||||
return fmt.Sprintf(`Asink client statistics:
|
return fmt.Sprintf(`Asink client statistics:
|
||||||
Processing %d file updates (%d local, %d remote)
|
Processing %d file updates (%d local, %d remote)
|
||||||
Uploading %d files
|
Uploading %d files
|
||||||
Downloading %d files`, local + remote, local, remote, uploads, downloads)
|
Downloading %d files
|
||||||
|
Sending %d updates`, local+remote, local, remote, uploads, downloads, sendingUpdates)
|
||||||
}
|
}
|
||||||
|
|
||||||
func StatStartLocalUpdate() {
|
func StatStartLocalUpdate() {
|
||||||
@ -50,3 +52,9 @@ func StatStartDownload() {
|
|||||||
func StatStopDownload() {
|
func StatStopDownload() {
|
||||||
atomic.AddInt32(&fileDownloads, -1)
|
atomic.AddInt32(&fileDownloads, -1)
|
||||||
}
|
}
|
||||||
|
func StatStartSending() {
|
||||||
|
atomic.AddInt32(&sendingUpdates, 1)
|
||||||
|
}
|
||||||
|
func StatStopSending() {
|
||||||
|
atomic.AddInt32(&sendingUpdates, -1)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user