Skip to content

Commit 3b5c837

Browse files
committed
fix: metrics package
1 parent 0a63bed commit 3b5c837

File tree

3 files changed

+16
-48
lines changed

3 files changed

+16
-48
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/metrics.go

Lines changed: 0 additions & 46 deletions
This file was deleted.

internal/api/handlers/rooms_handler.go

Lines changed: 2 additions & 2 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,12 +91,11 @@ 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))
93-
reportPingHandlerUpdateRoomFailure(message.SchedulerName)
94+
metrics.ReportPingHandlerUpdateRoomFailure(message.SchedulerName)
9495
return &api.UpdateRoomWithPingResponse{Success: false}, nil
9596
}
9697

9798
handlerLogger.Debug("Room updated with ping successfully")
98-
reportPingHandlerUpdateRoomSuccess(message.SchedulerName)
9999
return &api.UpdateRoomWithPingResponse{Success: true}, nil
100100
}
101101

0 commit comments

Comments
 (0)