45 lines
1.1 KiB
Go
45 lines
1.1 KiB
Go
package metrics
|
|
|
|
import (
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
"github.com/prometheus/client_golang/prometheus/promauto"
|
|
)
|
|
|
|
var (
|
|
// RequestCounter 请求计数器
|
|
RequestCounter = promauto.NewCounterVec(
|
|
prometheus.CounterOpts{
|
|
Name: "hospital_pay_requests_total",
|
|
Help: "请求总数,按功能码分类",
|
|
},
|
|
[]string{"function_code"},
|
|
)
|
|
|
|
// RequestDuration 请求处理时间
|
|
RequestDuration = promauto.NewHistogramVec(
|
|
prometheus.HistogramOpts{
|
|
Name: "hospital_pay_request_duration_seconds",
|
|
Help: "请求处理时间(秒)",
|
|
Buckets: prometheus.DefBuckets,
|
|
},
|
|
[]string{"function_code"},
|
|
)
|
|
|
|
// ErrorCounter 错误计数器
|
|
ErrorCounter = promauto.NewCounterVec(
|
|
prometheus.CounterOpts{
|
|
Name: "hospital_pay_errors_total",
|
|
Help: "错误总数,按功能码和错误码分类",
|
|
},
|
|
[]string{"function_code", "error_code"},
|
|
)
|
|
|
|
// ActiveConnections 活跃连接数
|
|
ActiveConnections = promauto.NewGauge(
|
|
prometheus.GaugeOpts{
|
|
Name: "hospital_pay_active_connections",
|
|
Help: "当前活跃连接数",
|
|
},
|
|
)
|
|
)
|