forked from cloudfoundry/gorouter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
compositereporter.go
74 lines (63 loc) · 2.22 KB
/
compositereporter.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package metrics
import (
"net/http"
"time"
"code.cloudfoundry.org/gorouter/route"
)
// Deprecated: this interface is marked for removal. It should be removed upon
// removal of Varz
//go:generate counterfeiter -o fakes/fake_varzreporter.go . VarzReporter
type VarzReporter interface {
CaptureBadRequest()
CaptureBadGateway()
CaptureRoutingRequest(b *route.Endpoint)
CaptureRoutingResponseLatency(b *route.Endpoint, statusCode int, t time.Time, d time.Duration)
}
//go:generate counterfeiter -o fakes/fake_proxyreporter.go . ProxyReporter
type ProxyReporter interface {
CaptureBackendExhaustedConns()
CaptureBackendInvalidID()
CaptureBackendInvalidTLSCert()
CaptureBackendTLSHandshakeFailed()
CaptureBadRequest()
CaptureBadGateway()
CaptureRoutingRequest(b *route.Endpoint)
CaptureRoutingResponse(statusCode int)
CaptureRoutingResponseLatency(b *route.Endpoint, statusCode int, t time.Time, d time.Duration)
CaptureRouteServiceResponse(res *http.Response)
CaptureWebSocketUpdate()
CaptureWebSocketFailure()
}
type ComponentTagged interface {
Component() string
}
//go:generate counterfeiter -o fakes/fake_registry_reporter.go . RouteRegistryReporter
type RouteRegistryReporter interface {
CaptureRouteStats(totalRoutes int, msSinceLastUpdate uint64)
CaptureRoutesPruned(prunedRoutes uint64)
CaptureLookupTime(t time.Duration)
CaptureRegistryMessage(msg ComponentTagged)
CaptureRouteRegistrationLatency(t time.Duration)
UnmuzzleRouteRegistrationLatency()
CaptureUnregistryMessage(msg ComponentTagged)
}
type CompositeReporter struct {
VarzReporter
ProxyReporter
}
func (c *CompositeReporter) CaptureBadRequest() {
c.VarzReporter.CaptureBadRequest()
c.ProxyReporter.CaptureBadRequest()
}
func (c *CompositeReporter) CaptureBadGateway() {
c.VarzReporter.CaptureBadGateway()
c.ProxyReporter.CaptureBadGateway()
}
func (c *CompositeReporter) CaptureRoutingRequest(b *route.Endpoint) {
c.VarzReporter.CaptureRoutingRequest(b)
c.ProxyReporter.CaptureRoutingRequest(b)
}
func (c *CompositeReporter) CaptureRoutingResponseLatency(b *route.Endpoint, statusCode int, t time.Time, d time.Duration) {
c.VarzReporter.CaptureRoutingResponseLatency(b, statusCode, t, d)
c.ProxyReporter.CaptureRoutingResponseLatency(b, 0, time.Time{}, d)
}