Add food metric
This commit is contained in:
parent
d9308e8753
commit
5e02c4d320
33
schlafana.py
33
schlafana.py
|
@ -55,6 +55,36 @@ class BotMassGaugeCollector(object):
|
|||
yield c
|
||||
|
||||
|
||||
class BotFoodCarrionCollector(object):
|
||||
def collect(self):
|
||||
c = CounterMetricFamily("carrion_food", "Carrion food consumed", labels=["name", "snake_id", "code_id"])
|
||||
for user in game.users.users:
|
||||
user = game.users.users.get(user)
|
||||
rev = user.revs.get(user.current_rev)
|
||||
c.add_metric([user.name, str(user.current_worm), str(user.current_rev)], rev.carrion_food_consumed)
|
||||
yield c
|
||||
|
||||
|
||||
class BotFoodNaturalCollector(object):
|
||||
def collect(self):
|
||||
c = CounterMetricFamily("natural_food", "Natural food consumed", labels=["name", "snake_id", "code_id"])
|
||||
for user in game.users.users:
|
||||
user = game.users.users.get(user)
|
||||
rev = user.revs.get(user.current_rev)
|
||||
c.add_metric([user.name, str(user.current_worm), str(user.current_rev)], rev.natural_food_consumed)
|
||||
yield c
|
||||
|
||||
|
||||
class BotFoodHuntedCollector(object):
|
||||
def collect(self):
|
||||
c = CounterMetricFamily("hunted_food", "Hunted food consumed", labels=["name", "snake_id", "code_id"])
|
||||
for user in game.users.users:
|
||||
user = game.users.users.get(user)
|
||||
rev = user.revs.get(user.current_rev)
|
||||
c.add_metric([user.name, str(user.current_worm), str(user.current_rev)], rev.hunted_food_consumed)
|
||||
yield c
|
||||
|
||||
|
||||
def main():
|
||||
global game
|
||||
game = Game()
|
||||
|
@ -73,6 +103,9 @@ def main():
|
|||
REGISTRY.register(BotKillCollector())
|
||||
REGISTRY.register(BotRevisionCountCollector())
|
||||
REGISTRY.register(BotMassGaugeCollector())
|
||||
REGISTRY.register(BotFoodCarrionCollector())
|
||||
REGISTRY.register(BotFoodNaturalCollector())
|
||||
REGISTRY.register(BotFoodHuntedCollector())
|
||||
start_http_server(9000)
|
||||
logger.info("Start prometheus scrape endpoint")
|
||||
|
||||
|
|
Loading…
Reference in a new issue