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

Side by Side Diff: common/tsmon/context.go

Issue 1854583002: Migrate tsmon protos to proto3 (Closed) Base URL: git@github.com:luci/luci-go.git@master
Patch Set: Created 4 years, 8 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 | « appengine/tsmon/standardmetrics_test.go ('k') | common/tsmon/field/field.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 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package tsmon 5 package tsmon
6 6
7 import ( 7 import (
8 "sync" 8 "sync"
9 9
10 "github.com/golang/protobuf/proto"
11 "golang.org/x/net/context" 10 "golang.org/x/net/context"
12 11
13 "github.com/luci/luci-go/common/tsmon/monitor" 12 "github.com/luci/luci-go/common/tsmon/monitor"
14 "github.com/luci/luci-go/common/tsmon/store" 13 "github.com/luci/luci-go/common/tsmon/store"
15 "github.com/luci/luci-go/common/tsmon/target" 14 "github.com/luci/luci-go/common/tsmon/target"
16 "github.com/luci/luci-go/common/tsmon/types" 15 "github.com/luci/luci-go/common/tsmon/types"
17 ) 16 )
18 17
19 // State holds the configuration of the tsmon library. There is one global 18 // State holds the configuration of the tsmon library. There is one global
20 // instance of State, but it can be overridden in a Context by tests. 19 // instance of State, but it can be overridden in a Context by tests.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 return WithState(c, &State{ 59 return WithState(c, &State{
61 S: s, 60 S: s,
62 M: m, 61 M: m,
63 RegisteredMetrics: map[string]types.Metric{}, 62 RegisteredMetrics: map[string]types.Metric{},
64 }), s, m 63 }), s, m
65 } 64 }
66 65
67 // WithDummyInMemory returns a new context holding a new State with a new in- 66 // WithDummyInMemory returns a new context holding a new State with a new in-
68 // memory store and a fake monitor. 67 // memory store and a fake monitor.
69 func WithDummyInMemory(c context.Context) (context.Context, *monitor.Fake) { 68 func WithDummyInMemory(c context.Context) (context.Context, *monitor.Fake) {
70 » s := store.NewInMemory(&target.Task{ServiceName: proto.String("")}) 69 » s := store.NewInMemory(&target.Task{})
71 m := &monitor.Fake{} 70 m := &monitor.Fake{}
72 return WithState(c, &State{ 71 return WithState(c, &State{
73 S: s, 72 S: s,
74 M: m, 73 M: m,
75 RegisteredMetrics: map[string]types.Metric{}, 74 RegisteredMetrics: map[string]types.Metric{},
76 }), m 75 }), m
77 } 76 }
78 77
79 type key int 78 type key int
80 79
81 var ( 80 var (
82 globalState = &State{ 81 globalState = &State{
83 S: store.NewNilStore(), 82 S: store.NewNilStore(),
84 M: monitor.NewNilMonitor(), 83 M: monitor.NewNilMonitor(),
85 RegisteredMetrics: map[string]types.Metric{}, 84 RegisteredMetrics: map[string]types.Metric{},
86 } 85 }
87 stateKey key = 1 86 stateKey key = 1
88 ) 87 )
OLDNEW
« no previous file with comments | « appengine/tsmon/standardmetrics_test.go ('k') | common/tsmon/field/field.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698