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

Side by Side Diff: appengine/tsmon/middleware.go

Issue 2795613002: Make global callbacks usable outside appengine. (Closed)
Patch Set: Created 3 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 | « no previous file | common/tsmon/context.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 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 tsmon 5 package tsmon
6 6
7 import ( 7 import (
8 "fmt" 8 "fmt"
9 "net/http" 9 "net/http"
10 "net/url" 10 "net/url"
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 137
138 // 'settings' or 'state' has changed. Reinitialize tsmon as needed under 138 // 'settings' or 'state' has changed. Reinitialize tsmon as needed under
139 // the write lock. 139 // the write lock.
140 s.lock.Lock() 140 s.lock.Lock()
141 defer s.lock.Unlock() 141 defer s.lock.Unlock()
142 142
143 // First call to 'checkSettings' ever? 143 // First call to 'checkSettings' ever?
144 if s.state == nil { 144 if s.state == nil {
145 s.state = state 145 s.state = state
146 s.state.M = monitor.NewNilMonitor() // doFlush uses its own moni tor 146 s.state.M = monitor.NewNilMonitor() // doFlush uses its own moni tor
147 s.state.InvokeGlobalCallbacksOnFlush = false
147 } else if state != s.state { 148 } else if state != s.state {
148 panic("tsmon state in the context was unexpectedly changed betwe en requests") 149 panic("tsmon state in the context was unexpectedly changed betwe en requests")
149 } 150 }
150 151
151 switch { 152 switch {
152 case !bool(s.lastSettings.Enabled) && bool(settings.Enabled): 153 case !bool(s.lastSettings.Enabled) && bool(settings.Enabled):
153 s.enableTsMon(c) 154 s.enableTsMon(c)
154 case bool(s.lastSettings.Enabled) && !bool(settings.Enabled): 155 case bool(s.lastSettings.Enabled) && !bool(settings.Enabled):
155 s.disableTsMon(c) 156 s.disableTsMon(c)
156 } 157 }
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 if err != nil { 335 if err != nil {
335 return err 336 return err
336 } 337 }
337 } 338 }
338 339
339 defer mon.Close() 340 defer mon.Close()
340 if err = state.Flush(c, mon); err != nil { 341 if err = state.Flush(c, mon); err != nil {
341 return err 342 return err
342 } 343 }
343 344
344 state.ResetGlobalCallbackMetrics(c)
345 return nil 345 return nil
346 } 346 }
OLDNEW
« no previous file with comments | « no previous file | common/tsmon/context.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698