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

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

Issue 2290993002: Always set presence/up from go tsmon apps. (Closed)
Patch Set: Created 4 years, 3 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/metric/metric_test.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 "strings" 10 "strings"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 userAgent, ok := c.Request.Header["User-Agent"] 92 userAgent, ok := c.Request.Header["User-Agent"]
93 if !ok || len(userAgent) == 0 { 93 if !ok || len(userAgent) == 0 {
94 userAgent = []string{"Unknown"} 94 userAgent = []string{"Unknown"}
95 } 95 }
96 ctx := c.Context 96 ctx := c.Context
97 contentLength := c.Request.ContentLength 97 contentLength := c.Request.ContentLength
98 nrw := newResponseWriter(c.Writer) 98 nrw := newResponseWriter(c.Writer)
99 c.Writer = nrw 99 c.Writer = nrw
100 defer func() { 100 defer func() {
101 dur := clock.Now(ctx).Sub(started) 101 dur := clock.Now(ctx).Sub(started)
102 metric.UpdatePresenceMetrics(ctx)
103 metric.UpdateServerMetrics(ctx, "/", nrw.Status(), dur, 102 metric.UpdateServerMetrics(ctx, "/", nrw.Status(), dur,
104 contentLength, nrw.Size(), userAgent[0]) 103 contentLength, nrw.Size(), userAgent[0])
105 }() 104 }()
106 next(c) 105 next(c)
107 s.flushIfNeeded(ctx, state, settings) 106 s.flushIfNeeded(ctx, state, settings)
108 } else { 107 } else {
109 next(c) 108 next(c)
110 } 109 }
111 } 110 }
112 111
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 } 320 }
322 } 321 }
323 322
324 if err := state.Flush(c, mon); err != nil { 323 if err := state.Flush(c, mon); err != nil {
325 return err 324 return err
326 } 325 }
327 326
328 state.ResetGlobalCallbackMetrics(c) 327 state.ResetGlobalCallbackMetrics(c)
329 return nil 328 return nil
330 } 329 }
OLDNEW
« no previous file with comments | « no previous file | common/tsmon/metric/metric_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698