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

Side by Side Diff: milo/appengine/buildbot/pubsub.go

Issue 2418063002: Milo: Add ts_mon metrics for master json datastore success (Closed)
Patch Set: Created 4 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The LUCI Authors. All rights reserved. 1 // Copyright 2016 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package buildbot 5 package buildbot
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "compress/gzip" 9 "compress/gzip"
10 "compress/zlib" 10 "compress/zlib"
(...skipping 24 matching lines...) Expand all
35 buildCounter = metric.NewCounter( 35 buildCounter = metric.NewCounter(
36 "luci/milo/buildbot_pubsub/builds", 36 "luci/milo/buildbot_pubsub/builds",
37 "The number of buildbot builds received by Milo from PubSub", 37 "The number of buildbot builds received by Milo from PubSub",
38 nil, 38 nil,
39 field.Bool("internal"), 39 field.Bool("internal"),
40 field.String("master"), 40 field.String("master"),
41 field.String("builder"), 41 field.String("builder"),
42 field.Bool("finished"), 42 field.Bool("finished"),
43 // Status can be one of 3 options. "New", "Replaced", "Rejected ". 43 // Status can be one of 3 options. "New", "Replaced", "Rejected ".
44 field.String("status")) 44 field.String("status"))
45
46 masterCounter = metric.NewCounter(
47 "luci/milo/buildbot_pubsub/masters",
48 "The number of buildbot master jsons received by Milo from PubSu b",
49 nil,
50 field.Bool("internal"),
51 field.String("master"),
52 // Status can be one of 2 options. "Success", "Failure".
dsansome 2016/10/16 23:45:36 Convention is for these field values to be lower-c
hinoka 2016/10/17 21:35:13 Done.
53 field.String("status"))
45 ) 54 )
46 55
47 type pubSubMessage struct { 56 type pubSubMessage struct {
48 Attributes map[string]string `json:"attributes"` 57 Attributes map[string]string `json:"attributes"`
49 Data string `json:"data"` 58 Data string `json:"data"`
50 MessageID string `json:"message_id"` 59 MessageID string `json:"message_id"`
51 } 60 }
52 61
53 type pubSubSubscription struct { 62 type pubSubSubscription struct {
54 Message pubSubMessage `json:"message"` 63 Message pubSubMessage `json:"message"`
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 bm.Builds = append(bm.Builds, build) 137 bm.Builds = append(bm.Builds, build)
129 slave.RunningbuildsMap[build.Buildername] = appe nd( 138 slave.RunningbuildsMap[build.Buildername] = appe nd(
130 slave.RunningbuildsMap[build.Buildername ], build.Number) 139 slave.RunningbuildsMap[build.Buildername ], build.Number)
131 } 140 }
132 slave.Runningbuilds = nil 141 slave.Runningbuilds = nil
133 } 142 }
134 } 143 }
135 return bm.Builds, bm.Master, nil 144 return bm.Builds, bm.Master, nil
136 } 145 }
137 146
138 // getOSInfo fetches the os family and version of hte build from the 147 // getOSInfo fetches the os family and version of hte build from the
dsansome 2016/10/16 23:45:36 And should it be "of the slave" rather than "of th
dsansome 2016/10/16 23:45:36 While I'm here, s/hte/the/
hinoka 2016/10/17 21:35:13 Done.
139 // master json on a best-effort basis. 148 // master json on a best-effort basis.
140 func getOSInfo(c context.Context, b *buildbotBuild, m *buildbotMaster) ( 149 func getOSInfo(c context.Context, b *buildbotBuild, m *buildbotMaster) (
141 family, version string) { 150 family, version string) {
142 // Fetch the master info from datastore if not provided. 151 // Fetch the master info from datastore if not provided.
143 if m.Name == "" { 152 if m.Name == "" {
144 logging.Infof(c, "Fetching info for master %s", b.Master) 153 logging.Infof(c, "Fetching info for master %s", b.Master)
145 entry := buildbotMasterEntry{Name: b.Master} 154 entry := buildbotMasterEntry{Name: b.Master}
146 err := ds.Get(c, &entry) 155 err := ds.Get(c, &entry)
147 if err != nil { 156 if err != nil {
148 logging.WithError(err).Errorf( 157 logging.WithError(err).Errorf(
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 buildCounter.Add( 296 buildCounter.Add(
288 c, 1, false, build.Master, build.Buildername, bu ild.Finished, "New") 297 c, 1, false, build.Master, build.Buildername, bu ild.Finished, "New")
289 } 298 }
290 299
291 } 300 }
292 if master != nil { 301 if master != nil {
293 err = putDSMasterJSON(c, master, internal) 302 err = putDSMasterJSON(c, master, internal)
294 if err != nil { 303 if err != nil {
295 logging.WithError(err).Errorf( 304 logging.WithError(err).Errorf(
296 c, "Could not save master in datastore %s", err) 305 c, "Could not save master in datastore %s", err)
306 masterCounter.Add(c, 1, internal, master.Name, "Failure" )
dsansome 2016/10/16 23:45:36 Does master.Name have a "master." prefix? If not
hinoka 2016/10/17 21:35:13 It does not, I assume it'd be better to normalize
297 // This is transient, we do want PubSub to retry. 307 // This is transient, we do want PubSub to retry.
298 h.WriteHeader(500) 308 h.WriteHeader(500)
299 return 309 return
300 } 310 }
311 masterCounter.Add(c, 1, internal, master.Name, "Success")
301 } 312 }
302 h.WriteHeader(200) 313 h.WriteHeader(200)
303 } 314 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698