File tree Expand file tree Collapse file tree 3 files changed +28
-1
lines changed
Expand file tree Collapse file tree 3 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -89,6 +89,16 @@ and how we can make improvements in the future.
8989Note that any latitudes and longitudes are rounded to 2 decimals places in order to anonymize the data.
9090If you would like to disable this logging, you can do so by setting the environment variable ` QUARTZ_SOLAR_FORECAST_LOGGING ` to ` False ` .
9191
92+ ### API Monitoring (APITally)
93+
94+ The FastAPI application supports optional monitoring via APITally.
95+
96+ To enable API request monitoring, set the following environment variables before starting the API:
97+
98+ ``` bash
99+ export APITALLY_CLIENT_ID=your_client_id
100+ export APITALLY_ENVIRONMENT=open_quartz_local
101+ ```
92102
93103## Model
94104
Original file line number Diff line number Diff line change 55from importlib .metadata import version
66
77import pandas as pd
8+ from apitally .fastapi import ApitallyMiddleware
89from fastapi import FastAPI
910from fastapi .middleware .cors import CORSMiddleware
1011from pydantic import BaseModel , Field
9596
9697app = FastAPI (description = description , version = __version__ , title = "Open Quartz Solar Forecast API" )
9798
99+ client_id = os .getenv ("APITALLY_CLIENT_ID" )
100+
101+ if client_id :
102+ app .add_middleware (
103+ ApitallyMiddleware ,
104+ client_id = client_id ,
105+ environment = os .getenv ("APITALLY_ENVIRONMENT" , "open_quartz_local" ),
106+ enable_request_logging = True ,
107+ log_request_headers = True ,
108+ log_request_body = True ,
109+ log_response_body = True ,
110+ capture_logs = True ,
111+ )
98112# CORS middleware setup
99113origins = [
100114 "*" ,
Original file line number Diff line number Diff line change @@ -27,7 +27,8 @@ dependencies = [
2727 " pydantic_settings" ,
2828 " httpx" ,
2929 " sentry_sdk" ,
30- " huggingface_hub==0.17.3"
30+ " huggingface_hub==0.17.3" ,
31+ " apitally[fastapi]>=0.22.3"
3132]
3233
3334[project .urls ]
@@ -51,6 +52,7 @@ dev = [
5152 " matplotlib" ,
5253 " zipfile36" ,
5354 " pytest" ,
55+ " huggingface_hub==0.17.3"
5456]
5557inverters = [" ocf_vrmapi" ] # victron
5658all = [
@@ -60,6 +62,7 @@ all = [
6062 " gdown==5.1.0" ,
6163 " fastapi" ,
6264 " pytest" ,
65+ " huggingface_hub==0.17.3"
6366]
6467
6568[tool .mypy ]
You can’t perform that action at this time.
0 commit comments