fastapi-radar 0.1.4__py3-none-any.whl → 0.1.6__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.
@@ -4,7 +4,7 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>FastAPI Radar - Debugging Dashboard</title>
7
- <script type="module" crossorigin src="/__radar/assets/index-CxIRSjZZ.js"></script>
7
+ <script type="module" crossorigin src="/__radar/assets/index-BJa0l2JD.js"></script>
8
8
  <link rel="stylesheet" crossorigin href="/__radar/assets/index-DCxkDBhr.css">
9
9
  </head>
10
10
  <body>
fastapi_radar/radar.py CHANGED
@@ -15,10 +15,12 @@ from .api import create_api_router
15
15
 
16
16
 
17
17
  class Radar:
18
+ query_capture: Optional[QueryCapture]
19
+
18
20
  def __init__(
19
21
  self,
20
22
  app: FastAPI,
21
- db_engine: Engine,
23
+ db_engine: Optional[Engine] = None,
22
24
  storage_engine: Optional[Engine] = None,
23
25
  dashboard_path: str = "/__radar",
24
26
  max_requests: int = 1000,
@@ -37,6 +39,7 @@ class Radar:
37
39
  self.capture_sql_bindings = capture_sql_bindings
38
40
  self.exclude_paths = exclude_paths or []
39
41
  self.theme = theme
42
+ self.query_capture = None # Initialize to None
40
43
 
41
44
  # Add all radar paths to excluded paths - exclude everything under /__radar
42
45
  if dashboard_path not in self.exclude_paths:
@@ -61,7 +64,11 @@ class Radar:
61
64
 
62
65
  # Initialize components
63
66
  self._setup_middleware()
64
- self._setup_query_capture()
67
+
68
+ # Only setup query capture if db_engine is provided
69
+ if self.db_engine:
70
+ self._setup_query_capture()
71
+
65
72
  self._setup_api()
66
73
  self._setup_dashboard()
67
74
 
@@ -86,6 +93,10 @@ class Radar:
86
93
 
87
94
  def _setup_query_capture(self) -> None:
88
95
  """Setup SQLAlchemy query capture."""
96
+ assert (
97
+ self.db_engine is not None
98
+ ), "db_engine must be set before calling _setup_query_capture"
99
+
89
100
  self.query_capture = QueryCapture(
90
101
  get_session=self.get_session,
91
102
  capture_bindings=self.capture_sql_bindings,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastapi-radar
3
- Version: 0.1.4
3
+ Version: 0.1.6
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
@@ -75,6 +75,8 @@ pipenv install fastapi-radar
75
75
 
76
76
  ## Quick Start
77
77
 
78
+ ### With SQL Database (Full Monitoring)
79
+
78
80
  ```python
79
81
  from fastapi import FastAPI
80
82
  from fastapi_radar import Radar
@@ -83,7 +85,7 @@ from sqlalchemy import create_engine
83
85
  app = FastAPI()
84
86
  engine = create_engine("sqlite:///./app.db")
85
87
 
86
- # That's it! One line to add complete monitoring
88
+ # Full monitoring with SQL query tracking
87
89
  radar = Radar(app, db_engine=engine)
88
90
  radar.create_tables()
89
91
 
@@ -93,30 +95,62 @@ async def get_users():
93
95
  return {"users": []}
94
96
  ```
95
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
+
96
117
  Access your dashboard at: **http://localhost:8000/\_\_radar/**
97
118
 
98
119
  ## Features
99
120
 
100
- - **Zero Configuration** - Works with any FastAPI + SQLAlchemy app
121
+ - **Zero Configuration** - Works with any FastAPI app (SQL database optional)
101
122
  - **Request Monitoring** - Complete HTTP request/response capture with timing
102
- - **Database Monitoring** - SQL query logging with execution times
123
+ - **Database Monitoring** - SQL query logging with execution times (when using SQLAlchemy)
103
124
  - **Exception Tracking** - Automatic exception capture with stack traces
104
125
  - **Real-time Updates** - Live dashboard updates as requests happen
126
+ - **Flexible Integration** - Use with SQL, NoSQL, or no database at all
105
127
 
106
128
  ## Configuration
107
129
 
108
130
  ```python
109
131
  radar = Radar(
110
132
  app,
111
- db_engine=engine,
112
- dashboard_path="/__radar", # Custom dashboard path
113
- enable_in_production=False, # Disable in production
114
- capture_body=True, # Capture request/response bodies
115
- capture_headers=True, # Capture headers
116
- 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"
117
141
  )
118
142
  ```
119
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
+
120
154
  ## Contributing
121
155
 
122
156
  We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
@@ -148,10 +182,14 @@ npm run dev # For development with hot reload
148
182
  npm run build # To rebuild the production bundle
149
183
  ```
150
184
 
151
- 4. Run the example app:
185
+ 4. Run the example apps:
152
186
 
153
187
  ```bash
188
+ # Example with SQL database
154
189
  python example_app.py
190
+
191
+ # Example without SQL database (NoSQL/in-memory)
192
+ python example_nosql_app.py
155
193
  ```
156
194
 
157
195
  ## License
@@ -0,0 +1,17 @@
1
+ fastapi_radar/__init__.py,sha256=SDlgxlRiF2H4tJXJR2lojX5ev-Z-uPeQoA_LgXAoOnc,137
2
+ fastapi_radar/api.py,sha256=B5FsIzwJ6hSfgI4DG08KMSNXsgDMqJ6x2Tq4_k0DbVs,10594
3
+ fastapi_radar/capture.py,sha256=7ozPNBcogWeILIT1YsiTg5GyIGJvIr3o2rMVJEW-RGs,3289
4
+ fastapi_radar/middleware.py,sha256=4Jo9nX0nxtT3e9JOIP5UE490uWvAI-a61nCS_8y77rs,4964
5
+ fastapi_radar/models.py,sha256=H2esHsTo4RZEy9GJ0I49Ob5-AS85aeO0oMWau2QrWMw,2262
6
+ fastapi_radar/radar.py,sha256=ScNC_VuXP_j6d3a1KkTSLGjsUiSTfXXj-EL_bnJnKYg,10545
7
+ fastapi_radar/utils.py,sha256=WoL5tEH1pl6zOp0sXoPV_3UEOsIl29_xgzS0iapS10s,1515
8
+ fastapi_radar/dashboard/dist/index.html,sha256=mWeUgXklmZG3Dge6ugGi3JxBHDFjlyP5NjkTsMpuUko,436
9
+ fastapi_radar/dashboard/dist/assets/index-BJa0l2JD.js,sha256=G-dZ8delFyCE9I2TOjR36ql261ekTtlmOb0yQtSNjr4,806905
10
+ fastapi_radar/dashboard/dist/assets/index-DCxkDBhr.css,sha256=RLA1xEBZZaQDyJqE1rok9UTyavpMgYb4bcuRdjKhMHo,33691
11
+ fastapi_radar-0.1.6.dist-info/licenses/LICENSE,sha256=0ga4BB6q-nqx6xlDRhtrgKrYs0HgX02PQyIzNFRK09Q,1067
12
+ tests/__init__.py,sha256=kAWaI50iJRZ4JlAdyt7FICgm8MsloZz0ZlsmhgLXBas,31
13
+ tests/test_radar.py,sha256=qA9iUtk6zzcsjgoxJriQngFvhHUqXmVrPcULp58sI1o,1684
14
+ fastapi_radar-0.1.6.dist-info/METADATA,sha256=flff7NtCLzQfXQPO-a2bmH9HzH0Va5pOtDj1C8YzHd4,5954
15
+ fastapi_radar-0.1.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
16
+ fastapi_radar-0.1.6.dist-info/top_level.txt,sha256=M-bALM-KDkiLcATq2aAx-BnG59Nv-GdFBzuzkUhiCa0,20
17
+ fastapi_radar-0.1.6.dist-info/RECORD,,