Skip to content

Commit

Permalink
Add build info to metrics (#555)
Browse files Browse the repository at this point in the history
* Add build info to metrics

* Make sure test doesn't hang
  • Loading branch information
Askaholic authored Mar 27, 2020
1 parent 52363bb commit 144e685
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ before_install:
install:
- pipenv sync --dev
- cp faf-server.example.pem faf-server.pem
- docker build -t faf-python-server .
- docker build --build-arg TRAVIS_TAG -t faf-python-server .

script:
- scripts/run_tests_with_coverage.sh
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ RUN pipenv install --ignore-pipfile --system --deploy
ADD . /code/
WORKDIR /code/

ARG TRAVIS_TAG
ENV VERSION=$TRAVIS_TAG
RUN python3 -m pip install -e .

# Main entrypoint and the default command that will be run
Expand Down
10 changes: 10 additions & 0 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@

import asyncio
import logging
import os
import signal
import socket
import sys
from datetime import datetime

import server
import server.config as config
Expand Down Expand Up @@ -136,6 +139,13 @@ async def run_profiler():
for sock in lobby_server.sockets:
sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)

server.metrics.info.info({
"version": os.environ.get("VERSION") or "dev",
"python_version": ".".join(map(str, sys.version_info[:3])),
"start_time": datetime.utcnow().strftime("%m-%d %H:%M"),
"game_uid": str(game_service.game_id_counter)
})

await done

# Cleanup
Expand Down
4 changes: 3 additions & 1 deletion server/metrics.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from prometheus_client import Counter, Gauge, Histogram
from prometheus_client import Counter, Gauge, Histogram, Info

info = Info("build", "Information collected on server start")

# ==========
# Matchmaker
Expand Down
1 change: 0 additions & 1 deletion tests/integration_tests/test_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ async def test_game_ended_rates_game(lobby_server):
host_id, _, host_proto = await connect_and_sign_in(
("test", "test_password"), lobby_server
)
await read_until_command(host_proto, "game_info")
guest_id, _, guest_proto = await connect_and_sign_in(
("Rhiza", "puff_the_magic_dragon"), lobby_server
)
Expand Down

0 comments on commit 144e685

Please sign in to comment.