fastapi-observability
FastAPI Observability is a reference implementation demonstrating how to integrate FastAPI applications with the three pillars of observability: distributed tracing (Tempo), metrics (Prometheus), and logs (Loki), all visualized through Grafana. It provides production-ready patterns for trace ID correlation across services and exemplar-based navigation between signals.
Key facts
Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.
| Field | Value |
|---|---|
| Repository | blueswen/fastapi-observability |
| Owner | blueswen |
| Primary language | Python |
| License | MIT — OSI-approved |
| Stars | 1.1k |
| Forks | 139 |
| Open issues | 6 |
| Latest release | Unknown |
| Last updated | 2026-04-12 |
| Source | https://github.com/blueswen/fastapi-observability |
What fastapi-observability is
The project provides Docker Compose configuration and Python instrumentation code leveraging OpenTelemetry SDK to emit traces via gRPC to Tempo, Prometheus Python Client for metrics with exemplars, and LoggingInstrumentor for trace-ID-enriched logs. It demonstrates cross-service span propagation, metric-to-trace correlation via exemplars, and Grafana dashboard configuration for unified observability.
Get the fastapi-observability source
Clone the repository and explore it locally.
git clone https://github.com/blueswen/fastapi-observability.gitcd fastapi-observability# follow the project's README for install & configurationNeed it deployed, integrated, or customized instead? DEV.co ships production installs.
Best use cases
Implementation considerations
- Loki Docker Driver installation is a prerequisite; verify ARM64 vs AMD64 compatibility and enable plugin after install.
- Trace ID must be manually injected into outbound HTTP headers via `inject()` or instrumented via the HTTPXClientInstrumentor; automatic propagation is not guaranteed across all client libraries.
- The FastAPIInstrumentor generates child spans for internal ASGI interactions, which may inflate trace size; mitigation requires custom middleware as documented in the referenced issue #831.
- Log format override uses `LoggingInstrumentor` set_logging_format=True; verify compatibility with existing Python logging configuration and handlers in your application.
- gRPC endpoint for OTLP must be reachable from application containers; network policy and DNS resolution should be validated in production deployments.
When to avoid it — and what to weigh
- Serverless or Event-Driven Architecture Dominance — The project assumes always-on services with direct HTTP communication. Serverless functions, async message queues, and ephemeral workloads require adapted instrumentation patterns not covered here.
- Non-Python Application Stack — The instrumentation code is Python-specific (OpenTelemetry Python SDK, Prometheus client). Multi-language environments require separate implementation per language.
- Lightweight, Zero-Setup Observability Requirement — This stack requires running and maintaining five additional services (Grafana, Tempo, Prometheus, Loki, plus log driver). Teams seeking minimal infrastructure overhead should consider managed SaaS alternatives.
- Strict Resource Constraints on Edge/IoT — The OpenTelemetry SDK and gRPC exporters add runtime overhead. Batch span processing helps but does not eliminate the footprint—unsuitable for severely resource-constrained environments.
License & commercial use
MIT License. Permissive OSI-approved license allowing commercial use, modification, and distribution with no warranty.
MIT license permits commercial use without royalties or restrictions. However, the project is a reference implementation and code example, not a supported product. Commercial deployment should involve internal testing, customization, and support plan for the observability stack itself (Grafana, Prometheus, Tempo, Loki versions and security patches).
DEV.co evaluation signals
Editorial assessment — not user reviews. Directional, with an explicit confidence level.
| Signal | Assessment |
|---|---|
| Maintenance | Active |
| Documentation | Adequate |
| License clarity | Clear |
| Deployment complexity | Moderate |
| DEV.co fit | Good |
| Assessment confidence | High |
Observability stack handles sensitive operational data (traces, logs, metrics). No security hardening guidance provided in documentation. Consider: gRPC transport encryption for OTLP exporter, Grafana authentication/RBAC, Loki data retention policies, log scrubbing for PII in traces/logs, and network isolation between app and observability backend. Default docker-compose credentials (admin:admin) must not be used in production.
Alternatives to consider
Datadog APM + Log Management
Fully managed SaaS with native FastAPI instrumentation, automatic trace correlation, and reduced operational overhead. Suitable if vendor lock-in and ongoing costs are acceptable.
New Relic One + OpenTelemetry
Managed backend supporting OTLP export; eliminates need to run Tempo, Prometheus, Loki. Trade-off: SaaS pricing and less control over data storage.
Jaeger (OSS alternative to Tempo)
Alternative tracing backend with similar API. May integrate with Prometheus/Loki, but ecosystem integration and Grafana native support is stronger for Tempo.
Build on fastapi-observability with DEV.co software developers
We help DevOps and engineering teams design and deploy scalable observability stacks. Let's discuss your tracing, metrics, and logging strategy.
Talk to DEV.coRelated open-source tools
Surfaced by semantic similarity across the DEV.co open-source index.
Related on DEV.co
Explore the category and the services that help you build with it.
fastapi-observability FAQ
Can I use this without Loki?
How do I propagate trace IDs to external HTTP services?
What happens if the Tempo gRPC endpoint is unreachable?
Is this production-ready out of the box?
Work with a software development agency
Need help beyond evaluating fastapi-observability? DEV.co is a software development agency offering software development services and web development for teams of every size. Our software developers and web developers build custom software, web applications, APIs, and open-source observability integrations — and maintain them long-term.
Ready to Instrument Your FastAPI Services?
We help DevOps and engineering teams design and deploy scalable observability stacks. Let's discuss your tracing, metrics, and logging strategy.