fastapi-radar 0.1.7__tar.gz → 0.1.8__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.

Potentially problematic release.


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

Files changed (27) hide show
  1. {fastapi_radar-0.1.7/fastapi_radar.egg-info → fastapi_radar-0.1.8}/PKG-INFO +22 -1
  2. {fastapi_radar-0.1.7 → fastapi_radar-0.1.8}/README.md +21 -0
  3. {fastapi_radar-0.1.7 → fastapi_radar-0.1.8}/fastapi_radar/__init__.py +1 -1
  4. {fastapi_radar-0.1.7 → fastapi_radar-0.1.8}/fastapi_radar/middleware.py +18 -14
  5. {fastapi_radar-0.1.7 → fastapi_radar-0.1.8}/fastapi_radar/radar.py +30 -1
  6. {fastapi_radar-0.1.7 → fastapi_radar-0.1.8/fastapi_radar.egg-info}/PKG-INFO +22 -1
  7. {fastapi_radar-0.1.7 → fastapi_radar-0.1.8}/pyproject.toml +1 -1
  8. {fastapi_radar-0.1.7 → fastapi_radar-0.1.8}/setup.py +1 -1
  9. {fastapi_radar-0.1.7 → fastapi_radar-0.1.8}/CONTRIBUTING.md +0 -0
  10. {fastapi_radar-0.1.7 → fastapi_radar-0.1.8}/LICENSE +0 -0
  11. {fastapi_radar-0.1.7 → fastapi_radar-0.1.8}/MANIFEST.in +0 -0
  12. {fastapi_radar-0.1.7 → fastapi_radar-0.1.8}/fastapi_radar/api.py +0 -0
  13. {fastapi_radar-0.1.7 → fastapi_radar-0.1.8}/fastapi_radar/capture.py +0 -0
  14. {fastapi_radar-0.1.7 → fastapi_radar-0.1.8}/fastapi_radar/dashboard/dist/assets/index-By5DXl8Z.js +0 -0
  15. {fastapi_radar-0.1.7 → fastapi_radar-0.1.8}/fastapi_radar/dashboard/dist/assets/index-XlGcZj49.css +0 -0
  16. {fastapi_radar-0.1.7 → fastapi_radar-0.1.8}/fastapi_radar/dashboard/dist/index.html +0 -0
  17. {fastapi_radar-0.1.7 → fastapi_radar-0.1.8}/fastapi_radar/models.py +0 -0
  18. {fastapi_radar-0.1.7 → fastapi_radar-0.1.8}/fastapi_radar/tracing.py +0 -0
  19. {fastapi_radar-0.1.7 → fastapi_radar-0.1.8}/fastapi_radar/utils.py +0 -0
  20. {fastapi_radar-0.1.7 → fastapi_radar-0.1.8}/fastapi_radar.egg-info/SOURCES.txt +0 -0
  21. {fastapi_radar-0.1.7 → fastapi_radar-0.1.8}/fastapi_radar.egg-info/dependency_links.txt +0 -0
  22. {fastapi_radar-0.1.7 → fastapi_radar-0.1.8}/fastapi_radar.egg-info/not-zip-safe +0 -0
  23. {fastapi_radar-0.1.7 → fastapi_radar-0.1.8}/fastapi_radar.egg-info/requires.txt +0 -0
  24. {fastapi_radar-0.1.7 → fastapi_radar-0.1.8}/fastapi_radar.egg-info/top_level.txt +0 -0
  25. {fastapi_radar-0.1.7 → fastapi_radar-0.1.8}/setup.cfg +0 -0
  26. {fastapi_radar-0.1.7 → fastapi_radar-0.1.8}/tests/__init__.py +0 -0
  27. {fastapi_radar-0.1.7 → fastapi_radar-0.1.8}/tests/test_radar.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastapi-radar
