forked from zalando/skipper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathall_kind.go
110 lines (103 loc) · 3.47 KB
/
all_kind.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
package metrics
import (
"net/http"
"time"
)
type All struct {
prometheus *Prometheus
codaHale *CodaHale
prometheusHandler http.Handler
codaHaleHandler http.Handler
}
func NewAll(o Options) *All {
return &All{
prometheus: NewPrometheus(o),
codaHale: NewCodaHale(o),
}
}
func (a *All) MeasureSince(key string, start time.Time) {
a.prometheus.MeasureSince(key, start)
a.codaHale.MeasureSince(key, start)
}
func (a *All) IncCounter(key string) {
a.prometheus.IncCounter(key)
a.codaHale.IncCounter(key)
}
func (a *All) IncCounterBy(key string, value int64) {
a.prometheus.IncCounterBy(key, value)
a.codaHale.IncCounterBy(key, value)
}
func (a *All) IncFloatCounterBy(key string, value float64) {
a.prometheus.IncFloatCounterBy(key, value)
a.codaHale.IncFloatCounterBy(key, value)
}
func (a *All) UpdateGauge(key string, v float64) {
a.prometheus.UpdateGauge(key, v)
a.codaHale.UpdateGauge(key, v)
}
func (a *All) MeasureRouteLookup(start time.Time) {
a.prometheus.MeasureRouteLookup(start)
a.codaHale.MeasureRouteLookup(start)
}
func (a *All) MeasureFilterRequest(filterName string, start time.Time) {
a.prometheus.MeasureFilterRequest(filterName, start)
a.codaHale.MeasureFilterRequest(filterName, start)
}
func (a *All) MeasureAllFiltersRequest(routeId string, start time.Time) {
a.prometheus.MeasureAllFiltersRequest(routeId, start)
a.codaHale.MeasureAllFiltersRequest(routeId, start)
}
func (a *All) MeasureBackend(routeId string, start time.Time) {
a.prometheus.MeasureBackend(routeId, start)
a.codaHale.MeasureBackend(routeId, start)
}
func (a *All) MeasureBackendHost(routeBackendHost string, start time.Time) {
a.prometheus.MeasureBackendHost(routeBackendHost, start)
a.codaHale.MeasureBackendHost(routeBackendHost, start)
}
func (a *All) MeasureFilterResponse(filterName string, start time.Time) {
a.prometheus.MeasureFilterResponse(filterName, start)
a.codaHale.MeasureFilterResponse(filterName, start)
}
func (a *All) MeasureAllFiltersResponse(routeId string, start time.Time) {
a.prometheus.MeasureAllFiltersResponse(routeId, start)
a.codaHale.MeasureAllFiltersResponse(routeId, start)
}
func (a *All) MeasureResponse(code int, method string, routeId string, start time.Time) {
a.prometheus.MeasureResponse(code, method, routeId, start)
a.codaHale.MeasureResponse(code, method, routeId, start)
}
func (a *All) MeasureServe(routeId, host, method string, code int, start time.Time) {
a.prometheus.MeasureServe(routeId, host, method, code, start)
a.codaHale.MeasureServe(routeId, host, method, code, start)
}
func (a *All) IncRoutingFailures() {
a.prometheus.IncRoutingFailures()
a.codaHale.IncRoutingFailures()
}
func (a *All) IncErrorsBackend(routeId string) {
a.prometheus.IncErrorsBackend(routeId)
a.codaHale.IncErrorsBackend(routeId)
}
func (a *All) MeasureBackend5xx(t time.Time) {
a.prometheus.MeasureBackend5xx(t)
a.codaHale.MeasureBackend5xx(t)
}
func (a *All) IncErrorsStreaming(routeId string) {
a.prometheus.IncErrorsStreaming(routeId)
a.codaHale.IncErrorsStreaming(routeId)
}
func (a *All) RegisterHandler(path string, handler *http.ServeMux) {
a.prometheusHandler = a.prometheus.getHandler()
a.codaHaleHandler = a.codaHale.getHandler(path)
handler.Handle(path, a.newHandler())
}
func (a *All) newHandler() http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
if req.Header.Get("Accept") == "application/codahale+json" {
a.codaHaleHandler.ServeHTTP(w, req)
} else {
a.prometheusHandler.ServeHTTP(w, req)
}
})
}