Skip to content

armgit / mwmbl

Public Imported from GitHub
0

An open source, non-profit web search engine

Add Sentry

Daoud Clarkea5cb43e3fea5
diff --git a/mwmbl/settings_common.py b/mwmbl/settings_common.py
index 7cb7cde..5ea7030 100644
--- a/mwmbl/settings_common.py
+++ b/mwmbl/settings_common.py
@@ -12,6 +12,8 @@ https://docs.djangoproject.com/en/4.2/ref/settings/
import os
from pathlib import Path
+import sentry_sdk
+
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
@@ -189,3 +191,20 @@ CACHES = {
}
SETUP_DATABASE = True
+
+
+SENTRY_DSN = os.environ.get("SENTRY_DSN")
+
+if SENTRY_DSN is not None:
+ sentry_sdk.init(
+ dsn=SENTRY_DSN,
+ # Set traces_sample_rate to 1.0 to capture 100%
+ # of transactions for tracing.
+ 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,
+ )
+else:
+ print("No SENTRY_DSN set, skipping Sentry initialization")
diff --git a/mwmbl/urls.py b/mwmbl/urls.py
index e43cbde..42f28e1 100644
--- a/mwmbl/urls.py
+++ b/mwmbl/urls.py
@@ -24,6 +24,11 @@ from mwmbl.views import home_fragment, add_url, index, approve, revert_current_c
flag_curation, CurationFlagListView, flag_curation_update, domains_view, domain_view, CurationsView, submit_domain, \
DomainSubmissionListView, memory_view
+
+def trigger_error(request):
+ division_by_zero = 1 / 0
+
+
urlpatterns = [
path('admin/', admin.site.urls),
path('accounts/', include('allauth.urls')),
@@ -52,4 +57,6 @@ urlpatterns = [
path("api/v1/crawler/", crawler.create_router(batch_cache=batch_cache, queued_batches=queued_batches, version="1.0.0").urls),
path("debug/memory", memory_view, name="memory"),
+
+ path('sentry-debug/', trigger_error),
]
diff --git a/poetry.lock b/poetry.lock
index 06c979d..ab0eade 100644
--- a/poetry.lock
+++ b/poetry.lock
@@ -2340,6 +2340,57 @@ dev = ["cython-lint (>=0.12.2)", "doit (>=0.36.0)", "mypy", "pycodestyle", "pyde
doc = ["jupyterlite-pyodide-kernel", "jupyterlite-sphinx (>=0.12.0)", "jupytext", "matplotlib (>=3.5)", "myst-nb", "numpydoc", "pooch", "pydata-sphinx-theme (>=0.15.2)", "sphinx (>=5.0.0)", "sphinx-design (>=0.4.0)"]
test = ["array-api-strict", "asv", "gmpy2", "hypothesis (>=6.30)", "mpmath", "pooch", "pytest", "pytest-cov", "pytest-timeout", "pytest-xdist", "scikit-umfpack", "threadpoolctl"]
+[[package]]
+name = "sentry-sdk"
+version = "2.13.0"
+description = "Python client for Sentry (https://sentry.io)"
+optional = false
+python-versions = ">=3.6"
+files = [
+ {file = "sentry_sdk-2.13.0-py2.py3-none-any.whl", hash = "sha256:6beede8fc2ab4043da7f69d95534e320944690680dd9a963178a49de71d726c6"},
+ {file = "sentry_sdk-2.13.0.tar.gz", hash = "sha256:8d4a576f7a98eb2fdb40e13106e41f330e5c79d72a68be1316e7852cf4995260"},
+]
+
+[package.dependencies]
+certifi = "*"
+urllib3 = ">=1.26.11"
+
+[package.extras]
+aiohttp = ["aiohttp (>=3.5)"]
+anthropic = ["anthropic (>=0.16)"]
+arq = ["arq (>=0.23)"]
+asyncpg = ["asyncpg (>=0.23)"]
+beam = ["apache-beam (>=2.12)"]
+bottle = ["bottle (>=0.12.13)"]
+celery = ["celery (>=3)"]
+celery-redbeat = ["celery-redbeat (>=2)"]
+chalice = ["chalice (>=1.16.0)"]
+clickhouse-driver = ["clickhouse-driver (>=0.2.0)"]
+django = ["django (>=1.8)"]
+falcon = ["falcon (>=1.4)"]
+fastapi = ["fastapi (>=0.79.0)"]
+flask = ["blinker (>=1.1)", "flask (>=0.11)", "markupsafe"]
+grpcio = ["grpcio (>=1.21.1)", "protobuf (>=3.8.0)"]
+httpx = ["httpx (>=0.16.0)"]
+huey = ["huey (>=2)"]
+huggingface-hub = ["huggingface-hub (>=0.22)"]
+langchain = ["langchain (>=0.0.210)"]
+litestar = ["litestar (>=2.0.0)"]
+loguru = ["loguru (>=0.5)"]
+openai = ["openai (>=1.0.0)", "tiktoken (>=0.3.0)"]
+opentelemetry = ["opentelemetry-distro (>=0.35b0)"]
+opentelemetry-experimental = ["opentelemetry-distro"]
+pure-eval = ["asttokens", "executing", "pure-eval"]
+pymongo = ["pymongo (>=3.1)"]
+pyspark = ["pyspark (>=2.4.4)"]
+quart = ["blinker (>=1.1)", "quart (>=0.16.1)"]
+rq = ["rq (>=0.6)"]
+sanic = ["sanic (>=0.8)"]
+sqlalchemy = ["sqlalchemy (>=1.2)"]
+starlette = ["starlette (>=0.19.1)"]
+starlite = ["starlite (>=1.48)"]
+tornado = ["tornado (>=6)"]
+
[[package]]
name = "setuptools"
version = "71.1.0"
@@ -2996,4 +3047,4 @@ indexer = ["Levenshtein", "beautifulsoup4", "idna", "langdetect", "pyarrow", "py
[metadata]
lock-version = "2.0"
python-versions = ">=3.10,<3.11"
-content-hash = "5e727460fd3c6e62a73ab5c878da7c25e9d3ffdf9ad217861c8c312bf9b8a548"
+content-hash = "de3cdafe7282c244e4670384daeb3315d13b9c374406a5d86ff8fada53bf75bf"
diff --git a/pyproject.toml b/pyproject.toml
index db56979..8b7f7cb 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -47,6 +47,7 @@ objgraph = "^3.6.1"
psutil = "^6.0.0"
xgboost = "^2.1.0"
pydistinct = "^0.6.4"
+sentry-sdk = "^2.13.0"
[tool.poetry.extras]
indexer = [