fastapi-radar 0.1.1__tar.gz → 0.3.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. fastapi_radar-0.3.2/PKG-INFO +245 -0
  2. fastapi_radar-0.3.2/README.md +196 -0
  3. fastapi_radar-0.3.2/fastapi_radar/__init__.py +7 -0
  4. fastapi_radar-0.3.2/fastapi_radar/api.py +677 -0
  5. fastapi_radar-0.3.2/fastapi_radar/background.py +120 -0
  6. fastapi_radar-0.3.2/fastapi_radar/capture.py +190 -0
  7. fastapi_radar-0.3.2/fastapi_radar/dashboard/dist/assets/index-BQIU9U77.js +356 -0
  8. fastapi_radar-0.3.2/fastapi_radar/dashboard/dist/assets/index-D51YrvFG.css +1 -0
  9. {fastapi_radar-0.1.1 → fastapi_radar-0.3.2}/fastapi_radar/dashboard/dist/index.html +2 -2
  10. fastapi_radar-0.3.2/fastapi_radar/dashboard/node_modules/flatted/python/flatted.py +149 -0
  11. fastapi_radar-0.3.2/fastapi_radar/middleware.py +240 -0
  12. fastapi_radar-0.3.2/fastapi_radar/models.py +190 -0
  13. fastapi_radar-0.3.2/fastapi_radar/radar.py +463 -0
  14. fastapi_radar-0.3.2/fastapi_radar/tracing.py +258 -0
  15. {fastapi_radar-0.1.1 → fastapi_radar-0.3.2}/fastapi_radar/utils.py +26 -1
  16. fastapi_radar-0.3.2/fastapi_radar.egg-info/PKG-INFO +245 -0
  17. {fastapi_radar-0.1.1 → fastapi_radar-0.3.2}/fastapi_radar.egg-info/SOURCES.txt +6 -3
  18. fastapi_radar-0.3.2/fastapi_radar.egg-info/requires.txt +21 -0
  19. {fastapi_radar-0.1.1 → fastapi_radar-0.3.2}/fastapi_radar.egg-info/top_level.txt +0 -1
  20. {fastapi_radar-0.1.1 → fastapi_radar-0.3.2}/pyproject.toml +37 -18
  21. {fastapi_radar-0.1.1 → fastapi_radar-0.3.2}/setup.py +8 -3
  22. fastapi_radar-0.3.2/tests/test_async_radar.py +56 -0
  23. {fastapi_radar-0.1.1 → fastapi_radar-0.3.2}/tests/test_radar.py +22 -13
  24. fastapi_radar-0.1.1/PKG-INFO +0 -165
  25. fastapi_radar-0.1.1/README.md +0 -120
  26. fastapi_radar-0.1.1/fastapi_radar/__init__.py +0 -6
  27. fastapi_radar-0.1.1/fastapi_radar/api.py +0 -320
  28. fastapi_radar-0.1.1/fastapi_radar/capture.py +0 -105
  29. fastapi_radar-0.1.1/fastapi_radar/dashboard/dist/assets/index-BrbdDWQe.css +0 -1
  30. fastapi_radar-0.1.1/fastapi_radar/dashboard/dist/assets/index-DjYO9SdO.js +0 -343
  31. fastapi_radar-0.1.1/fastapi_radar/middleware.py +0 -142
  32. fastapi_radar-0.1.1/fastapi_radar/models.py +0 -66
  33. fastapi_radar-0.1.1/fastapi_radar/radar.py +0 -295
  34. fastapi_radar-0.1.1/fastapi_radar.egg-info/PKG-INFO +0 -165
  35. fastapi_radar-0.1.1/fastapi_radar.egg-info/requires.txt +0 -15
  36. fastapi_radar-0.1.1/tests/__init__.py +0 -1
  37. {fastapi_radar-0.1.1 → fastapi_radar-0.3.2}/CONTRIBUTING.md +0 -0
  38. {fastapi_radar-0.1.1 → fastapi_radar-0.3.2}/LICENSE +0 -0
  39. {fastapi_radar-0.1.1 → fastapi_radar-0.3.2}/MANIFEST.in +0 -0
  40. {fastapi_radar-0.1.1 → fastapi_radar-0.3.2}/fastapi_radar.egg-info/dependency_links.txt +0 -0
  41. {fastapi_radar-0.1.1 → fastapi_radar-0.3.2}/fastapi_radar.egg-info/not-zip-safe +0 -0
  42. {fastapi_radar-0.1.1 → fastapi_radar-0.3.2}/setup.cfg +0 -0
