Add frame count metric

This commit is contained in:
sqozz 2018-05-11 21:10:46 +02:00
parent 4e8575cbe1
commit 64d4eb0344

View file

@ -10,10 +10,11 @@ import time
MESSAGES = { "GameInfo" : 0x00,
"WorldUpdate" : 0x01,
"Tick" : 0x10,
"BotSpawn" : 0x20,
"BotKill" : 0x21,
"BotMove" : 0x22,
"BotStats" : 0x24
"BotStats" : 0x24,
}
@ -100,6 +101,7 @@ class Game():
self.food_decay_per_frame = 0
self.users = UserList()
self.uptime = Summary("api_up", "Status of the server API")
self.frames = Counter("frames", "Frame counter")
pass
@ -144,8 +146,10 @@ class Game():
for bot in bots:
bot = bots.get(bot)
self.users.update_by_name(bot.get("name"), data=bot)
elif typ == MESSAGES["Tick"]:
game.frames.inc()
elif msg_type != "FoodSpawn" and msg_type != "WorldUpdate" and msg_type != "FoodConsume" and msg_type != "BotMoveHead" and msg_type != "Tick" and msg_type != "FoodDecay":
elif msg_type != "FoodSpawn" and msg_type != "FoodConsume" and msg_type != "BotMoveHead" and msg_type != "FoodDecay":
logging.fatal("Unhandled msg_type: {}".format(msg_type))