Skip to content

Commit

Permalink
feat: use sentry.io (#386)
Browse files Browse the repository at this point in the history
* sentry

* check for main branch

* Update openadapt/config.py

* Update openadapt/config.py

* ERROR_REPORTING_ENABLED

* Update config.py

* update poetry.lock

* Update openadapt/config.py

---------

Co-authored-by: Richard Abrich <[email protected]>
  • Loading branch information
0dm and abrichr authored Aug 29, 2023
1 parent a75ca9a commit 90bfe8f
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 5 deletions.
18 changes: 18 additions & 0 deletions openadapt/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,20 @@

from dotenv import load_dotenv
from loguru import logger
import git
import sentry_sdk

_DEFAULTS = {
"CACHE_DIR_PATH": ".cache",
"CACHE_ENABLED": True,
"CACHE_VERBOSITY": 0,
"DB_ECHO": False,
"DB_FNAME": "openadapt.db",
"ERROR_REPORTING_ENABLED": True,
"ERROR_REPORTING_DSN": (
"https://[email protected]/3798"
),
"ERROR_REPORTING_BRANCH": "main",
"OPENAI_API_KEY": "<set your api key in .env>",
# "OPENAI_MODEL_NAME": "gpt-4",
"OPENAI_MODEL_NAME": "gpt-3.5-turbo",
Expand Down Expand Up @@ -220,3 +227,14 @@ def obfuscate(val: str, pct_reveal: float = 0.1, char: str = "*") -> str:
):
val = obfuscate(val)
logger.info(f"{key}={val}")

if ERROR_REPORTING_ENABLED: # type: ignore # noqa
active_branch_name = git.Repo(ROOT_DIRPATH).active_branch.name
logger.info(f"{active_branch_name=}")
is_reporting_branch = active_branch_name == ERROR_REPORTING_BRANCH # type: ignore # noqa
logger.info(f"{is_reporting_branch=}")
if is_reporting_branch:
sentry_sdk.init(
dsn=ERROR_REPORTING_DSN, # type: ignore # noqa
traces_sample_rate=1.0,
)
Loading

0 comments on commit 90bfe8f

Please sign in to comment.