Skip to content

Commit b1ecd64

Browse files
authored
feat: add metric for ping handler update room failures (#699)
1 parent 1e6ae60 commit b1ecd64

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

internal/adapters/metrics/grpc.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,18 @@ var (
3838
monitoring.LabelCode,
3939
},
4040
})
41+
42+
PingHandlerUpdateRoomFailuresMetric = monitoring.CreateCounterMetric(&monitoring.MetricOpts{
43+
Namespace: monitoring.Namespace,
44+
Subsystem: monitoring.SubsystemApi,
45+
Name: "ping_handler_update_room_failures",
46+
Help: "Number of failures in UpdateRoomWithPing handler when calling UpdateRoom",
47+
Labels: []string{
48+
monitoring.LabelScheduler,
49+
},
50+
})
4151
)
52+
53+
func ReportPingHandlerUpdateRoomFailure(schedulerName string) {
54+
PingHandlerUpdateRoomFailuresMetric.WithLabelValues(schedulerName).Inc()
55+
}

internal/api/handlers/rooms_handler.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ package handlers
2525
import (
2626
"context"
2727

28+
"github.com/topfreegames/maestro/internal/adapters/metrics"
2829
"github.com/topfreegames/maestro/internal/api/handlers/requestadapters"
2930
"github.com/topfreegames/maestro/internal/core/entities/events"
3031
"github.com/topfreegames/maestro/internal/core/logs"
@@ -90,6 +91,7 @@ func (h *RoomsHandler) UpdateRoomWithPing(ctx context.Context, message *api.Upda
9091
err = h.roomManager.UpdateRoom(ctx, gameRoom)
9192
if err != nil {
9293
handlerLogger.Error("error updating room with ping", zap.Any("ping", message), zap.Error(err))
94+
metrics.ReportPingHandlerUpdateRoomFailure(message.SchedulerName)
9395
return &api.UpdateRoomWithPingResponse{Success: false}, nil
9496
}
9597

0 commit comments

Comments
 (0)