3
- Version: 0.1.7
3
+ Version: 0.1.8
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
@@ -139,9 +139,30 @@ radar = Radar(
139
139
  capture_sql_bindings=True, # Capture SQL query parameters
140
140
  exclude_paths=["/health"], # Paths to exclude from monitoring
141
141
  theme="auto", # Dashboard theme: "light", "dark", or "auto"
142
+ db_path="/path/to/db", # Custom path for radar.duckdb file (default: current directory)
142
143
  )
143
144
  ```
144
145
 
146
+ ### Custom Database Location
147
+
148
+ 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:
149
+
150
+ ```python
151
+ # Store in a specific directory
152
+ radar = Radar(app, db_path="/var/data/monitoring")
153
+ # Creates: /var/data/monitoring/radar.duckdb
154
+
155
+ # Store with a specific filename
156
+ radar = Radar(app, db_path="/var/data/my_app_monitoring.duckdb")
157
+ # Creates: /var/data/my_app_monitoring.duckdb
158
+
159
+ # Use a relative path
160
+ radar = Radar(app, db_path="./data")
161
+ # Creates: ./data/radar.duckdb
162
+ ```
163
+
164
+ If the specified path cannot be created, FastAPI Radar will fallback to using the current directory with a warning.
165
+
145
166
  ## What Gets Captured?
146
167
 
147
168
  - ✅ HTTP requests and responses
@@ -94,9 +94,30 @@ radar = Radar(
94
94
  capture_sql_bindings=True, # Capture SQL query parameters
95
95
  exclude_paths=["/health"], # Paths to exclude from monitoring
96
96
  theme="auto", # Dashboard theme: "light", "dark", or "auto"
97
+ db_path="/path/to/db", # Custom path for radar.duckdb file (default: current directory)
97
98
  )
98
99
  ```
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
+
100
121
  ## What Gets Captured?
101
122
 
102
123
  - ✅ HTTP requests and responses
@@ -2,5 +2,5 @@
2
2
 
3
3
  from .radar import Radar
4
4
 
5
- __version__ = "0.1.7"
5
+ __version__ = "0.1.8"
6
6
  __all__ = ["Radar"]
@@ -109,24 +109,28 @@ class RadarMiddleware(BaseHTTPMiddleware):
109
109
  exception_occurred = False
110
110
 
111
111
  try:
112
- response = await call_next(request)
112
+ response = original_response = await call_next(request)
113
113
 
114
114
  captured_request.status_code = response.status_code
115
115
  captured_request.response_headers = serialize_headers(response.headers)
116
116
 
