Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1056)

Side by Side Diff: monitoring/go/prober/main.go

Issue 659943006: Do not forget to call `defer glog.Flush()` in our applications (Closed) Base URL: https://skia.googlesource.com/buildbot@master
Patch Set: revert titletool changes Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « monitoring/go/grains/grains.go ('k') | perf/go/ingest/main.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Prober is an HTTP prober that periodically sends out HTTP requests to specifi ed 1 // Prober is an HTTP prober that periodically sends out HTTP requests to specifi ed
2 // endpoints and reports if the returned results match the expectations. The res ults 2 // endpoints and reports if the returned results match the expectations. The res ults
3 // of the probe, including latency, are recored in InfluxDB using the Carbon pro tocol. 3 // of the probe, including latency, are recored in InfluxDB using the Carbon pro tocol.
4 // See probers.json as an example of the config file format. 4 // See probers.json as an example of the config file format.
5 package main 5 package main
6 6
7 import ( 7 import (
8 "encoding/json" 8 "encoding/json"
9 "flag" 9 "flag"
10 "fmt" 10 "fmt"
11 "io" 11 "io"
12 "io/ioutil" 12 "io/ioutil"
13 "net" 13 "net"
14 "net/http" 14 "net/http"
15 "os" 15 "os"
16 "strings" 16 "strings"
17 "time" 17 "time"
18 18
19 "github.com/golang/glog"
19 "github.com/rcrowley/go-metrics" 20 "github.com/rcrowley/go-metrics"
20 ) 21 )
21 22
22 import (
23 "github.com/golang/glog"
24 )
25
26 var ( 23 var (
27 config = flag.String("config", "probers.json,buildbots.json", "Comma separated names of prober config files.") 24 config = flag.String("config", "probers.json,buildbots.json", "Comma separated names of prober config files.")
28 prefix = flag.String("prefix", "prober", "Prefix to add to all probe r values sent to Carbon.") 25 prefix = flag.String("prefix", "prober", "Prefix to add to all probe r values sent to Carbon.")
29 carbon = flag.String("carbon", "localhost:2003", "Address of Carbon server and port.") 26 carbon = flag.String("carbon", "localhost:2003", "Address of Carbon server and port.")
30 apikeyFlag = flag.String("apikey", "", "The API Key used to make issue t racker requests. Only for local testing.") 27 apikeyFlag = flag.String("apikey", "", "The API Key used to make issue t racker requests. Only for local testing.")
31 runEvery = flag.Duration("run_every", 1*time.Minute, "How often to run the probes.") 28 runEvery = flag.Duration("run_every", 1*time.Minute, "How often to run the probes.")
32 29
33 // bodyTesters is a mapping of names to functions that test response bod ies. 30 // bodyTesters is a mapping of names to functions that test response bod ies.
34 bodyTesters = map[string]BodyTester{ 31 bodyTesters = map[string]BodyTester{
35 "buildbotJSON": testBuildbotJSON, 32 "buildbotJSON": testBuildbotJSON,
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 glog.Infof("Num Issues: %s - %d", issue.Name, jsonResp[" totalResults"]) 203 glog.Infof("Num Issues: %s - %d", issue.Name, jsonResp[" totalResults"])
207 if err == nil && resp.Body != nil { 204 if err == nil && resp.Body != nil {
208 resp.Body.Close() 205 resp.Body.Close()
209 } 206 }
210 } 207 }
211 } 208 }
212 } 209 }
213 210
214 func main() { 211 func main() {
215 flag.Parse() 212 flag.Parse()
213 defer glog.Flush()
216 go monitorIssueTracker() 214 go monitorIssueTracker()
217 glog.Infoln("Looking for Carbon server.") 215 glog.Infoln("Looking for Carbon server.")
218 addr, err := net.ResolveTCPAddr("tcp", *carbon) 216 addr, err := net.ResolveTCPAddr("tcp", *carbon)
219 if err != nil { 217 if err != nil {
220 glog.Fatalln("Failed to resolve the Carbon server: ", err) 218 glog.Fatalln("Failed to resolve the Carbon server: ", err)
221 } 219 }
222 glog.Infoln("Found Carbon server.") 220 glog.Infoln("Found Carbon server.")
223 221
224 // We have two sets of metrics, one for the probes and one for the probe 222 // We have two sets of metrics, one for the probes and one for the probe
225 // server itself. 223 // server itself.
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 glog.Errorf("Body test failed. %#v", probe) 285 glog.Errorf("Body test failed. %#v", probe)
288 probe.failure.Update(1) 286 probe.failure.Update(1)
289 continue 287 continue
290 } 288 }
291 289
292 probe.failure.Update(0) 290 probe.failure.Update(0)
293 probe.latency.Update(d) 291 probe.latency.Update(d)
294 } 292 }
295 } 293 }
296 } 294 }
OLDNEW
« no previous file with comments | « monitoring/go/grains/grains.go ('k') | perf/go/ingest/main.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698