forked from go-kratos/kratos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
metrics.go
37 lines (34 loc) · 1.14 KB
/
metrics.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
package sql
import "github.com/go-kratos/kratos/pkg/stat/metric"
const namespace = "mysql_client"
var (
_metricReqDur = metric.NewHistogramVec(&metric.HistogramVecOpts{
Namespace: namespace,
Subsystem: "requests",
Name: "duration_ms",
Help: "mysql client requests duration(ms).",
Labels: []string{"name", "addr", "command"},
Buckets: []float64{5, 10, 25, 50, 100, 250, 500, 1000, 2500},
})
_metricReqErr = metric.NewCounterVec(&metric.CounterVecOpts{
Namespace: namespace,
Subsystem: "requests",
Name: "error_total",
Help: "mysql client requests error count.",
Labels: []string{"name", "addr", "command", "error"},
})
_metricConnTotal = metric.NewCounterVec(&metric.CounterVecOpts{
Namespace: namespace,
Subsystem: "connections",
Name: "total",
Help: "mysql client connections total count.",
Labels: []string{"name", "addr", "state"},
})
_metricConnCurrent = metric.NewGaugeVec(&metric.GaugeVecOpts{
Namespace: namespace,
Subsystem: "connections",
Name: "current",
Help: "mysql client connections current.",
Labels: []string{"name", "addr", "state"},
})
)