Skip to content

Commit

Permalink
Configure sentry
Browse files Browse the repository at this point in the history
  • Loading branch information
Zaczero committed Feb 14, 2024
1 parent 61b6bb9 commit 5ac3490
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 4 deletions.
4 changes: 3 additions & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
from pyproj import Transformer

NAME = 'openaedmap-backend'
VERSION = '2.6.1'
VERSION = '2.6.2'
CREATED_BY = f'{NAME} {VERSION}'
WEBSITE = 'https://openaedmap.org'

ENVIRONMENT = os.getenv('ENVIRONMENT', None)
USER_AGENT = f'{NAME}/{VERSION} (+{WEBSITE})'

OVERPASS_API_URL = 'https://overpass-api.de/api/interpreter'
Expand Down
1 change: 0 additions & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,5 @@ with pkgs; dockerTools.buildLayeredImage {
"/app/data/photos" = { };
};
Entrypoint = [ "python" "-m" "uvicorn" "main:app" ];
Cmd = [ "--host" "0.0.0.0" ];
};
}
1 change: 1 addition & 0 deletions envs/app/dev.env
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
ENVIRONMENT=dev
OPENSTREETMAP_API_URL=https://master.apis.dev.openstreetmap.org/api/0.6/
1 change: 1 addition & 0 deletions envs/app/main.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ENVIRONMENT=main
10 changes: 9 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
from datetime import timedelta

import anyio
import sentry_sdk
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from starlette.middleware.base import BaseHTTPMiddleware

import api.v1.api as api
from config import DEFAULT_CACHE_MAX_AGE, DEFAULT_CACHE_STALE, startup_setup
from config import DEFAULT_CACHE_MAX_AGE, DEFAULT_CACHE_STALE, ENVIRONMENT, VERSION, startup_setup
from middlewares.cache_middleware import CacheMiddleware
from middlewares.profiler_middleware import profiler_middleware
from middlewares.version_middleware import version_middleware
Expand All @@ -16,6 +17,13 @@
from states.country_state import get_country_state
from states.worker_state import WorkerStateEnum, get_worker_state

if ENVIRONMENT:
sentry_sdk.init(
dsn='https://[email protected]/3',
release=VERSION,
environment=ENVIRONMENT,
)


@asynccontextmanager
async def lifespan(_):
Expand Down
65 changes: 64 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ python-magic = "^0.4.27"
python-multipart = "<1"
pytz = "*"
scikit-learn = "^1.3.2"
sentry-sdk = {extras = ["fastapi"], version = "^1.40.4"}
setuptools = "^69.0.3"
shapely = "^2.0.2"
tqdm = "^4.66.1"
Expand Down

0 comments on commit 5ac3490

Please sign in to comment.