Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/CD_production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ jobs:
script: auto
env_variables:
MODE: "production"
ENVIRONMENT: "production"
DB_DRIVER: "cloudsql"
CLOUD_SQL_INSTANCE_NAME: "${{ secrets.CLOUD_SQL_INSTANCE_NAME }}"
CLOUD_SQL_DATABASE: "${{ vars.CLOUD_SQL_DATABASE }}"
Expand All @@ -73,6 +74,7 @@ jobs:
AUTHENTIK_AUTHORIZE_URL: "${{ vars.AUTHENTIK_AUTHORIZE_URL }}"
AUTHENTIK_TOKEN_URL: "${{ vars.AUTHENTIK_TOKEN_URL }}"
SESSION_SECRET_KEY: "${{ secrets.SESSION_SECRET_KEY }}"
APITALLY_CLIENT_ID: "${{ secrets.APITALLY_CLIENT_ID }}"
EOF

- name: Deploy to Google Cloud
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/CD_staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ jobs:
script: auto
env_variables:
MODE: "production"
ENVIRONMENT: "staging"
DB_DRIVER: "cloudsql"
CLOUD_SQL_INSTANCE_NAME: "${{ secrets.CLOUD_SQL_INSTANCE_NAME }}"
CLOUD_SQL_DATABASE: "${{ vars.CLOUD_SQL_DATABASE }}"
Expand All @@ -74,6 +75,7 @@ jobs:
AUTHENTIK_AUTHORIZE_URL: "${{ vars.AUTHENTIK_AUTHORIZE_URL }}"
AUTHENTIK_TOKEN_URL: "${{ vars.AUTHENTIK_TOKEN_URL }}"
SESSION_SECRET_KEY: "${{ secrets.SESSION_SECRET_KEY }}"
APITALLY_CLIENT_ID: "${{ secrets.APITALLY_CLIENT_ID }}"
EOF

- name: Deploy to Google Cloud
Expand Down
56 changes: 38 additions & 18 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
import os

import sentry_sdk
from dotenv import load_dotenv

from core.initializers import register_routes

load_dotenv()

sentry_sdk.init(
dsn=os.environ.get("SENTRY_DSN"),
# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for performance monitoring.
traces_sample_rate=1.0,
# Set profiles_sample_rate to 1.0 to profile 100%
# of sampled transactions.
# We recommend adjusting this value in production.
profiles_sample_rate=1.0,
# Set profile_lifecycle to "trace" to automatically
# run the profiler on when there is an active transaction
profile_lifecycle="trace",
# Add data like request headers and IP for users,
# see https://docs.sentry.io/platforms/python/data-management/data-collected/ for more info
send_default_pii=True,
)
DSN = os.environ.get("SENTRY_DSN")

if DSN:
import sentry_sdk

sentry_sdk.init(
dsn=DSN,
# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for performance monitoring.
traces_sample_rate=1.0,
# Set profiles_sample_rate to 1.0 to profile 100%
# of sampled transactions.
# We recommend adjusting this value in production.
profiles_sample_rate=1.0,
# Set profile_lifecycle to "trace" to automatically
# run the profiler on when there is an active transaction
profile_lifecycle="trace",
# Add data like request headers and IP for users,
# see https://docs.sentry.io/platforms/python/data-management/data-collected/ for more info
send_default_pii=True,
)


from starlette.middleware.cors import CORSMiddleware
Expand Down Expand Up @@ -55,6 +58,23 @@
allow_headers=["*"],
)

APITALLY_CLIENT_ID = os.environ.get("APITALLY_CLIENT_ID")
if APITALLY_CLIENT_ID:
from apitally.fastapi import ApitallyMiddleware

app.add_middleware(
ApitallyMiddleware,
client_id=APITALLY_CLIENT_ID,
env=os.environ.get("ENVIRONMENT"), # "production" or "staging"
# Optionally enable and configure request logging
enable_request_logging=True,
log_request_headers=True,
log_request_body=True,
log_response_body=True,
capture_logs=True,
capture_traces=False, # requires instrumentation
)


if __name__ == "__main__":
import uvicorn
Expand Down
17 changes: 9 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ dependencies = [
"alembic==1.18.4",
"annotated-types==0.7.0",
"anyio==4.12.1",
"apitally[fastapi]==0.24.0",
"asgiref==3.11.1",
"asn1crypto==1.5.1",
"asyncpg==0.31.0",
"attrs==25.4.0",
"authlib>=1.6.0",
"authlib==1.6.7",
"bcrypt==4.3.0",
"cachetools==5.5.2",
"certifi==2025.8.3",
Expand All @@ -27,7 +28,7 @@ dependencies = [
"cloud-sql-python-connector==1.20.0",
"cryptography==45.0.6",
"dnspython==2.8.0",
"dotenv>=0.9.9",
"dotenv==0.9.9",
"email-validator==2.3.0",
"fastapi==0.124.2",
"fastapi-pagination==0.15.10",
Expand All @@ -48,7 +49,7 @@ dependencies = [
"idna==3.11",
"iniconfig==2.3.0",
"itsdangerous>=2.2.0",
"jinja2>=3.1.6",
"jinja2==3.1.6",
"mako==1.3.10",
"markupsafe==3.0.3",
"multidict==6.7.1",
Expand All @@ -75,15 +76,15 @@ dependencies = [
"pyproj==3.7.2",
"pyshp==2.3.1",
"pytest==8.4.1",
"pytest-cov>=6.2.1",
"pytest-cov==6.2.1",
"python-dateutil==2.9.0.post0",
"python-jose>=3.5.0",
"python-multipart==0.0.22",
"pytz==2025.2",
"requests==2.32.5",
"rsa==4.9.1",
"scramp==1.4.8",
"sentry-sdk[fastapi]>=2.35.0",
"sentry-sdk[fastapi]==2.35.0",
"shapely==2.1.2",
"six==1.17.0",
"sniffio==1.3.1",
Expand All @@ -92,13 +93,13 @@ dependencies = [
"sqlalchemy-searchable==2.1.0",
"sqlalchemy-utils==0.42.1",
"starlette==0.49.1",
"starlette-admin[i18n]>=0.16.0",
"typer>=0.21.1",
"starlette-admin[i18n]==0.16.0",
"typer==0.21.1",
"typing-extensions==4.15.0",
"typing-inspection==0.4.2",
"tzdata==2025.3",
"urllib3==2.6.3",
"utm>=0.8.1",
"utm==0.8.1",
"uvicorn==0.40.0",
"yarl==1.22.0",
]
Expand Down
Loading
Loading