Keep statistics on the number of events being sent to the server

This commit is contained in:
Aaron Lindsay 2013-09-04 23:51:28 -04:00
parent 11b57cda66
commit 90533c9e2d
2 changed files with 11 additions and 1 deletions

View File

@ -209,7 +209,9 @@ func ProcessLocalEvent(globals AsinkGlobals, event *asink.Event) {
}
//finally, send it off to the server
StatStartSending()
err = SendEvent(globals, event)
StatStopSending()
if err != nil {
panic(err) //TODO handle sensibly
}

View File

@ -13,6 +13,7 @@ var localUpdates int32 = 0
var remoteUpdates int32 = 0
var fileUploads int32 = 0
var fileDownloads int32 = 0
var sendingUpdates int32 = 0
func GetStats() string {
local := atomic.LoadInt32(&localUpdates)
@ -23,7 +24,8 @@ func GetStats() string {
return fmt.Sprintf(`Asink client statistics:
Processing %d file updates (%d local, %d remote)
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() {
@ -50,3 +52,9 @@ func StatStartDownload() {
func StatStopDownload() {
atomic.AddInt32(&fileDownloads, -1)
}
func StatStartSending() {
atomic.AddInt32(&sendingUpdates, 1)
}
func StatStopSending() {
atomic.AddInt32(&sendingUpdates, -1)
}