{"id":31581057,"url":"https://github.com/execreate/observability-demo","last_synced_at":"2026-05-11T07:23:50.512Z","repository":{"id":316382754,"uuid":"1062630758","full_name":"execreate/observability-demo","owner":"execreate","description":"Testing out distributed tracing and logging","archived":false,"fork":false,"pushed_at":"2025-09-24T08:04:54.000Z","size":309,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-24T10:13:02.442Z","etag":null,"topics":["clickhouse","fastapi","observability","opentelemetry"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/execreate.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-23T14:07:24.000Z","updated_at":"2025-09-24T08:04:58.000Z","dependencies_parsed_at":"2025-09-24T10:25:15.171Z","dependency_job_id":null,"html_url":"https://github.com/execreate/observability-demo","commit_stats":null,"previous_names":["execreate/observability-demo"],"tags_count":null,"template":false,"template_full_name":"execreate/fastapi-template","purl":"pkg:github/execreate/observability-demo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/execreate%2Fobservability-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/execreate%2Fobservability-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/execreate%2Fobservability-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/execreate%2Fobservability-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/execreate","download_url":"https://codeload.github.com/execreate/observability-demo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/execreate%2Fobservability-demo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278526242,"owners_count":26001325,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-05T02:00:06.059Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clickhouse","fastapi","observability","opentelemetry"],"created_at":"2025-10-05T21:52:34.923Z","updated_at":"2025-10-05T21:52:37.802Z","avatar_url":"https://github.com/execreate.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Observability demo\n\nA demo setup for testing out [OpenTelemetry](https://opentelemetry.io) and\n[ClickStack](https://clickhouse.com/use-cases/observability) for distributed tracing and logging.\n\n## What's new\n\nThis project is completely the same as my [FastAPI Template](https://github.com/execreate/fastapi-template),\nexcept for some minor changes. This is a very silly (but okay for the demo) setup with two identical apps where\nthe [first one](./one) mirrors all requests to the [second one](./two). The [Docker Compose file](./docker-compose.yml)\nhas also been adapted to spin up both apps with separate PostgreSQL databases.\n\n### How to run\n\n1. Copy-paste the content from `.env.example` to `.env` for both apps (the [first one](./one) and\n   the [second one](./two)).\n2. Run `docker compose up -d clickstack`.\n3. Open http://localhost:8081, set up your ClickStack user and copy the ingestion API key into your `.env`.\n4. The run `docker compose up -d` to start the rest of the components.\n5. Run [Locust](https://locust.io) for load tests.\n6. Open http://localhost:8089 to access Locust UI. Set the host parameter to the first app URL `http://localhost:8091`,\n   adjust other parameters like test duration and concurrency, then start the test.\n7. You should see the logs and traces coming in from the backend on ClickStack UI at http://localhost:8081.\n\n### How it looks\n\n![A screenshot to showcase distributed tracing and logging](screenshot.png)\n\n## Original README\n\n\u003cdetails\u003e\n\n\u003csummary\u003eClick here to see the rest of original README from the FastAPI Template\u003c/summary\u003e\n\n## Features overview\n\n1. [uv](https://docs.astral.sh/uv/) for dependency management.\n    - Run `uv sync --group=telemetry --group=load-testing` to install all deps.\n2. Docker compose for local development and testing\n    1. Make sure to create `.env` file before you start (refer to `.env.example`)\n    2. First start the ClickStack service with `docker compose up -d clickstack`\n    3. Open http://localhost:8081, set up your ClickStack user and copy the ingestion API key into your `.env`\n    4. The run `docker compose up` to start the database and the app\n    5. Optionally run [Locust](https://locust.io) for load tests (beware that the `locustfile.py` was vibe-coded!)\n3. [SQL Alchemy](https://www.sqlalchemy.org) and [Alembic](https://alembic.sqlalchemy.org/en/latest/) for database\n   operations\n    - Go to the `app/` directory and run `alembic revision --autogenerate -m \"my message\"` to create a new migration\n    - Run `alembic upgrade head` to apply the migration\n    - Run `alembic downgrade -1` to revert the migration\n4. Basic authentication for the documentation page\n    - Simply showcasing how auth can be handled in a FastAPI app\n    - The API endpoints themselves are not protected!\n    - Access the docs page at http://localhost:8080/docs, default login credentials are `docs_user` and\n      `simple_password`\n5. CRUD operations generic class with pagination\n    - Check out the [CRUD factory](app/db/crud/base.py) for more details\n    - The [blog post example](app/db/crud/blog_post.py) is a good starting point to see\n      it [in action](app/api/v1/blog_post.py)\n6. Async testing suite with Pytest\n    - Before running unit tests you must start the database with `docker compose up -d db`\n    - Run `ENVIRONMENT=test uv run pytest` to run the tests\n    - Having `ENVIRONMENT=test` in your env is pretty important here because it affects\n      the [CRUD factory](app/db/crud/base.py) operations and database table\n      names [the SQL Alchemy base class](app/db/base_class.py)\n7. [ClickStack](https://clickhouse.com/use-cases/observability) integration for logs and metrics\n    - Logs are already correlated with traces, so you get a nice overview of your backend operations\n    - You must use [the logging setup](app/logging_setup.py) for your logs to be properly exported to the OTEL collector\n    - In any given file you'd do `from logging_setup import setup_gunicorn_logging` and then\n      `logger = setup_gunicorn_logging(__name__)`\n    - Logs in this demo app are for demo purposes only, make sure to review them when coding your own logic\n\n## Demo setup\n\n1. Clone this app and copy-paste the content from `.env.example` to `.env`\n2. Run `docker compose up -d clickstack`\n3. Open http://localhost:8081, set up your ClickStack user and copy the ingestion API key into your `.env`\n4. The run `docker compose up` to start the database and the app\n5. Run [Locust](https://locust.io) for load tests (another reminder that the `locustfile.py` was vibe-coded, feel free\n   to adapt it)\n6. Open http://localhost:8089 to access Locust UI. Set the host parameter to the backend URL `http://localhost:8080`,\n   adjust other parameters and start the test\n7. You should see the logs and traces coming in from the backend on ClickStack UI at http://localhost:8081\n\n## Project structure\n\nSince all app code (except tests) lives inside `app/` folder, make sure to mark that directory as Sources Root in your\nIDE.\n\nYour imports should look like this:\n\n```python\nfrom core.config import settings\n```\n\nand NOT like this:\n\n```python\n# this will throw an error!\nfrom app.core.config import settings\n```\n\nThe Dockerfile is also configured to copy over only the `app/` folder.\n\n## OpenTelemetry instrumentation\n\nTo include instrumentation for your new dependencies, you can use the `opentelemetry-bootstrap` command:\n\n```shell\nuv add --group telemetry $(opentelemetry-bootstrap -a requirements)\n```\n\n\u003c/details\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexecreate%2Fobservability-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fexecreate%2Fobservability-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexecreate%2Fobservability-demo/lists"}