@@ -0,0 +1,245 @@
1
+ Metadata-Version: 2.4
2
+ Name: fastapi-radar
3
+ Version: 0.3.2
4
+ Summary: A debugging dashboard for FastAPI applications with real-time monitoring
5
+ Home-page: https://github.com/doganarif/fastapi-radar
6
+ Author: Arif Dogan
7
+ Author-email: Arif Dogan <me@arif.sh>
8
+ License: MIT
9
+ Project-URL: Homepage, https://github.com/doganarif/fastapi-radar
10
+ Project-URL: Bug Reports, https://github.com/doganarif/fastapi-radar/issues
11
+ Project-URL: Source, https://github.com/doganarif/fastapi-radar
12
+ Keywords: fastapi,debugging,monitoring,dashboard,development-tools
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Framework :: FastAPI
21
+ Classifier: Topic :: Software Development :: Debuggers
22
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Requires-Python: >=3.8
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: fastapi
27
+ Requires-Dist: sqlalchemy>=2.0
28
+ Requires-Dist: pydantic
29
+ Requires-Dist: starlette
30
+ Requires-Dist: duckdb==1.1.3
31
+ Requires-Dist: duckdb-engine==0.17.0
32
+ Requires-Dist: aiosqlite>=0.21.0
33
+ Provides-Extra: dev
34
+ Requires-Dist: pytest; extra == "dev"
35
+ Requires-Dist: pytest-asyncio; extra == "dev"
36
+ Requires-Dist: uvicorn[standard]; extra == "dev"
37
+ Requires-Dist: black; extra == "dev"
38
+ Requires-Dist: isort; extra == "dev"
39
+ Requires-Dist: flake8; extra == "dev"
40
+ Requires-Dist: mypy; extra == "dev"
41
+ Requires-Dist: httpx; extra == "dev"
42
+ Provides-Extra: release
43
+ Requires-Dist: build; extra == "release"
44
+ Requires-Dist: twine; extra == "release"
45
+ Dynamic: author
46
+ Dynamic: home-page
47
+ Dynamic: license-file
48
+ Dynamic: requires-python
49
+
50
+ # FastAPI Radar
51
+
52
+ [![Python Version](https://img.shields.io/badge/python-3.8%2B-blue.svg)](https://www.python.org/downloads/)
53
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
54
+
55
+ **A debugging dashboard for FastAPI applications providing real-time request, database query, and exception monitoring.**
56
+
57
+ **Just one line to add powerful monitoring to your FastAPI app!**
58
+
59
+ ## See it in Action
60
+
61
+ ![FastAPI Radar Dashboard Demo](./assets/demo.gif)
62
+
63
+ ## Installation
64
+
65
+ ```bash
66
+ pip install fastapi-radar
67
+ ```
68
+
69
+ Or with your favorite package manager:
70
+
71
+ ```bash
72
+ # Using poetry
73
+ poetry add fastapi-radar
74
+
75
+ # Using pipenv
76
+ pipenv install fastapi-radar
77
+ ```
78
+
79
+ **Note:** The dashboard comes pre-built! No need to build anything - just install and use.
80
+
81
+ ## Quick Start
82
+
83
+ ### With SQL Database (Full Monitoring)
84
+
85
+ ```python
86
+ from fastapi import FastAPI
87
+ from fastapi_radar import Radar
88
+ from sqlalchemy import create_engine
89
+
90
+ app = FastAPI()
91
+ engine = create_engine("sqlite:///./app.db")
92
+
93
+ # Full monitoring with SQL query tracking
94
+ radar = Radar(app, db_engine=engine)
95
+ radar.create_tables()
96
+
97
+ # Your routes work unchanged
98
+ @app.get("/users")
99
+ async def get_users():
100
+ return {"users": []}
101
+ ```
102
+
103
+ ### Without SQL Database (HTTP & Exception Monitoring)
104
+
105
+ ```python
106
+ from fastapi import FastAPI
107
+ from fastapi_radar import Radar
108
+
109
+ app = FastAPI()
110
+
111
+ # Monitor HTTP requests and exceptions only
112
+ # Perfect for NoSQL databases, external APIs, or database-less apps
113
+ radar = Radar(app) # No db_engine parameter needed!
114
+ radar.create_tables()
115
+
116
+ @app.get("/api/data")
117
+ async def get_data():
118
+ # Your MongoDB, Redis, or external API calls here
119
+ return {"data": []}
120
+ ```
121
+
122
+ Access your dashboard at: **http://localhost:8000/\_\_radar/**
123
+
124
+ ## Features
125
+
126
+ - **Zero Configuration** - Works with any FastAPI app (SQL database optional)
127
+ - **Request Monitoring** - Complete HTTP request/response capture with timing
128
+ - **Database Monitoring** - SQL query logging with execution times (when using SQLAlchemy)
129
+ - **Exception Tracking** - Automatic exception capture with stack traces
130
+ - **Real-time Updates** - Live dashboard updates as requests happen
131
+ - **Flexible Integration** - Use with SQL, NoSQL, or no database at all
132
+
133
+ ## Configuration
134
+
135
+ ```python
136
+ radar = Radar(
137
+ app,
138
+ db_engine=engine, # Optional: SQLAlchemy engine for SQL query monitoring
139
+ dashboard_path="/__radar", # Custom dashboard path (default: "/__radar")
140
+ max_requests=1000, # Max requests to store (default: 1000)
141
+ retention_hours=24, # Data retention period (default: 24)
142
+ slow_query_threshold=100, # Mark queries slower than this as slow (ms)
143
+ capture_sql_bindings=True, # Capture SQL query parameters
144
+ exclude_paths=["/health"], # Paths to exclude from monitoring
145
+ theme="auto", # Dashboard theme: "light", "dark", or "auto"
146
+ db_path="/path/to/db", # Custom path for radar.duckdb file (default: current directory)
147
+ )
148
+ ```
149
+
150
+ ### Custom Database Location
151
+
152
+ By default, FastAPI Radar stores its monitoring data in a `radar.duckdb` file in your current working directory. You can customize this location using the `db_path` parameter:
153
+
154
+ ```python
155
+ # Store in a specific directory
156
+ radar = Radar(app, db_path="/var/data/monitoring")
157
+ # Creates: /var/data/monitoring/radar.duckdb
158
+
159
+ # Store with a specific filename
160
+ radar = Radar(app, db_path="/var/data/my_app_monitoring.duckdb")
161
+ # Creates: /var/data/my_app_monitoring.duckdb
162
+
163
+ # Use a relative path
164
+ radar = Radar(app, db_path="./data")
165
+ # Creates: ./data/radar.duckdb
166
+ ```
167
+
168
+ If the specified path cannot be created, FastAPI Radar will fallback to using the current directory with a warning.
169
+
170
+ ### Development Mode with Auto-Reload
171
+
172
+ When running your FastAPI application with `fastapi dev` (which uses auto-reload), FastAPI Radar automatically switches to an in-memory database to avoid file locking issues. This means:
173
+
174
+ - **No file locking errors** - The dashboard will work seamlessly in development
175
+ - **Data doesn't persist between reloads** - Each reload starts with a fresh database
176
+ - **Production behavior unchanged** - When using `fastapi run` or deploying, the normal file-based database is used
177
+
178
+ ```python
179
+ # With fastapi dev (auto-reload enabled):
180
+ # Automatically uses in-memory database - no configuration needed!
181
+ radar = Radar(app)
182
+ radar.create_tables() # Safe to call - handles multiple processes gracefully
183
+ ```
184
+
185
+ This behavior only applies when using the development server with auto-reload (`fastapi dev`). In production or when using `fastapi run`, the standard file-based DuckDB storage is used.
186
+
187
+ ## What Gets Captured?
188
+
189
+ - ✅ HTTP requests and responses
190
+ - ✅ Response times and performance metrics
191
+ - ✅ SQL queries with execution times
192
+ - ✅ Query parameters and bindings
193
+ - ✅ Slow query detection
194
+ - ✅ Exceptions with stack traces
195
+ - ✅ Request/response bodies and headers
196
+
197
+ ## Contributing
198
+
199
+ We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
200
+
201
+ ### Development Setup
202
+
203
+ For contributors who want to modify the codebase:
204
+
205
+ 1. Clone the repository:
206
+
207
+ ```bash
208
+ git clone https://github.com/doganarif/fastapi-radar.git
209
+ cd fastapi-radar
210
+ ```
211
+
212
+ 2. Install development dependencies:
213
+
214
+ ```bash
215
+ pip install -e ".[dev]"
216
+ ```
217
+
218
+ 3. (Optional) If modifying the dashboard UI:
219
+
220
+ ```bash
221
+ cd fastapi_radar/dashboard
222
+ npm install
223
+ npm run dev # For development with hot reload
224
+ # or
225
+ npm run build # To rebuild the production bundle
226
+ ```
227
+
228
+ 4. Run the example apps:
229
+
230
+ ```bash
231
+ # Example with SQL database
232
+ python example_app.py
233
+
234
+ # Example without SQL database (NoSQL/in-memory)
235
+ python example_nosql_app.py
236
+ ```
237
+
238
+ ## License
239
+
240
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
241
+
242
+ ## Acknowledgments
243
+
244
+ - Built with [FastAPI](https://fastapi.tiangolo.com/)
245
+ - Dashboard powered by [React](https://react.dev/) and [shadcn/ui](https://ui.shadcn.com/)
@@ -0,0 +1,196 @@
1
+ # FastAPI Radar
2
+
3
+ [![Python Version](https://img.shields.io/badge/python-3.8%2B-blue.svg)](https://www.python.org/downloads/)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+
6
+ **A debugging dashboard for FastAPI applications providing real-time request, database query, and exception monitoring.**
7
+
8
+ **Just one line to add powerful monitoring to your FastAPI app!**
9
+
10
+ ## See it in Action
11
+
12
+ ![FastAPI Radar Dashboard Demo](./assets/demo.gif)
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ pip install fastapi-radar
18
+ ```
19
+
20
+ Or with your favorite package manager:
21
+
22
+ ```bash
23
+ # Using poetry
24
+ poetry add fastapi-radar
25
+
26
+ # Using pipenv
27
+ pipenv install fastapi-radar
28
+ ```
29
+
30
+ **Note:** The dashboard comes pre-built! No need to build anything - just install and use.
31
+
32
+ ## Quick Start
33
+
34
+ ### With SQL Database (Full Monitoring)
35
+
36
+ ```python
37
+ from fastapi import FastAPI
38
+ from fastapi_radar import Radar
39
+ from sqlalchemy import create_engine
40
+
41
+ app = FastAPI()
42
+ engine = create_engine("sqlite:///./app.db")
43
+
44
+ # Full monitoring with SQL query tracking
45
+ radar = Radar(app, db_engine=engine)
46
+ radar.create_tables()
47
+
48
+ # Your routes work unchanged
49
+ @app.get("/users")
50
+ async def get_users():
51
+ return {"users": []}
52
+ ```
53
+
54
+ ### Without SQL Database (HTTP & Exception Monitoring)
55
+
56
+ ```python
57
+ from fastapi import FastAPI
58
+ from fastapi_radar import Radar
59
+
60
+ app = FastAPI()
61
+
62
+ # Monitor HTTP requests and exceptions only
63
+ # Perfect for NoSQL databases, external APIs, or database-less apps
64
+ radar = Radar(app) # No db_engine parameter needed!
65
+ radar.create_tables()
66
+
67
+ @app.get("/api/data")
68
+ async def get_data():
69
+ # Your MongoDB, Redis, or external API calls here
70
+ return {"data": []}
71
+ ```
72
+
73
+ Access your dashboard at: **http://localhost:8000/\_\_radar/**
74
+
75
+ ## Features
76
+
77
+ - **Zero Configuration** - Works with any FastAPI app (SQL database optional)
78
+ - **Request Monitoring** - Complete HTTP request/response capture with timing
79
+ - **Database Monitoring** - SQL query logging with execution times (when using SQLAlchemy)
80
+ - **Exception Tracking** - Automatic exception capture with stack traces
81
+ - **Real-time Updates** - Live dashboard updates as requests happen
82
+ - **Flexible Integration** - Use with SQL, NoSQL, or no database at all
83
+
84
+ ## Configuration
85
+
86
+ ```python
87
+ radar = Radar(
88
+ app,
89
+ db_engine=engine, # Optional: SQLAlchemy engine for SQL query monitoring
90
+ dashboard_path="/__radar", # Custom dashboard path (default: "/__radar")
91
+ max_requests=1000, # Max requests to store (default: 1000)
92
+ retention_hours=24, # Data retention period (default: 24)
93
+ slow_query_threshold=100, # Mark queries slower than this as slow (ms)
94
+ capture_sql_bindings=True, # Capture SQL query parameters
95
+ exclude_paths=["/health"], # Paths to exclude from monitoring
96
+ theme="auto", # Dashboard theme: "light", "dark", or "auto"
97
+ db_path="/path/to/db", # Custom path for radar.duckdb file (default: current directory)
98
+ )
99
+ ```
100
+
101
+ ### Custom Database Location
102
+
103
+ By default, FastAPI Radar stores its monitoring data in a `radar.duckdb` file in your current working directory. You can customize this location using the `db_path` parameter:
104
+
105
+ ```python
106
+ # Store in a specific directory
107
+ radar = Radar(app, db_path="/var/data/monitoring")
108
+ # Creates: /var/data/monitoring/radar.duckdb
109
+
110
+ # Store with a specific filename
111
+ radar = Radar(app, db_path="/var/data/my_app_monitoring.duckdb")
112
+ # Creates: /var/data/my_app_monitoring.duckdb
113
+
114
+ # Use a relative path
115
+ radar = Radar(app, db_path="./data")
116
+ # Creates: ./data/radar.duckdb
117
+ ```
118
+
119
+ If the specified path cannot be created, FastAPI Radar will fallback to using the current directory with a warning.
120
+
121
+ ### Development Mode with Auto-Reload
122
+
123
+ When running your FastAPI application with `fastapi dev` (which uses auto-reload), FastAPI Radar automatically switches to an in-memory database to avoid file locking issues. This means:
124
+
125
+ - **No file locking errors** - The dashboard will work seamlessly in development
126
+ - **Data doesn't persist between reloads** - Each reload starts with a fresh database
127
+ - **Production behavior unchanged** - When using `fastapi run` or deploying, the normal file-based database is used
128
+
129
+ ```python
130
+ # With fastapi dev (auto-reload enabled):
131
+ # Automatically uses in-memory database - no configuration needed!
132
+ radar = Radar(app)
133
+ radar.create_tables() # Safe to call - handles multiple processes gracefully
134
+ ```
135
+
136
+ This behavior only applies when using the development server with auto-reload (`fastapi dev`). In production or when using `fastapi run`, the standard file-based DuckDB storage is used.
137
+
138
+ ## What Gets Captured?
139
+
140
+ - ✅ HTTP requests and responses
141
+ - ✅ Response times and performance metrics
142
+ - ✅ SQL queries with execution times
143
+ - ✅ Query parameters and bindings
144
+ - ✅ Slow query detection
145
+ - ✅ Exceptions with stack traces
146
+ - ✅ Request/response bodies and headers
147
+
148
+ ## Contributing
149
+
150
+ We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
151
+
152
+ ### Development Setup
153
+
154
+ For contributors who want to modify the codebase:
155
+
156
+ 1. Clone the repository:
157
+
158
+ ```bash
159
+ git clone https://github.com/doganarif/fastapi-radar.git
160
+ cd fastapi-radar
161
+ ```
162
+
163
+ 2. Install development dependencies:
164
+
165
+ ```bash
166
+ pip install -e ".[dev]"
167
+ ```
168
+
169
+ 3. (Optional) If modifying the dashboard UI:
170
+
171
+ ```bash
172
+ cd fastapi_radar/dashboard
173
+ npm install
174
+ npm run dev # For development with hot reload
175
+ # or
176
+ npm run build # To rebuild the production bundle
177
+ ```
178
+
179
+ 4. Run the example apps:
180
+
181
+ ```bash
182
+ # Example with SQL database
183
+ python example_app.py
184
+
185
+ # Example without SQL database (NoSQL/in-memory)
186
+ python example_nosql_app.py
187
+ ```
188
+
189
+ ## License
190
+
191
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
192
+
193
+ ## Acknowledgments
194
+
195
+ - Built with [FastAPI](https://fastapi.tiangolo.com/)
196
+ - Dashboard powered by [React](https://react.dev/) and [shadcn/ui](https://ui.shadcn.com/)
@@ -0,0 +1,7 @@
1
+ """FastAPI Radar - Debugging dashboard for FastAPI applications."""
2
+
3
+ from .radar import Radar
4
+ from .background import track_background_task
5
+
6
+ __version__ = "0.3.2"
7
+ __all__ = ["Radar", "track_background_task"]