From 329d4db397bbc51f9639d65caa1d7ee5d162633f Mon Sep 17 00:00:00 2001 From: "insanity@loafle.com" Date: Thu, 18 May 2017 19:48:33 +0900 Subject: [PATCH] added elapsed time to collect --- collector.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/collector.go b/collector.go index 0f0e105..36cc4ff 100644 --- a/collector.go +++ b/collector.go @@ -9,6 +9,7 @@ import ( "log" "strconv" "sync" + "time" ) var ( @@ -76,11 +77,15 @@ func (c *Collector) collect(id string) { in.Id = id in.Name = grpc.Crawlers(grpc.Crawlers_value[conf.Crawler.Name]) + startAt := time.Now().Unix() out, err := dc.Get(context.Background(), in) + finishedAt := time.Now().Unix() if err != nil { log.Printf("Cannot collect [ID: %s] [Crawler : %s] - [Err : %s]\n", conf.Id, conf.Crawler.Name, err.Error()) return } + out.StartDate = startAt + out.EndDate = finishedAt log.Printf("COLLECTED. [ID: %s] [Crawler : %s] [Result : %s]\n", conf.Id, conf.Crawler.Name, out.GetData()) c.dataCh <- out }()