parent
6ee88fea7e
commit
279238e1bd
@ -1,45 +0,0 @@
|
|||||||
package prommetrics
|
|
||||||
|
|
||||||
import (
|
|
||||||
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
|
|
||||||
config2 "github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/ginprometheus"
|
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
|
||||||
"github.com/prometheus/client_golang/prometheus/collectors"
|
|
||||||
)
|
|
||||||
|
|
||||||
func NewGrpcPromObj(cusMetrics []prometheus.Collector) (*prometheus.Registry, *grpc_prometheus.ServerMetrics, error) {
|
|
||||||
////////////////////////////////////////////////////////
|
|
||||||
reg := prometheus.NewRegistry()
|
|
||||||
grpcMetrics := grpc_prometheus.NewServerMetrics()
|
|
||||||
grpcMetrics.EnableHandlingTimeHistogram()
|
|
||||||
cusMetrics = append(cusMetrics, grpcMetrics, collectors.NewGoCollector())
|
|
||||||
reg.MustRegister(cusMetrics...)
|
|
||||||
return reg, grpcMetrics, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetGrpcCusMetrics(registerName string) []prometheus.Collector {
|
|
||||||
switch registerName {
|
|
||||||
case config2.Config.RpcRegisterName.OpenImMessageGatewayName:
|
|
||||||
return []prometheus.Collector{OnlineUserGauge}
|
|
||||||
case config2.Config.RpcRegisterName.OpenImMsgName:
|
|
||||||
return []prometheus.Collector{SingleChatMsgProcessSuccessCounter, SingleChatMsgProcessFailedCounter, GroupChatMsgProcessSuccessCounter, GroupChatMsgProcessFailedCounter}
|
|
||||||
case "Transfer":
|
|
||||||
return []prometheus.Collector{MsgInsertRedisSuccessCounter, MsgInsertRedisFailedCounter, MsgInsertMongoSuccessCounter, MsgInsertMongoFailedCounter, SeqSetFailedCounter}
|
|
||||||
case config2.Config.RpcRegisterName.OpenImPushName:
|
|
||||||
return []prometheus.Collector{MsgOfflinePushFailedCounter}
|
|
||||||
case config2.Config.RpcRegisterName.OpenImAuthName:
|
|
||||||
return []prometheus.Collector{UserLoginCounter}
|
|
||||||
default:
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetGinCusMetrics(name string) []*ginprometheus.Metric {
|
|
||||||
switch name {
|
|
||||||
case "Api":
|
|
||||||
return []*ginprometheus.Metric{ApiCustomCnt}
|
|
||||||
default:
|
|
||||||
return []*ginprometheus.Metric{ApiCustomCnt}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
package prommetrics
|
|
||||||
|
|
||||||
import ginProm "github.com/openimsdk/open-im-server/v3/pkg/common/ginprometheus"
|
|
||||||
|
|
||||||
/*
|
|
||||||
labels := prometheus.Labels{"label_one": "any", "label_two": "value"}
|
|
||||||
ApiCustomCnt.MetricCollector.(*prometheus.CounterVec).With(labels).Inc()
|
|
||||||
*/
|
|
||||||
var (
|
|
||||||
ApiCustomCnt = &ginProm.Metric{
|
|
||||||
Name: "custom_total",
|
|
||||||
Description: "Custom counter events.",
|
|
||||||
Type: "counter_vec",
|
|
||||||
Args: []string{"label_one", "label_two"},
|
|
||||||
}
|
|
||||||
)
|
|
@ -1,12 +0,0 @@
|
|||||||
package prommetrics
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
UserLoginCounter = prometheus.NewCounter(prometheus.CounterOpts{
|
|
||||||
Name: "user_login_total",
|
|
||||||
Help: "The number of user login",
|
|
||||||
})
|
|
||||||
)
|
|
@ -1,24 +0,0 @@
|
|||||||
package prommetrics
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
SingleChatMsgProcessSuccessCounter = prometheus.NewCounter(prometheus.CounterOpts{
|
|
||||||
Name: "single_chat_msg_process_success_total",
|
|
||||||
Help: "The number of single chat msg successful processed",
|
|
||||||
})
|
|
||||||
SingleChatMsgProcessFailedCounter = prometheus.NewCounter(prometheus.CounterOpts{
|
|
||||||
Name: "single_chat_msg_process_failed_total",
|
|
||||||
Help: "The number of single chat msg failed processed",
|
|
||||||
})
|
|
||||||
GroupChatMsgProcessSuccessCounter = prometheus.NewCounter(prometheus.CounterOpts{
|
|
||||||
Name: "group_chat_msg_process_success_total",
|
|
||||||
Help: "The number of group chat msg successful processed",
|
|
||||||
})
|
|
||||||
GroupChatMsgProcessFailedCounter = prometheus.NewCounter(prometheus.CounterOpts{
|
|
||||||
Name: "group_chat_msg_process_failed_total",
|
|
||||||
Help: "The number of group chat msg failed processed",
|
|
||||||
})
|
|
||||||
)
|
|
@ -1,12 +0,0 @@
|
|||||||
package prommetrics
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
OnlineUserGauge = prometheus.NewGauge(prometheus.GaugeOpts{
|
|
||||||
Name: "online_user_num",
|
|
||||||
Help: "The number of online user num",
|
|
||||||
})
|
|
||||||
)
|
|
Loading…
Reference in new issue