announce & scrape stats

This commit is contained in:
Jimmy Zelinskie 2014-07-21 19:32:36 -04:00
parent 477f292371
commit 24f3e6b80b
2 changed files with 9 additions and 1 deletions

View file

@ -7,6 +7,7 @@ package tracker
import ( import (
"net" "net"
"github.com/chihaya/chihaya/stats"
"github.com/chihaya/chihaya/tracker/models" "github.com/chihaya/chihaya/tracker/models"
) )
@ -88,6 +89,8 @@ func (tkr *Tracker) HandleAnnounce(ann *models.Announce, w Writer) error {
conn.PurgeInactiveTorrent(torrent.Infohash) conn.PurgeInactiveTorrent(torrent.Infohash)
} }
stats.RecordEvent(stats.Announce)
return w.WriteAnnounce(newAnnounceResponse(ann, peer, torrent)) return w.WriteAnnounce(newAnnounceResponse(ann, peer, torrent))
} }

View file

@ -4,7 +4,10 @@
package tracker 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 // HandleScrape encapsulates all the logic of handling a BitTorrent client's
// scrape without being coupled to any transport protocol. // 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) torrents = append(torrents, torrent)
} }
stats.RecordEvent(stats.Scrape)
return w.WriteScrape(&models.ScrapeResponse{torrents}) return w.WriteScrape(&models.ScrapeResponse{torrents})
} }