OLD | NEW |
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" |
11 "encoding/base64" | 11 "encoding/base64" |
12 "encoding/json" | 12 "encoding/json" |
13 "time" | 13 "time" |
14 | 14 |
15 "github.com/luci/gae/service/datastore" | 15 "github.com/luci/gae/service/datastore" |
16 "github.com/luci/luci-go/common/clock" | 16 "github.com/luci/luci-go/common/clock" |
17 "github.com/luci/luci-go/common/iotools" | 17 "github.com/luci/luci-go/common/iotools" |
18 log "github.com/luci/luci-go/common/logging" | 18 log "github.com/luci/luci-go/common/logging" |
19 "github.com/luci/luci-go/server/router" | 19 "github.com/luci/luci-go/server/router" |
20 | 20 |
21 "golang.org/x/net/context" | 21 "golang.org/x/net/context" |
22 | 22 |
23 "github.com/luci/luci-go/common/tsmon/field" | 23 "github.com/luci/luci-go/common/tsmon/field" |
24 "github.com/luci/luci-go/common/tsmon/metric" | 24 "github.com/luci/luci-go/common/tsmon/metric" |
| 25 "github.com/luci/luci-go/common/tsmon/types" |
25 ) | 26 ) |
26 | 27 |
27 var ( | 28 var ( |
28 // subName is the name of the pubsub subscription that milo is expecting
. | 29 // subName is the name of the pubsub subscription that milo is expecting
. |
29 // TODO(hinoka): This should be read from luci-config. | 30 // TODO(hinoka): This should be read from luci-config. |
30 subName = "projects/luci-milo/subscriptions/buildbot-public" | 31 subName = "projects/luci-milo/subscriptions/buildbot-public" |
31 | 32 |
32 // Metrics | 33 // Metrics |
33 buildCounter = metric.NewCounter( | 34 buildCounter = metric.NewCounter( |
34 "luci/milo/buildbot_pubsub/builds", | 35 "luci/milo/buildbot_pubsub/builds", |
35 "The number of buildbot builds received by Milo from PubSub", | 36 "The number of buildbot builds received by Milo from PubSub", |
| 37 types.MetricMetadata{}, |
36 field.Bool("internal"), | 38 field.Bool("internal"), |
37 field.String("master"), | 39 field.String("master"), |
38 field.String("builder"), | 40 field.String("builder"), |
39 field.Bool("finished"), | 41 field.Bool("finished"), |
40 // Status can be one of 3 options. "New", "Replaced", "Rejected
". | 42 // Status can be one of 3 options. "New", "Replaced", "Rejected
". |
41 field.String("status")) | 43 field.String("status")) |
42 ) | 44 ) |
43 | 45 |
44 type pubSubMessage struct { | 46 type pubSubMessage struct { |
45 Attributes map[string]string `json:"attributes"` | 47 Attributes map[string]string `json:"attributes"` |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 if err != nil { | 221 if err != nil { |
220 log.WithError(err).Errorf( | 222 log.WithError(err).Errorf( |
221 c, "Could not save master in datastore %s", err) | 223 c, "Could not save master in datastore %s", err) |
222 // This is transient, we do want PubSub to retry. | 224 // This is transient, we do want PubSub to retry. |
223 h.WriteHeader(500) | 225 h.WriteHeader(500) |
224 return | 226 return |
225 } | 227 } |
226 } | 228 } |
227 h.WriteHeader(200) | 229 h.WriteHeader(200) |
228 } | 230 } |
OLD | NEW |