Skip to content

Latest commit

 

History

History
47 lines (29 loc) · 1.74 KB

File metadata and controls

47 lines (29 loc) · 1.74 KB

Todos Backend

Welcome to our super sophisticated Todos app 😎.

The backend is an easy FastAPI application that allows creating, reading, updating, and deleting Todos.

The application works fine, but the performance is not fantastic: some bugs are making the system slow.

Your goal is to find the bugs 🐛🐞🦗 and fix them 🧐. You will instrument the code to export metrics to Prometheus and use Grafana to create beautiful dashboards 🤩.

Are you ready for the challenge? 💪🏻💪🏻💪🏻

Setup

This project is built in Python 3 and uses Poetry to manage dependencies. Make sure you have Python 3.11 and Poetry installed.

Install the dependencies as follows:

poetry install

The application requires a working PostgreSQL database. Please follow the instructions in the top-level README to run it using Docker Compose.

Run the main.py from PyCharm. If you prefer the command line, you can use the following command:

poetry shell
PYTHONPATH=. python ./app/main.py

Task

Measure the execution time of the different database operations.

Please name the metric app_repository_query_duration_seconds with the label query to take advantage of the existing Grafana dashboards.

The solution requires only a few lines of code to the InstrumentedRepository class. Please refer to the slides for code snippets or check out the official documentation of the Prometheus Python client.

Solution

The solution is available in the solution branch in git.