| 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 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |