fastapi-radar 0.1.3__py3-none-any.whl → 0.1.5__py3-none-any.whl

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.

Potentially problematic release.


This version of fastapi-radar might be problematic. Click here for more details.

fastapi_radar/__init__.py CHANGED
@@ -2,5 +2,5 @@
2
2
 
3
3
  from .radar import Radar
4
4
 
5
- __version__ = "0.1.0"
5
+ __version__ = "0.1.5"
6
6
  __all__ = ["Radar"]
fastapi_radar/radar.py CHANGED
@@ -18,7 +18,7 @@ class Radar:
18
18
  def __init__(
19
19
  self,
20
20
  app: FastAPI,
21
- db_engine: Engine,
21
+ db_engine: Optional[Engine] = None,
22
22
  storage_engine: Optional[Engine] = None,
23
23
  dashboard_path: str = "/__radar",
24
24
  max_requests: int = 1000,
@@ -37,6 +37,7 @@ class Radar:
37
37
  self.capture_sql_bindings = capture_sql_bindings
38
38
  self.exclude_paths = exclude_paths or []
39
39
  self.theme = theme
40
+ self.query_capture = None # Initialize to None
40
41
 
41
42
  # Add all radar paths to excluded paths - exclude everything under /__radar
42
43
  if dashboard_path not in self.exclude_paths:
@@ -61,7 +62,11 @@ class Radar:
61
62
 
62
63
  # Initialize components
63
64
  self._setup_middleware()
64
- self._setup_query_capture()
65
+
66
+ # Only setup query capture if db_engine is provided
67
+ if self.db_engine:
68
+ self._setup_query_capture()
69
+
65
70
  self._setup_api()
66
71
  self._setup_dashboard()
67
72
 
@@ -120,7 +125,6 @@ class Radar:
120
125
 
121
126
  # Add a catch-all route for the dashboard SPA
122
127
  # This ensures all sub-routes under /__radar serve the index.html
123
- @self.app.get(f"{self.dashboard_path}")
124
128
  @self.app.get(f"{self.dashboard_path}/{{full_path:path}}")
125
129
  async def serve_dashboard(request: Request, full_path: str = ""):
126
130
  # Check if it's a request for a static asset
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastapi-radar
3
- Version: 0.1.3
3
+ Version: 0.1.5
4
4
  Summary: A debugging dashboard for FastAPI applications with real-time monitoring
5
5
  Home-page: https://github.com/doganarif/fastapi-radar
6
6
  Author: Arif Dogan
@@ -28,8 +28,6 @@ Requires-Dist: fastapi>=0.68.0
28
28
  Requires-Dist: sqlalchemy>=1.4.0
29
29
  Requires-Dist: pydantic>=1.8.0
30
30
  Requires-Dist: starlette>=0.14.2
31
- Requires-Dist: black>=24.8.0
32
- Requires-Dist: httpx>=0.28.1
33
31
  Provides-Extra: dev
34
32
  Requires-Dist: pytest>=7.0.0; extra == "dev"
35
33
  Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
@@ -38,21 +36,22 @@ Requires-Dist: black>=22.0.0; extra == "dev"
38
36
  Requires-Dist: isort>=5.10.0; extra == "dev"
39
37
  Requires-Dist: flake8>=4.0.0; extra == "dev"
40
38
  Requires-Dist: mypy>=0.950; extra == "dev"
39
+ Requires-Dist: httpx>=0.28.1; extra == "dev"
41
40
  Dynamic: author
42
41
  Dynamic: home-page
43
42
  Dynamic: license-file
44
43
  Dynamic: requires-python
45
44
 
46
- # FastAPI Radar 🛰️
45
+ # FastAPI Radar
47
46
 
48
47
  [![Python Version](https://img.shields.io/badge/python-3.8%2B-blue.svg)](https://www.python.org/downloads/)
49
48
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
50
49
 
51
50
  **A debugging dashboard for FastAPI applications providing real-time request, database query, and exception monitoring.**
52
51
 
53
- **Just one line to add powerful monitoring to your FastAPI app!**
52
+ **Just one line to add powerful monitoring to your FastAPI app!**
54
53
 
55
- ## 🎯 See it in Action
54
+ ## See it in Action
56
55
 
57
56
  ![FastAPI Radar Dashboard Demo](./assets/demo.gif)
58
57
 
@@ -76,6 +75,8 @@ pipenv install fastapi-radar
76
75
 
77
76
  ## Quick Start
78
77
 
78
+ ### With SQL Database (Full Monitoring)
79
+
79
80
  ```python
80
81
  from fastapi import FastAPI
81
82
  from fastapi_radar import Radar
@@ -84,7 +85,7 @@ from sqlalchemy import create_engine
84
85
  app = FastAPI()
85
86
  engine = create_engine("sqlite:///./app.db")
86
87
 
87
- # That's it! One line to add complete monitoring 🚀
88
+ # Full monitoring with SQL query tracking
88
89
  radar = Radar(app, db_engine=engine)
89
90
  radar.create_tables()
90
91
 
@@ -94,31 +95,62 @@ async def get_users():
94
95
  return {"users": []}
95
96
  ```
96
97
 
98
+ ### Without SQL Database (HTTP & Exception Monitoring)
99
+
100
+ ```python
101
+ from fastapi import FastAPI
102
+ from fastapi_radar import Radar
103
+
104
+ app = FastAPI()
105
+
106
+ # Monitor HTTP requests and exceptions only
107
+ # Perfect for NoSQL databases, external APIs, or database-less apps
108
+ radar = Radar(app) # No db_engine parameter needed!
109
+ radar.create_tables()
110
+
111
+ @app.get("/api/data")
112
+ async def get_data():
113
+ # Your MongoDB, Redis, or external API calls here
114
+ return {"data": []}
115
+ ```
116
+
97
117
  Access your dashboard at: **http://localhost:8000/\_\_radar/**
98
118
 
99
119
  ## Features
100
120
 
101
- - 🚀 **Zero Configuration** - Works with any FastAPI + SQLAlchemy app
102
- - 📊 **Request Monitoring** - Complete HTTP request/response capture with timing
103
- - 🗃️ **Database Monitoring** - SQL query logging with execution times
104
- - 🐛 **Exception Tracking** - Automatic exception capture with stack traces
105
- - **Real-time Updates** - Live dashboard updates as requests happen
106
- - 🎨 **Beautiful UI** - Modern React dashboard with shadcn/ui components
121
+ - **Zero Configuration** - Works with any FastAPI app (SQL database optional)
122
+ - **Request Monitoring** - Complete HTTP request/response capture with timing
123
+ - **Database Monitoring** - SQL query logging with execution times (when using SQLAlchemy)
124
+ - **Exception Tracking** - Automatic exception capture with stack traces
125
+ - **Real-time Updates** - Live dashboard updates as requests happen
126
+ - **Flexible Integration** - Use with SQL, NoSQL, or no database at all
107
127
 
108
128
  ## Configuration
109
129
 
110
130
  ```python
111
131
  radar = Radar(
112
132
  app,
113
- db_engine=engine,
114
- dashboard_path="/__radar", # Custom dashboard path
115
- enable_in_production=False, # Disable in production
116
- capture_body=True, # Capture request/response bodies
117
- capture_headers=True, # Capture headers
118
- max_body_size=10000, # Max body size to capture
133
+ db_engine=engine, # Optional: SQLAlchemy engine for SQL query monitoring
134
+ dashboard_path="/__radar", # Custom dashboard path (default: "/__radar")
135
+ max_requests=1000, # Max requests to store (default: 1000)
136
+ retention_hours=24, # Data retention period (default: 24)
137
+ slow_query_threshold=100, # Mark queries slower than this as slow (ms)
138
+ capture_sql_bindings=True, # Capture SQL query parameters
139
+ exclude_paths=["/health"], # Paths to exclude from monitoring
140
+ theme="auto", # Dashboard theme: "light", "dark", or "auto"
119
141
  )
120
142
  ```
121
143
 
144
+ ## What Gets Captured?
145
+
146
+ - ✅ HTTP requests and responses
147
+ - ✅ Response times and performance metrics
148
+ - ✅ SQL queries with execution times
149
+ - ✅ Query parameters and bindings
150
+ - ✅ Slow query detection
151
+ - ✅ Exceptions with stack traces
152
+ - ✅ Request/response bodies and headers
153
+
122
154
  ## Contributing
123
155
 
124
156
  We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
@@ -150,10 +182,14 @@ npm run dev # For development with hot reload
150
182
  npm run build # To rebuild the production bundle
151
183
  ```
152
184
 
153
- 4. Run the example app:
185
+ 4. Run the example apps:
154
186
 
155
187
  ```bash
188
+ # Example with SQL database
156
189
  python example_app.py
190
+
191
+ # Example without SQL database (NoSQL/in-memory)
192
+ python example_nosql_app.py
157
193
  ```
158
194
 
159
195
  ## License
@@ -1,17 +1,17 @@
1
- fastapi_radar/__init__.py,sha256=AIZy7tyr7kPLDQNspJTEbkCZXThWvRkm0mCaZ_icIBc,137
1
+ fastapi_radar/__init__.py,sha256=YE_bmBBb0G-NoaqVVMA5AkkUTrryxcpdqvvt7J2K7oI,137
2
2
  fastapi_radar/api.py,sha256=xZIVW4PBAIT0ix4s58NUfwYeCEZKeViXgk9tABGeSQg,10589
3
3
  fastapi_radar/capture.py,sha256=7ozPNBcogWeILIT1YsiTg5GyIGJvIr3o2rMVJEW-RGs,3289
4
4
  fastapi_radar/middleware.py,sha256=4Jo9nX0nxtT3e9JOIP5UE490uWvAI-a61nCS_8y77rs,4964
5
5
  fastapi_radar/models.py,sha256=H2esHsTo4RZEy9GJ0I49Ob5-AS85aeO0oMWau2QrWMw,2262
6
- fastapi_radar/radar.py,sha256=jtRUM49CK63KoHtUAlFeDbeBE0Kh_uQL2faBcFgryY4,10256
6
+ fastapi_radar/radar.py,sha256=UZuvLrzeBwz8TxbXLf57OVaX46N3WHfqY92XxfHMr4A,10374
7
7
  fastapi_radar/utils.py,sha256=WoL5tEH1pl6zOp0sXoPV_3UEOsIl29_xgzS0iapS10s,1515
8
8
  fastapi_radar/dashboard/dist/index.html,sha256=Q3fhImCwGAmqjZv0GYi81vJ4ELeUrOY2VS7O80UU6uU,436
9
9
  fastapi_radar/dashboard/dist/assets/index-CxIRSjZZ.js,sha256=jla8HJd6P3-vm1CYh7HLkgTys-HFOMILPH4DlFDcCxk,789553
10
10
  fastapi_radar/dashboard/dist/assets/index-DCxkDBhr.css,sha256=RLA1xEBZZaQDyJqE1rok9UTyavpMgYb4bcuRdjKhMHo,33691
11
- fastapi_radar-0.1.3.dist-info/licenses/LICENSE,sha256=0ga4BB6q-nqx6xlDRhtrgKrYs0HgX02PQyIzNFRK09Q,1067
11
+ fastapi_radar-0.1.5.dist-info/licenses/LICENSE,sha256=0ga4BB6q-nqx6xlDRhtrgKrYs0HgX02PQyIzNFRK09Q,1067
12
12
  tests/__init__.py,sha256=kAWaI50iJRZ4JlAdyt7FICgm8MsloZz0ZlsmhgLXBas,31
13
13
  tests/test_radar.py,sha256=qA9iUtk6zzcsjgoxJriQngFvhHUqXmVrPcULp58sI1o,1684
14
- fastapi_radar-0.1.3.dist-info/METADATA,sha256=XBsKXx18Q8Rml2kwwkAYbii5dnWgS9t6XWZPe0iKg7o,4813
15
- fastapi_radar-0.1.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
16
- fastapi_radar-0.1.3.dist-info/top_level.txt,sha256=M-bALM-KDkiLcATq2aAx-BnG59Nv-GdFBzuzkUhiCa0,20
17
- fastapi_radar-0.1.3.dist-info/RECORD,,
14
+ fastapi_radar-0.1.5.dist-info/METADATA,sha256=__ElmxMuvC9LaRntXhrSpgiJgo9WEC4gs7uRq3BICqw,5954
15
+ fastapi_radar-0.1.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
16
+ fastapi_radar-0.1.5.dist-info/top_level.txt,sha256=M-bALM-KDkiLcATq2aAx-BnG59Nv-GdFBzuzkUhiCa0,20
17
+ fastapi_radar-0.1.5.dist-info/RECORD,,