Skip to content
Snippets Groups Projects
Verified Commit fa8a8402 authored by Marco Aceti's avatar Marco Aceti
Browse files

Add Sentry SDK integration

parent 80c8eb5b
No related branches found
No related tags found
No related merge requests found
Pipeline #2781 passed
......@@ -2,3 +2,4 @@ requests==2.28.2
python-dateutil==2.8.2
tqdm==4.65.0
geojson==3.0.1
sentry-sdk==1.18.0
......@@ -3,10 +3,12 @@ import logging
import os
import pathlib
import pickle
import subprocess
import sys
import typing as t
from datetime import date, datetime, timedelta
import sentry_sdk
from tqdm import tqdm
from src.const import TIMEZONE
......@@ -16,6 +18,17 @@ from src.scraper.train import Train
DATA_DIR = pathlib.Path("data/")
def get_git_revision_short_hash() -> str:
try:
return (
subprocess.check_output(["git", "rev-parse", "--short", "HEAD"])
.decode("ascii")
.strip()
)
except subprocess.CalledProcessError:
return "unknown"
def load_dataset(file_path: pathlib.Path) -> dict[t.Any, t.Any]:
try:
with open(file_path, "rb") as f:
......@@ -38,6 +51,15 @@ def main() -> None:
)
sys.exit(1)
sentry_dsn = os.getenv("SENTRY_DSN")
if sentry_dsn is not None:
sentry_sdk.init(
dsn=sentry_dsn,
release=get_git_revision_short_hash(),
traces_sample_rate=1.0,
)
logging.info("Activated sentry error reporting")
# Today + ~3 hours
today: date = (datetime.now(tz=TIMEZONE) - timedelta(hours=3)).date()
today_path: pathlib.Path = DATA_DIR / today.strftime("%Y-%m-%d")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment