mirror of
https://github.com/strukturag/nextcloud-spreed-signaling
synced 2024-05-05 23:33:10 +02:00
Add metrics for GRPC calls.
This commit is contained in:
parent
b315c09a3b
commit
b6e419f18a
|
@ -45,3 +45,6 @@ The following metrics are available:
|
||||||
| `signaling_mcu_no_backend_available_total` | Counter | 0.4.0 | Total number of publishing requests where no backend was available | `type` |
|
| `signaling_mcu_no_backend_available_total` | Counter | 0.4.0 | Total number of publishing requests where no backend was available | `type` |
|
||||||
| `signaling_room_sessions` | Gauge | 0.4.0 | The current number of sessions in a room | `backend`, `room`, `clienttype` |
|
| `signaling_room_sessions` | Gauge | 0.4.0 | The current number of sessions in a room | `backend`, `room`, `clienttype` |
|
||||||
| `signaling_server_messages_total` | Counter | 0.4.0 | The total number of signaling messages | `type` |
|
| `signaling_server_messages_total` | Counter | 0.4.0 | The total number of signaling messages | `type` |
|
||||||
|
| `signaling_grpc_clients` | Gauge | 1.0.0 | The current number of GRPC clients | |
|
||||||
|
| `signaling_grpc_client_calls_total` | Counter | 1.0.0 | The total number of GRPC client calls | `method` |
|
||||||
|
| `signaling_grpc_server_calls_total` | Counter | 1.0.0 | The total number of GRPC server calls | `method` |
|
||||||
|
|
|
@ -37,6 +37,10 @@ import (
|
||||||
status "google.golang.org/grpc/status"
|
status "google.golang.org/grpc/status"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
RegisterGrpcClientStats()
|
||||||
|
}
|
||||||
|
|
||||||
type grpcClientImpl struct {
|
type grpcClientImpl struct {
|
||||||
RpcMcuClient
|
RpcMcuClient
|
||||||
RpcSessionsClient
|
RpcSessionsClient
|
||||||
|
@ -76,6 +80,7 @@ func (c *GrpcClient) Close() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *GrpcClient) LookupSessionId(ctx context.Context, roomSessionId string) (string, error) {
|
func (c *GrpcClient) LookupSessionId(ctx context.Context, roomSessionId string) (string, error) {
|
||||||
|
statsGrpcClientCalls.WithLabelValues("LookupSessionId").Inc()
|
||||||
// TODO: Remove debug logging
|
// TODO: Remove debug logging
|
||||||
log.Printf("Lookup room session %s on %s", roomSessionId, c.Target())
|
log.Printf("Lookup room session %s on %s", roomSessionId, c.Target())
|
||||||
response, err := c.impl.LookupSessionId(ctx, &LookupSessionIdRequest{
|
response, err := c.impl.LookupSessionId(ctx, &LookupSessionIdRequest{
|
||||||
|
@ -96,6 +101,7 @@ func (c *GrpcClient) LookupSessionId(ctx context.Context, roomSessionId string)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *GrpcClient) IsSessionInCall(ctx context.Context, sessionId string, room *Room) (bool, error) {
|
func (c *GrpcClient) IsSessionInCall(ctx context.Context, sessionId string, room *Room) (bool, error) {
|
||||||
|
statsGrpcClientCalls.WithLabelValues("IsSessionInCall").Inc()
|
||||||
// TODO: Remove debug logging
|
// TODO: Remove debug logging
|
||||||
log.Printf("Check if session %s is in call %s on %s", sessionId, room.Id(), c.Target())
|
log.Printf("Check if session %s is in call %s on %s", sessionId, room.Id(), c.Target())
|
||||||
response, err := c.impl.IsSessionInCall(ctx, &IsSessionInCallRequest{
|
response, err := c.impl.IsSessionInCall(ctx, &IsSessionInCallRequest{
|
||||||
|
@ -113,6 +119,7 @@ func (c *GrpcClient) IsSessionInCall(ctx context.Context, sessionId string, room
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *GrpcClient) GetPublisherId(ctx context.Context, sessionId string, streamType string) (string, string, net.IP, error) {
|
func (c *GrpcClient) GetPublisherId(ctx context.Context, sessionId string, streamType string) (string, string, net.IP, error) {
|
||||||
|
statsGrpcClientCalls.WithLabelValues("GetPublisherId").Inc()
|
||||||
// TODO: Remove debug logging
|
// TODO: Remove debug logging
|
||||||
log.Printf("Get %s publisher id %s on %s", streamType, sessionId, c.Target())
|
log.Printf("Get %s publisher id %s on %s", streamType, sessionId, c.Target())
|
||||||
response, err := c.impl.GetPublisherId(ctx, &GetPublisherIdRequest{
|
response, err := c.impl.GetPublisherId(ctx, &GetPublisherIdRequest{
|
||||||
|
@ -209,6 +216,7 @@ func (c *GrpcClients) load(config *goconf.ConfigFile) error {
|
||||||
|
|
||||||
c.clients = clients
|
c.clients = clients
|
||||||
c.clientsMap = clientsMap
|
c.clientsMap = clientsMap
|
||||||
|
statsGrpcClients.Set(float64(len(clients)))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,10 @@ import (
|
||||||
status "google.golang.org/grpc/status"
|
status "google.golang.org/grpc/status"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
RegisterGrpcServerStats()
|
||||||
|
}
|
||||||
|
|
||||||
type GrpcServer struct {
|
type GrpcServer struct {
|
||||||
UnimplementedRpcMcuServer
|
UnimplementedRpcMcuServer
|
||||||
UnimplementedRpcSessionsServer
|
UnimplementedRpcSessionsServer
|
||||||
|
@ -92,6 +96,7 @@ func (s *GrpcServer) Close() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *GrpcServer) LookupSessionId(ctx context.Context, request *LookupSessionIdRequest) (*LookupSessionIdReply, error) {
|
func (s *GrpcServer) LookupSessionId(ctx context.Context, request *LookupSessionIdRequest) (*LookupSessionIdReply, error) {
|
||||||
|
statsGrpcServerCalls.WithLabelValues("LookupSessionId").Inc()
|
||||||
// TODO: Remove debug logging
|
// TODO: Remove debug logging
|
||||||
log.Printf("Lookup session id for room session id %s", request.RoomSessionId)
|
log.Printf("Lookup session id for room session id %s", request.RoomSessionId)
|
||||||
sid, err := s.hub.roomSessions.GetSessionId(request.RoomSessionId)
|
sid, err := s.hub.roomSessions.GetSessionId(request.RoomSessionId)
|
||||||
|
@ -107,6 +112,7 @@ func (s *GrpcServer) LookupSessionId(ctx context.Context, request *LookupSession
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *GrpcServer) IsSessionInCall(ctx context.Context, request *IsSessionInCallRequest) (*IsSessionInCallReply, error) {
|
func (s *GrpcServer) IsSessionInCall(ctx context.Context, request *IsSessionInCallRequest) (*IsSessionInCallReply, error) {
|
||||||
|
statsGrpcServerCalls.WithLabelValues("IsSessionInCall").Inc()
|
||||||
// TODO: Remove debug logging
|
// TODO: Remove debug logging
|
||||||
log.Printf("Check if session %s is in call %s on %s", request.SessionId, request.RoomId, request.BackendUrl)
|
log.Printf("Check if session %s is in call %s on %s", request.SessionId, request.RoomId, request.BackendUrl)
|
||||||
session := s.hub.GetSessionByPublicId(request.SessionId)
|
session := s.hub.GetSessionByPublicId(request.SessionId)
|
||||||
|
@ -127,6 +133,7 @@ func (s *GrpcServer) IsSessionInCall(ctx context.Context, request *IsSessionInCa
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *GrpcServer) GetPublisherId(ctx context.Context, request *GetPublisherIdRequest) (*GetPublisherIdReply, error) {
|
func (s *GrpcServer) GetPublisherId(ctx context.Context, request *GetPublisherIdRequest) (*GetPublisherIdReply, error) {
|
||||||
|
statsGrpcServerCalls.WithLabelValues("GetPublisherId").Inc()
|
||||||
// TODO: Remove debug logging
|
// TODO: Remove debug logging
|
||||||
log.Printf("Get %s publisher id for session %s", request.StreamType, request.SessionId)
|
log.Printf("Get %s publisher id for session %s", request.StreamType, request.SessionId)
|
||||||
session := s.hub.GetSessionByPublicId(request.SessionId)
|
session := s.hub.GetSessionByPublicId(request.SessionId)
|
||||||
|
|
65
grpc_stats_prometheus.go
Normal file
65
grpc_stats_prometheus.go
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
/**
|
||||||
|
* Standalone signaling server for the Nextcloud Spreed app.
|
||||||
|
* Copyright (C) 2022 struktur AG
|
||||||
|
*
|
||||||
|
* @author Joachim Bauch <bauch@struktur.de>
|
||||||
|
*
|
||||||
|
* @license GNU AGPL version 3 or any later version
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package signaling
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
statsGrpcClients = prometheus.NewGauge(prometheus.GaugeOpts{
|
||||||
|
Namespace: "signaling",
|
||||||
|
Subsystem: "grpc",
|
||||||
|
Name: "clients",
|
||||||
|
Help: "The current number of GRPC clients",
|
||||||
|
})
|
||||||
|
statsGrpcClientCalls = prometheus.NewCounterVec(prometheus.CounterOpts{
|
||||||
|
Namespace: "signaling",
|
||||||
|
Subsystem: "grpc",
|
||||||
|
Name: "client_calls_total",
|
||||||
|
Help: "The total number of GRPC client calls",
|
||||||
|
}, []string{"method"})
|
||||||
|
|
||||||
|
grpcClientStats = []prometheus.Collector{
|
||||||
|
statsGrpcClients,
|
||||||
|
statsGrpcClientCalls,
|
||||||
|
}
|
||||||
|
|
||||||
|
statsGrpcServerCalls = prometheus.NewCounterVec(prometheus.CounterOpts{
|
||||||
|
Namespace: "signaling",
|
||||||
|
Subsystem: "grpc",
|
||||||
|
Name: "server_calls_total",
|
||||||
|
Help: "The total number of GRPC server calls",
|
||||||
|
}, []string{"method"})
|
||||||
|
|
||||||
|
grpcServerStats = []prometheus.Collector{
|
||||||
|
statsGrpcServerCalls,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func RegisterGrpcClientStats() {
|
||||||
|
registerAll(grpcClientStats...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func RegisterGrpcServerStats() {
|
||||||
|
registerAll(grpcServerStats...)
|
||||||
|
}
|
Loading…
Reference in a new issue