monitor lobby segments

pull/5803/head
Thibault Duplessis 2019-12-21 15:55:45 -06:00
parent de678847fe
commit cb3cc3fe34
5 changed files with 52 additions and 40 deletions

View File

@ -17,7 +17,12 @@ final class KeyPages(env: Env)(implicit ec: scala.concurrent.ExecutionContext) {
events = env.event.api.promoteTo(ctx.req).nevermind,
simuls = env.simul.allCreatedFeaturable.get.nevermind
)
.map(h => html.lobby.home(h))
.mon(_.lobby segment "preloader")
.map { h =>
lila.mon.chronoSync(_.lobby segment "render") {
html.lobby.home(h)
}
}
.dmap { (html: Frag) =>
env.lilaCookie.ensure(ctx.req)(status(html))
}

View File

@ -20,7 +20,7 @@ final class Lobby(
def home = Open { implicit ctx =>
pageHit
negotiate(
html = keyPages.home(Results.Ok).map(NoCache),
html = keyPages.home(Results.Ok).dmap(NoCache),
api = _ =>
fuccess {
val expiration = 60 * 60 * 24 * 7 // set to one hour, one week before changing the pool config

View File

@ -39,43 +39,46 @@ final class Preload(
events: Fu[List[Event]],
simuls: Fu[List[Simul]]
)(implicit ctx: Context): Fu[Homepage] =
lobbyApi(ctx) zip
posts zip
tours zip
events zip
simuls zip
tv.getBestGame zip
(ctx.userId ?? timelineApi.userEntries) zip
userCached.topWeek(()) zip
tourWinners.all.dmap(_.top) zip
(ctx.noBot ?? dailyPuzzle()) zip
liveStreamApi.all.dmap(_.autoFeatured withTitles lightUserApi) zip
(ctx.userId ?? playbanApi.currentBan) zip
lobbyApi(ctx).mon(_.lobby segment "lobbyApi") zip
posts.mon(_.lobby segment "posts") zip
tours.mon(_.lobby segment "tours") zip
events.mon(_.lobby segment "events") zip
simuls.mon(_.lobby segment "simuls") zip
tv.getBestGame.mon(_.lobby segment "tvBestGame") zip
(ctx.userId ?? timelineApi.userEntries).mon(_.lobby segment "timeline") zip
userCached.topWeek(()).mon(_.lobby segment "userTopWeek") zip
tourWinners.all.dmap(_.top).mon(_.lobby segment "tourWinners") zip
(ctx.noBot ?? dailyPuzzle()).mon(_.lobby segment "puzzle") zip
liveStreamApi.all.dmap(_.autoFeatured withTitles lightUserApi).mon(_.lobby segment "streams") zip
(ctx.userId ?? playbanApi.currentBan).mon(_.lobby segment "playban") zip
(ctx.blind ?? ctx.me ?? roundProxy.urgentGames) flatMap {
case (data, povs) ~ posts ~ tours ~ events ~ simuls ~ feat ~ entries ~ lead ~ tWinners ~ puzzle ~ streams ~ playban ~ blindGames =>
(ctx.me ?? currentGameMyTurn(povs, lightUserApi.sync) _) flatMap { currentGame =>
lightUserApi.preloadMany {
tWinners.map(_.userId) :::
posts.flatMap(_.userId) :::
entries.flatMap(_.userIds).toList
} inject Homepage(
data,
entries,
posts,
tours,
events,
simuls,
feat,
lead,
tWinners,
puzzle,
streams.excludeUsers(events.flatMap(_.hostedBy)),
lastPostCache.apply,
playban,
currentGame,
simulIsFeaturable,
blindGames
)
(ctx.me ?? currentGameMyTurn(povs, lightUserApi.sync) _)
.mon(_.lobby segment "currentGame") zip
lightUserApi
.preloadMany {
tWinners.map(_.userId) ::: posts.flatMap(_.userId) ::: entries.flatMap(_.userIds).toList
}
.mon(_.lobby segment "lightUsers") map {
case (currentGame, _) =>
Homepage(
data,
entries,
posts,
tours,
events,
simuls,
feat,
lead,
tWinners,
puzzle,
streams.excludeUsers(events.flatMap(_.hostedBy)),
lastPostCache.apply,
playban,
currentGame,
simulIsFeaturable,
blindGames
)
}
}

View File

@ -19,9 +19,9 @@ final class LobbyApi(
val poolsJson = Json toJson pools
def apply(implicit ctx: Context): Fu[(JsObject, List[Pov])] =
ctx.me.fold(seekApi.forAnon)(seekApi.forUser) zip
(ctx.me ?? gameProxyRepo.urgentGames) zip
getFilter(ctx) flatMap {
ctx.me.fold(seekApi.forAnon)(seekApi.forUser).mon(_.lobby segment "seeks") zip
(ctx.me ?? gameProxyRepo.urgentGames).mon(_.lobby segment "urgentGames") zip
getFilter(ctx).mon(_.lobby segment "filter") flatMap {
case seeks ~ povs ~ filter =>
val displayedPovs = povs take 9
lightUserApi.preloadMany(displayedPovs.flatMap(_.opponent.userId)) inject {

View File

@ -112,6 +112,8 @@ object mon {
def duration(id: String) = timer("lobby.pool.gameStart.duration").withTag("pool", id)
}
}
private val lobbySegment = timer("lobby.segment")
def segment(seg: String) = lobbySegment.withTag("segment", seg)
}
object rating {
def distribution(perfKey: String, rating: Int) =
@ -521,6 +523,8 @@ object mon {
def time(name: String) = timer("blocking.time").withTag("name", name)
}
def chronoSync[A] = lila.common.Chronometer.syncMon[A] _
type TimerPath = lila.mon.type => Timer
type CounterPath = lila.mon.type => Counter