A FastAPI observability demo implementing traces (Tempo), metrics (Prometheus), and logs (Loki) with OpenTelemetry and Grafana.
FastAPI Observability is a demonstration project that shows how to implement comprehensive observability for FastAPI applications using the Grafana stack (Prometheus, Tempo, Loki) and OpenTelemetry. It provides a working example of instrumenting FastAPI to collect traces, metrics with exemplars, and correlated logs, then visualizing them in Grafana with seamless navigation between telemetry data.
Backend developers and DevOps engineers building or monitoring FastAPI services who want to implement production-grade observability with open-source tools.
It offers a complete, ready-to-run reference implementation that saves time compared to piecing together observability components manually, and demonstrates best practices like trace-to-log correlation and metrics exemplars that are often poorly documented.
Observe FastAPI app with three pillars of observability: Traces (Tempo), Metrics (Prometheus), Logs (Loki) on Grafana through OpenTelemetry.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Provides a ready-to-run Docker Compose setup with Prometheus, Tempo, Loki, and a prebuilt Grafana dashboard, saving time on integration and configuration.
Uses OpenTelemetry SDK for manual instrumentation, allowing developers to add custom attributes and exemplars to metrics, as shown in the metrics and logging code examples.
Demonstrates metrics with exemplars and Loki derived fields, enabling direct navigation between traces, metrics, and logs in Grafana, as illustrated in the correlation images.
Includes practical examples of trace propagation using HTTP header injection and automatic HTTPX instrumentation, useful for microservices architectures.
Requires installing the Loki Docker Driver and troubleshooting plugin issues, adding deployment overhead compared to simpler monitoring solutions.
Heavily dependent on Tempo, Loki, and Prometheus; configuration files are tailored to these tools, limiting flexibility for teams using other observability stacks.
Admits to a known issue with FastAPI instrumentation causing internal spans, requiring a workaround from a GitHub issue, which can add complexity and maintenance burden.