[MM-57010] Include client type in websocket connections metric (#26763)
* Include client type in websocket connections metric * Unexport field
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
effb99301e
Коммит
4b508eed46
@@ -66,7 +66,7 @@ type MetricsInterfaceImpl struct {
|
||||
|
||||
HTTPRequestsCounter prometheus.Counter
|
||||
HTTPErrorsCounter prometheus.Counter
|
||||
HTTPWebsocketsGauge prometheus.GaugeFunc
|
||||
HTTPWebsocketsGauge *prometheus.GaugeVec
|
||||
|
||||
ClusterRequestsDuration prometheus.Histogram
|
||||
ClusterRequestsCounter prometheus.Counter
|
||||
@@ -368,13 +368,13 @@ func New(ps *platform.PlatformService, driver, dataSource string) *MetricsInterf
|
||||
|
||||
// HTTP Subsystem
|
||||
|
||||
m.HTTPWebsocketsGauge = prometheus.NewGaugeFunc(prometheus.GaugeOpts{
|
||||
m.HTTPWebsocketsGauge = prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
||||
Namespace: MetricsNamespace,
|
||||
Subsystem: MetricsSubsystemHTTP,
|
||||
Name: "websockets_total",
|
||||
Help: "The total number of websocket connections to this server.",
|
||||
ConstLabels: additionalLabels,
|
||||
}, func() float64 { return float64(m.Platform.TotalWebsocketConnections()) })
|
||||
}, []string{"origin_client"})
|
||||
m.Registry.MustRegister(m.HTTPWebsocketsGauge)
|
||||
|
||||
m.HTTPRequestsCounter = prometheus.NewCounter(prometheus.CounterOpts{
|
||||
@@ -1467,6 +1467,14 @@ func (mi *MetricsInterfaceImpl) SetReplicaLagTime(node string, value float64) {
|
||||
mi.DbReplicaLagGaugeTime.With(prometheus.Labels{"node": node}).Set(value)
|
||||
}
|
||||
|
||||
func (mi *MetricsInterfaceImpl) IncrementHTTPWebSockets(originClient string) {
|
||||
mi.HTTPWebsocketsGauge.With(prometheus.Labels{"origin_client": originClient}).Inc()
|
||||
}
|
||||
|
||||
func (mi *MetricsInterfaceImpl) DecrementHTTPWebSockets(originClient string) {
|
||||
mi.HTTPWebsocketsGauge.With(prometheus.Labels{"origin_client": originClient}).Dec()
|
||||
}
|
||||
|
||||
func extractDBCluster(driver, connectionString string) (string, error) {
|
||||
host, err := extractHost(driver, connectionString)
|
||||
if err != nil {
|
||||
|
||||
Ссылка в новой задаче
Block a user