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

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

Issue 1857643003: Revert of 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"
10 "golang.org/x/net/context" 11 "golang.org/x/net/context"
11 12
12 "github.com/luci/luci-go/common/tsmon/monitor" 13 "github.com/luci/luci-go/common/tsmon/monitor"
13 "github.com/luci/luci-go/common/tsmon/store" 14 "github.com/luci/luci-go/common/tsmon/store"
14 "github.com/luci/luci-go/common/tsmon/target" 15 "github.com/luci/luci-go/common/tsmon/target"
15 "github.com/luci/luci-go/common/tsmon/types" 16 "github.com/luci/luci-go/common/tsmon/types"
16 ) 17 )
17 18
18 // State holds the configuration of the tsmon library. There is one global 19 // State holds the configuration of the tsmon library. There is one global
19 // instance of State, but it can be overridden in a Context by tests. 20 // 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
59 return WithState(c, &State{ 60 return WithState(c, &State{
60 S: s, 61 S: s,
61 M: m, 62 M: m,
62 RegisteredMetrics: map[string]types.Metric{}, 63 RegisteredMetrics: map[string]types.Metric{},
63 }), s, m 64 }), s, m
64 } 65 }
65 66
66 // WithDummyInMemory returns a new context holding a new State with a new in- 67 // WithDummyInMemory returns a new context holding a new State with a new in-
67 // memory store and a fake monitor. 68 // memory store and a fake monitor.
68 func WithDummyInMemory(c context.Context) (context.Context, *monitor.Fake) { 69 func WithDummyInMemory(c context.Context) (context.Context, *monitor.Fake) {
69 » s := store.NewInMemory(&target.Task{}) 70 » s := store.NewInMemory(&target.Task{ServiceName: proto.String("")})
70 m := &monitor.Fake{} 71 m := &monitor.Fake{}
71 return WithState(c, &State{ 72 return WithState(c, &State{
72 S: s, 73 S: s,
73 M: m, 74 M: m,
74 RegisteredMetrics: map[string]types.Metric{}, 75 RegisteredMetrics: map[string]types.Metric{},
75 }), m 76 }), m
76 } 77 }
77 78
78 type key int 79 type key int
79 80
80 var ( 81 var (
81 globalState = &State{ 82 globalState = &State{
82 S: store.NewNilStore(), 83 S: store.NewNilStore(),
83 M: monitor.NewNilMonitor(), 84 M: monitor.NewNilMonitor(),
84 RegisteredMetrics: map[string]types.Metric{}, 85 RegisteredMetrics: map[string]types.Metric{},
85 } 86 }
86 stateKey key = 1 87 stateKey key = 1
87 ) 88 )
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