From 90533c9e2d0b2697e2b8e9801e88c86f16a08bc7 Mon Sep 17 00:00:00 2001 From: Aaron Lindsay Date: Wed, 4 Sep 2013 23:51:28 -0400 Subject: [PATCH] Keep statistics on the number of events being sent to the server --- asink/client.go | 2 ++ asink/status.go | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/asink/client.go b/asink/client.go index 94d6249..9a9b44c 100644 --- a/asink/client.go +++ b/asink/client.go @@ -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 } diff --git a/asink/status.go b/asink/status.go index 7dbb5a4..b20bb67 100644 --- a/asink/status.go +++ b/asink/status.go @@ -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) +}