Skip to content

streamfold/fastapi-backend-example

Repository files navigation

FastAPI - Rotel Demo

This is a demo of the Rotel Python integration with the FastAPI project. Using the FastAPI instrumentation, it will emit trace spans that can be sent to any compatible tracing vendor. See the Enabling Rotel section below for how to enable Rotel and OpenTelemetry for your own FastAPI project.

This is the backend component from the fullstack FastAPI demo template. For full instructions on how to run the FastAPI backend, see the FastAPI README.

Usage

Copy the .env.example to .env and set the appropriate environment variables.

This project uses the uv project manager, to install dependencies run:

uv sync

Run a server listening on http://127.0.0.1:10000:

uv run uvicorn app.main:app --host 0.0.0.0 --port "10000" --workers 2

Test that the server is running:

curl http://127.0.0.1:10000/api/v1/utils/health-check/

Enabling Rotel

See the initialize_tracing method in main.py for how we enable OpenTelemetry tracing and Rotel to emit traces to Axiom.

To start the server with Rotel enabled, set the following environment variables before starting the server:

export AXIOM_API_KEY=xaat-xxxxxxxx
export AXIOM_DATA_SET=my-data-set

uv run uvicorn app.main:app --host 0.0.0.0 --port "10000" --workers 2

Deploying to Render

This project can also be deployed to Render using the provided build and run scripts. Fork this repo and connect it to Render, setting the following script paths in the app config. Set the environment variables as needed in Render's configuration section.

Questions / Support

Do you have questions about this project or want to share your feedback? Join our Discord server where we'd be happy to discuss this integration. See you there! 🚀

About

Example of using Rotel with FastAPI

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published