-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: start collecting engine metrics (#86)
## How does this PR impact the user? No direct impact. This will help us debug performance issues :) ## Description <img width="1424" alt="image" src="https://github.com/user-attachments/assets/d87c38ae-6e72-434b-9ff5-d0f14d3f19c8"> ## Limitations - we most likely will want to get rid of per-user metric at some point; but, for now, it's fine 😄 ## Checklist - [x] my PR is focused and contains one wholistic change - [x] I have added screenshots or screen recordings to show the changes
- Loading branch information
1 parent
195c33b
commit 9fa7dbb
Showing
6 changed files
with
111 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import promClient from "prom-client"; | ||
|
||
export const gameStepTimeMs = new promClient.Histogram({ | ||
name: "game_step_time_ms", | ||
help: "Time all bots took to make a move and engine took to process them", | ||
buckets: [200, 250], | ||
}); | ||
|
||
export const botCodeRunTimeMs = new promClient.Histogram({ | ||
name: "bot_code_run_time_ms", | ||
help: "Time a bot took to make a move", | ||
buckets: [50, 75], | ||
labelNames: ["username"] as const, | ||
}); | ||
|
||
export const gameStepCodeRunTimeMs = new promClient.Histogram({ | ||
name: "game_step_code_run_time_ms", | ||
help: "Time all bots took to make a move", | ||
buckets: [50, 100, 150], | ||
}); | ||
|
||
export const gameStepMoveBotTimeMs = new promClient.Summary({ | ||
name: "game_step_move_bot_time_ms", | ||
help: "Time it took to move all bots", | ||
}); | ||
|
||
export const gameStepCollisionCheckTimeMs = new promClient.Summary({ | ||
name: "game_step_collision_check_time_ms", | ||
help: "Time it took to check for collisions", | ||
}); | ||
|
||
export const gameStepFoodSpawnTimeMs = new promClient.Summary({ | ||
name: "game_step_food_spawn_time_ms", | ||
help: "Time it took to spawn food", | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import promClient from "prom-client"; | ||
|
||
promClient.collectDefaultMetrics(); | ||
|
||
export default defineEventHandler(async () => { | ||
const metrics = await promClient.register.metrics(); | ||
return new Response(metrics, { | ||
headers: { | ||
"Content-Type": promClient.register.contentType, | ||
}, | ||
}); | ||
}); |