31 lines
662 B
Go
31 lines
662 B
Go
package metric
|
|
|
|
import (
|
|
"github.com/zeromicro/go-zero/core/metric"
|
|
)
|
|
|
|
var AppErrorMetrics = NewAppErrMetrics()
|
|
|
|
type appErrMetrics struct {
|
|
metric.CounterVec
|
|
}
|
|
|
|
type Metrics interface {
|
|
AddFailure(source, reason string)
|
|
}
|
|
|
|
// NewAppErrMetrics initiate metrics and register to prometheus
|
|
func NewAppErrMetrics() Metrics {
|
|
return &appErrMetrics{metric.NewCounterVec(&metric.CounterVecOpts{
|
|
Namespace: "ark",
|
|
Subsystem: "permission",
|
|
Name: "permission_app_error_total",
|
|
Help: "App defined failure total.",
|
|
Labels: []string{"source", "reason"},
|
|
})}
|
|
}
|
|
|
|
func (m *appErrMetrics) AddFailure(source, reason string) {
|
|
m.Inc(source, reason)
|
|
}
|