From 24f3e6b80b9e927736fb23912fb43d5a10214479 Mon Sep 17 00:00:00 2001 From: Jimmy Zelinskie Date: Mon, 21 Jul 2014 19:32:36 -0400 Subject: [PATCH] announce & scrape stats --- tracker/announce.go | 3 +++ tracker/scrape.go | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/tracker/announce.go b/tracker/announce.go index 1ee0578..205dec4 100644 --- a/tracker/announce.go +++ b/tracker/announce.go @@ -7,6 +7,7 @@ package tracker import ( "net" + "github.com/chihaya/chihaya/stats" "github.com/chihaya/chihaya/tracker/models" ) @@ -88,6 +89,8 @@ func (tkr *Tracker) HandleAnnounce(ann *models.Announce, w Writer) error { conn.PurgeInactiveTorrent(torrent.Infohash) } + stats.RecordEvent(stats.Announce) + return w.WriteAnnounce(newAnnounceResponse(ann, peer, torrent)) } diff --git a/tracker/scrape.go b/tracker/scrape.go index 02f3f1a..e33ec3a 100644 --- a/tracker/scrape.go +++ b/tracker/scrape.go @@ -4,7 +4,10 @@ package tracker -import "github.com/chihaya/chihaya/tracker/models" +import ( + "github.com/chihaya/chihaya/stats" + "github.com/chihaya/chihaya/tracker/models" +) // HandleScrape encapsulates all the logic of handling a BitTorrent client's // scrape without being coupled to any transport protocol. @@ -38,5 +41,7 @@ func (tkr *Tracker) HandleScrape(scrape *models.Scrape, w Writer) (err error) { torrents = append(torrents, torrent) } + stats.RecordEvent(stats.Scrape) + return w.WriteScrape(&models.ScrapeResponse{torrents}) }