117
- if self.capture_response_body and not isinstance(
118
- response, StreamingResponse
119
- ):
120
- response_body = b""
121
- async for chunk in response.body_iterator:
122
- response_body += chunk
123
-
124
- captured_request.response_body = truncate_body(
125
- response_body.decode("utf-8", errors="ignore"), self.max_body_size
126
- )
127
-
128
- response = Response(
129
- content=response_body,
117
+ if self.capture_response_body:
118
+
119
+ async def capture_response():
120
+ response_body = ""
121
+ async for chunk in original_response.body_iterator:
122
+ yield chunk
123
+ if len(response_body) < self.max_body_size:
124
+ response_body += chunk.decode("utf-8", errors="ignore")
125
+ with self.get_session() as session:
126
+ captured_request.response_body = truncate_body(
127
+ response_body, self.max_body_size
128
+ )
129
+ session.add(captured_request)
130
+ session.commit()
131
+
132
+ response = StreamingResponse(
133
+ content=capture_response(),
130
134
  status_code=response.status_code,
131
135
  headers=dict(response.headers),
132
136
  media_type=response.media_type,
@@ -34,6 +34,7 @@ class Radar:
34
34
  enable_tracing: bool = True,
35
35
  service_name: str = "fastapi-app",
36
36
  include_in_schema: bool = True,
37
+ db_path: Optional[str] = None,
37
38
  ):
38
39
  self.app = app
39
40
  self.db_engine = db_engine
@@ -46,6 +47,7 @@ class Radar:
46
47
  self.theme = theme
47
48
  self.enable_tracing = enable_tracing
48
49
  self.service_name = service_name
50
+ self.db_path = db_path
49
51
  self.query_capture = None
50
52
 
51
53
  # Exclude radar dashboard paths
@@ -65,7 +67,34 @@ class Radar:
65
67
  # Import duckdb_engine to register the dialect
66
68
  import duckdb_engine # noqa: F401
67
69
 
68
- radar_db_path = Path.cwd() / "radar.duckdb"
70
+ if self.db_path:
71
+ try:
72
+ # Avoid shadowing the attribute name by using a different variable name
73
+ provided_path = Path(self.db_path).resolve()
74
+ if provided_path.suffix.lower() == ".duckdb":
75
+ radar_db_path = provided_path
76
+ radar_db_path.parent.mkdir(parents=True, exist_ok=True)
77
+ else:
78
+ radar_db_path = provided_path / "radar.duckdb"
79
+ provided_path.mkdir(parents=True, exist_ok=True)
80
+
81
+ except Exception as e:
82
+ # Fallback to current directory if path creation fails
83
+ import warnings
84
+
85
+ warnings.warn(
86
+ (
87
+ f"Failed to create database path '{self.db_path}': {e}. "
88
+ f"Using current directory."
89
+ ),
90
+ UserWarning,
91
+ )
92
+
93
+ radar_db_path = Path.cwd() / "radar.duckdb"
94
+ radar_db_path.parent.mkdir(parents=True, exist_ok=True)
95
+ else:
96
+ radar_db_path = Path.cwd() / "radar.duckdb"
97
+ radar_db_path.parent.mkdir(parents=True, exist_ok=True)
69
98
  self.storage_engine = create_engine(
70
99
  f"duckdb:///{radar_db_path}",
71
100
  connect_args={
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastapi-radar
3
- Version: 0.1.7
3
+ Version: 0.1.8
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
@@ -139,9 +139,30 @@ radar = Radar(
139
139
  capture_sql_bindings=True, # Capture SQL query parameters
140
140
  exclude_paths=["/health"], # Paths to exclude from monitoring
141
141
  theme="auto", # Dashboard theme: "light", "dark", or "auto"
142
+ db_path="/path/to/db", # Custom path for radar.duckdb file (default: current directory)
142
143
  )
143
144
  ```
144
145
 
146
+ ### Custom Database Location
147
+
148
+ 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:
149
+
150
+ ```python
151
+ # Store in a specific directory
152
+ radar = Radar(app, db_path="/var/data/monitoring")
153
+ # Creates: /var/data/monitoring/radar.duckdb
154
+
155
+ # Store with a specific filename
156
+ radar = Radar(app, db_path="/var/data/my_app_monitoring.duckdb")
157
+ # Creates: /var/data/my_app_monitoring.duckdb
158
+
159
+ # Use a relative path
160
+ radar = Radar(app, db_path="./data")
161
+ # Creates: ./data/radar.duckdb
162
+ ```
163
+
164
+ If the specified path cannot be created, FastAPI Radar will fallback to using the current directory with a warning.
165
+
145
166
  ## What Gets Captured?
146
167
 
147
168
  - ✅ HTTP requests and responses
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "fastapi-radar"
3
- version = "0.1.7"
3
+ version = "0.1.8"
4
4
  description = "A debugging dashboard for FastAPI applications with real-time monitoring"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.9"
@@ -9,7 +9,7 @@ long_description = (this_directory / "README.md").read_text(encoding="utf-8")
9
9
 
10
10
  setup(
11
11
  name="fastapi-radar",
12
- version="0.1.7",
12
+ version="0.1.8",
13
13
  author="Arif Dogan",
14
14
  author_email="me@arif.sh",
15
15
  description=(
File without changes
File without changes
File without changes