Skip to content

Commit 0a63bed

Browse files
committed
feat: add label result
1 parent 62cc353 commit 0a63bed

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

internal/api/handlers/metrics.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,21 @@ import (
2626
"github.com/topfreegames/maestro/internal/core/monitoring"
2727
)
2828

29-
var pingHandlerUpdateRoomFailuresMetric = monitoring.CreateCounterMetric(&monitoring.MetricOpts{
29+
var pingHandlerUpdateRoomTotalMetric = monitoring.CreateCounterMetric(&monitoring.MetricOpts{
3030
Namespace: monitoring.Namespace,
3131
Subsystem: monitoring.SubsystemApi,
32-
Name: "ping_handler_update_room_failures",
33-
Help: "Number of failures in UpdateRoomWithPing handler when calling UpdateRoom",
32+
Name: "ping_handler_update_room",
33+
Help: "Total number of UpdateRoomWithPing handler calls",
3434
Labels: []string{
3535
monitoring.LabelScheduler,
36+
"result",
3637
},
3738
})
3839

3940
func reportPingHandlerUpdateRoomFailure(schedulerName string) {
40-
pingHandlerUpdateRoomFailuresMetric.WithLabelValues(schedulerName).Inc()
41+
pingHandlerUpdateRoomTotalMetric.WithLabelValues(schedulerName, "failure").Inc()
42+
}
43+
44+
func reportPingHandlerUpdateRoomSuccess(schedulerName string) {
45+
pingHandlerUpdateRoomTotalMetric.WithLabelValues(schedulerName, "success").Inc()
4146
}

internal/api/handlers/rooms_handler.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ func (h *RoomsHandler) UpdateRoomWithPing(ctx context.Context, message *api.Upda
9595
}
9696

9797
handlerLogger.Debug("Room updated with ping successfully")
98+
reportPingHandlerUpdateRoomSuccess(message.SchedulerName)
9899
return &api.UpdateRoomWithPingResponse{Success: true}, nil
99100
}
100101

0 commit comments

Comments
 (0)