-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmetric.go
192 lines (177 loc) · 6.31 KB
/
metric.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
package main
import (
"fmt"
"time"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
)
var (
metricPanics = promauto.NewCounter(
prometheus.CounterOpts{
Name: "gobuild_panics_total",
Help: "Number of unhandled panics.",
},
)
metricGoproxyResolveVersionDuration = promauto.NewHistogram(
prometheus.HistogramOpts{
Name: "gobuild_goproxy_resolve_version_duration_seconds",
Help: "Duration of request to goproxy to resolve module version in seconds.",
Buckets: []float64{0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2, 4, 8, 16, 32, 64, 128},
},
)
metricGoproxyListDuration = promauto.NewHistogram(
prometheus.HistogramOpts{
Name: "gobuild_goproxy_list_duration_seconds",
Help: "Duration of request to goproxy to list module versions in seconds.",
Buckets: []float64{0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2, 4, 8, 16, 32, 64, 128},
},
)
metricGoproxyListErrors = promauto.NewCounterVec(
prometheus.CounterOpts{
Name: "gobuild_goproxy_list_errors_total",
Help: "Number of error reponses from goproxy for listing module versions, per http response code.",
},
[]string{"code"},
)
metricPageDuration = promauto.NewHistogramVec(
prometheus.HistogramOpts{
Name: "gobuild_page_duration_seconds",
Help: "Duration of request for page in seconds, per http response code.",
Buckets: []float64{0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2, 4, 8, 16, 32, 64, 128},
},
[]string{"page"},
)
metricGogetDuration = promauto.NewHistogram(
prometheus.HistogramOpts{
Name: "gobuild_goget_duration_seconds",
Help: "Duration of go get to fetch module source in seconds.",
Buckets: []float64{0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2, 4, 8, 16, 32, 64, 128},
},
)
metricGogetErrors = promauto.NewCounter(
prometheus.CounterOpts{
Name: "gobuild_goget_errors_total",
Help: "Number of error reponses during go get.",
},
)
metricListPackageErrors = promauto.NewCounter(
prometheus.CounterOpts{
Name: "gobuild_list_package_errors_total",
Help: "Number of errors listing packages.",
},
)
metricNotMainErrors = promauto.NewCounter(
prometheus.CounterOpts{
Name: "gobuild_not_main_errors_total",
Help: "Number of errors due to requested package not being main.",
},
)
metricCheckCgoErrors = promauto.NewCounter(
prometheus.CounterOpts{
Name: "gobuild_check_cgo_errors_total",
Help: "Number of errors while checking if module needs cgo.",
},
)
metricNeedsCgoErrors = promauto.NewCounter(
prometheus.CounterOpts{
Name: "gobuild_needs_cgo_errors_total",
Help: "Number of errors due to package needing cgo.",
},
)
metricResolveVersionErrors = promauto.NewCounter(
prometheus.CounterOpts{
Name: "gobuild_resolve_version_errors_total",
Help: "Number of errors while resolving version for module.",
},
)
metricCompileDuration = promauto.NewHistogramVec(
prometheus.HistogramOpts{
Name: "gobuild_compile_duration_seconds",
Help: "Duration of go build to compile program in seconds.",
Buckets: []float64{0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2, 4, 8, 16, 32, 64, 128, 256},
},
[]string{"goos", "goarch", "goversion"},
)
metricCompileErrors = promauto.NewCounterVec(
prometheus.CounterOpts{
Name: "gobuild_compile_errors_total",
Help: "Number of error reponses during go build.",
},
[]string{"goos", "goarch", "goversion"},
)
metricRecompileMismatch = promauto.NewCounterVec(
prometheus.CounterOpts{
Name: "gobuild_recompile_mismatch_total",
Help: "Number of sum mismatches when recompiling cleaned up binaries.",
},
[]string{"goos", "goarch", "goversion"},
)
metricVerifyDuration = promauto.NewHistogramVec(
prometheus.HistogramOpts{
Name: "gobuild_verify_duration_seconds",
Help: "Duration of verifying build with other backend, in seconds.",
Buckets: []float64{0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2, 4, 8, 16, 32, 64, 128, 256},
},
[]string{"baseurl", "goos", "goarch", "goversion"},
)
metricVerifyErrors = promauto.NewCounterVec(
prometheus.CounterOpts{
Name: "gobuild_verify_errors_total",
Help: "Number of error reponses verifying with other backends.",
},
[]string{"baseurl", "goos", "goarch", "goversion"},
)
metricVerifyMismatch = promauto.NewCounterVec(
prometheus.CounterOpts{
Name: "gobuild_verify_mismatch_total",
Help: "Number of sum mismatches with other backends.",
},
[]string{"baseurl", "goos", "goarch", "goversion"},
)
metricTlogAddErrors = promauto.NewCounter(
prometheus.CounterOpts{
Name: "gobuild_tlog_add_errors_total",
Help: "Number of errors (of any kind, including consistency) while adding a sum to the transparency log.",
},
)
metricTlogConsistencyErrors = promauto.NewCounter(
prometheus.CounterOpts{
Name: "gobuild_tlog_consistency_errors_total",
Help: "Number of consistency errors encountered while adding a sum to the transparency log.",
},
)
metricTlogRecords = promauto.NewGauge(
prometheus.GaugeOpts{
Name: "gobuild_tlog_record_total",
Help: "Number of records in the transparency log.",
},
)
metricTlogOpsSignedErrors = newOpsErrorCounter("signed")
metricTlogOpsReadrecordsErrors = newOpsErrorCounter("readrecords")
metricTlogOpsLookupErrors = newOpsErrorCounter("lookup")
metricTlogOpsReadtiledataErrors = newOpsErrorCounter("readtiledata")
metricTlogOpsSignedDuration = newOpsHistogram("signed")
metricTlogOpsReadrecordsDuration = newOpsHistogram("readrecords")
metricTlogOpsLookupDuration = newOpsHistogram("lookup")
metricTlogOpsReadtiledataDuration = newOpsHistogram("readtiledata")
)
func newOpsErrorCounter(op string) prometheus.Counter {
return promauto.NewCounter(
prometheus.CounterOpts{
Name: fmt.Sprintf("gobuild_tlog_ops_%s_errors_total", op),
Help: fmt.Sprintf("Number of transparency log errors for server op %s on the transparency log.", op),
},
)
}
func newOpsHistogram(op string) prometheus.Histogram {
return promauto.NewHistogram(
prometheus.HistogramOpts{
Name: fmt.Sprintf("gobuild_tlog_ops_%s_duration_seconds", op),
Help: fmt.Sprintf("Duration of transparency log server op %s in seconds.", op),
Buckets: []float64{0.001, 0.005, 0.01, 0.05, 0.1, 0.25, 0.5, 1},
},
)
}
func observePage(page string, t0 time.Time) {
metricPageDuration.WithLabelValues(page).Observe(time.Since(t0).Seconds())
}