Added metrics for ticket behavior (#1491) (#1494)

* Added metrics for total number of tickets and total number of backfills (#1, #4 of proposed metrics)

* Fixed totalBackfillTicketsView Name

* Added metric for keeping track of tickets in pending state

* altered name of total tickets to total 'active' tickets to remove confusion

* updated pending tickets metric name

* Register totalActiveTicketsView and pendingTotalTicketsView
This commit is contained in:
Jon Foust
2022-09-21 12:38:47 -04:00
committed by GitHub
parent 5d5f4de7a7
commit 036be6455d
2 changed files with 33 additions and 6 deletions

View File

@ -177,8 +177,10 @@ func updateTicketCache(store statestore.Service, value interface{}) error {
}
stats.Record(context.Background(), cacheTotalItems.M(int64(previousCount)))
stats.Record(context.Background(), totalActiveTickets.M(int64(len(tickets)-len(toFetch))))
stats.Record(context.Background(), cacheFetchedItems.M(int64(len(toFetch))))
stats.Record(context.Background(), cacheUpdateLatency.M(float64(time.Since(t))/float64(time.Millisecond)))
stats.Record(context.Background(), totalPendingTickets.M(int64(len(toFetch))))
logger.Debugf("Ticket Cache update: Previous %d, Deleted %d, Fetched %d, Current %d", previousCount, deletedCount, len(toFetch), len(tickets))
return nil
@ -242,6 +244,7 @@ func updateBackfillCache(store statestore.Service, value interface{}) error {
}
stats.Record(context.Background(), cacheTotalItems.M(int64(previousCount)))
stats.Record(context.Background(), totalBackfillsTickets.M(int64(len(backfills))))
stats.Record(context.Background(), cacheFetchedItems.M(int64(len(toFetch))))
stats.Record(context.Background(), cacheUpdateLatency.M(float64(time.Since(t))/float64(time.Millisecond)))

View File

@ -25,12 +25,15 @@ import (
)
var (
ticketsPerQuery = stats.Int64("open-match.dev/query/tickets_per_query", "Number of tickets per query", stats.UnitDimensionless)
backfillsPerQuery = stats.Int64("open-match.dev/query/backfills_per_query", "Number of backfills per query", stats.UnitDimensionless)
cacheTotalItems = stats.Int64("open-match.dev/query/total_cache_items", "Total number of items query service cached", stats.UnitDimensionless)
cacheFetchedItems = stats.Int64("open-match.dev/query/fetched_items", "Number of fetched items in total", stats.UnitDimensionless)
cacheWaitingQueries = stats.Int64("open-match.dev/query/waiting_queries", "Number of waiting queries in the last update", stats.UnitDimensionless)
cacheUpdateLatency = stats.Float64("open-match.dev/query/update_latency", "Time elapsed of each query cache update", stats.UnitMilliseconds)
ticketsPerQuery = stats.Int64("open-match.dev/query/tickets_per_query", "Number of tickets per query", stats.UnitDimensionless)
totalActiveTickets = stats.Int64("open-match.dev/query/total_active_tickets", "Number of tickets", stats.UnitDimensionless)
backfillsPerQuery = stats.Int64("open-match.dev/query/backfills_per_query", "Number of backfills per query", stats.UnitDimensionless)
totalBackfillsTickets = stats.Int64("open-match.dev/query/total_backfill_tickets", "Number of current backfills", stats.UnitDimensionless)
totalPendingTickets = stats.Int64("open-match.dev/query/tickets_pending_release", "Number of tickets per query", stats.UnitDimensionless)
cacheTotalItems = stats.Int64("open-match.dev/query/total_cache_items", "Total number of items query service cached", stats.UnitDimensionless)
cacheFetchedItems = stats.Int64("open-match.dev/query/fetched_items", "Number of fetched items in total", stats.UnitDimensionless)
cacheWaitingQueries = stats.Int64("open-match.dev/query/waiting_queries", "Number of waiting queries in the last update", stats.UnitDimensionless)
cacheUpdateLatency = stats.Float64("open-match.dev/query/update_latency", "Time elapsed of each query cache update", stats.UnitMilliseconds)
ticketsPerQueryView = &view.View{
Measure: ticketsPerQuery,
@ -38,12 +41,30 @@ var (
Description: "Tickets per query",
Aggregation: telemetry.DefaultCountDistribution,
}
ticketsActiveTotalView = &view.View{
Measure: totalActiveTickets,
Name: "open-match.dev/query/total_active_tickets",
Description: "Total tickets",
Aggregation: view.LastValue(),
}
backfillsPerQueryView = &view.View{
Measure: ticketsPerQuery,
Name: "open-match.dev/query/backfills_per_query",
Description: "Backfills per query",
Aggregation: telemetry.DefaultCountDistribution,
}
backfillTotalTicketsView = &view.View{
Measure: totalBackfillsTickets,
Name: "open-match.dev/query/total_backfill_tickets",
Description: "Total number of backfill tickets",
Aggregation: view.LastValue(),
}
pendingTotalTicketsView = &view.View{
Measure: totalPendingTickets,
Name: "open-match.dev/query/total_pending_tickets",
Description: "Total number of pending tickets",
Aggregation: view.LastValue(),
}
cacheTotalItemsView = &view.View{
Measure: cacheTotalItems,
Name: "open-match.dev/query/total_cached_items",
@ -90,7 +111,10 @@ func BindService(p *appmain.Params, b *appmain.Bindings) error {
}, pb.RegisterQueryServiceHandlerFromEndpoint)
b.RegisterViews(
ticketsPerQueryView,
ticketsActiveTotalView,
backfillsPerQueryView,
backfillTotalTicketsView,
pendingTotalTicketsView,
cacheTotalItemsView,
cacheUpdateView,
cacheFetchedItemsView,