Fix panic on inconsistent label cardinality and error semantic
Michal Budzyn
7 years ago
15 | 15 |
|
16 | 16 |
func (mw instrumentingMiddleware) Uppercase(s string) (output string, err error) {
|
17 | 17 |
defer func(begin time.Time) {
|
18 | |
lvs := []string{"method", "uppercase", "error", fmt.Sprint(err == nil)}
|
|
18 |
lvs := []string{"method", "uppercase", "error", fmt.Sprint(err != nil)}
|
19 | 19 |
mw.requestCount.With(lvs...).Add(1)
|
20 | 20 |
mw.requestLatency.With(lvs...).Observe(time.Since(begin).Seconds())
|
21 | 21 |
}(time.Now())
|
|
26 | 26 |
|
27 | 27 |
func (mw instrumentingMiddleware) Count(s string) (n int) {
|
28 | 28 |
defer func(begin time.Time) {
|
29 | |
lvs := []string{"method", "count"}
|
|
29 |
lvs := []string{"method", "count", "error", "false"}
|
30 | 30 |
mw.requestCount.With(lvs...).Add(1)
|
31 | 31 |
mw.requestLatency.With(lvs...).Observe(time.Since(begin).Seconds())
|
32 | 32 |
mw.countResult.Observe(float64(n))
|
25 | 25 |
|
26 | 26 |
func (mw instrmw) Uppercase(s string) (output string, err error) {
|
27 | 27 |
defer func(begin time.Time) {
|
28 | |
lvs := []string{"method", "uppercase", "error", fmt.Sprint(err == nil)}
|
|
28 |
lvs := []string{"method", "uppercase", "error", fmt.Sprint(err != nil)}
|
29 | 29 |
mw.requestCount.With(lvs...).Add(1)
|
30 | 30 |
mw.requestLatency.With(lvs...).Observe(time.Since(begin).Seconds())
|
31 | 31 |
}(time.Now())
|
|
36 | 36 |
|
37 | 37 |
func (mw instrmw) Count(s string) (n int) {
|
38 | 38 |
defer func(begin time.Time) {
|
39 | |
lvs := []string{"method", "count"}
|
|
39 |
lvs := []string{"method", "count", "error", "false"}
|
40 | 40 |
mw.requestCount.With(lvs...).Add(1)
|
41 | 41 |
mw.requestLatency.With(lvs...).Observe(time.Since(begin).Seconds())
|
42 | 42 |
mw.countResult.Observe(float64(n))
|