Skip to content

Commit 8b7ac20

Browse files
Integrate Sentry for error tracking and profiling (#2750)
1 parent 9704a63 commit 8b7ac20

File tree

3 files changed

+55
-5
lines changed

3 files changed

+55
-5
lines changed

bugbot/__init__.py

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,48 @@
33
# You can obtain one at http://mozilla.org/MPL/2.0/.
44

55
import logging
6+
import os
67
import sys
8+
from subprocess import check_output
9+
10+
import sentry_sdk
711

812
from . import config
913

14+
15+
def get_version():
16+
git_tags = (
17+
check_output(["git", "tag", "--sort=-version:refname"])
18+
.decode("utf-8")
19+
.splitlines()
20+
)
21+
return git_tags[0] if git_tags else None
22+
23+
24+
__version__ = get_version()
25+
26+
27+
sentry_sdk.init(
28+
dsn="https://[email protected]/4510268495101953",
29+
release=__version__,
30+
environment=os.getenv("ENVIRONMENT", "development"),
31+
dist=check_output(["git", "rev-parse", "HEAD"]).decode("utf-8").rstrip(),
32+
server_name=check_output("hostname").decode("utf-8").rstrip(),
33+
# Add data like request headers and IP for users,
34+
# see https://docs.sentry.io/platforms/python/data-management/data-collected/ for more info
35+
send_default_pii=True,
36+
# Enable sending logs to Sentry
37+
enable_logs=True,
38+
# Set traces_sample_rate to 1.0 to capture 100%
39+
# of transactions for tracing.
40+
traces_sample_rate=1.0,
41+
# Set profile_session_sample_rate to 1.0 to profile 100%
42+
# of profile sessions.
43+
profile_session_sample_rate=1.0,
44+
)
45+
46+
sentry_sdk.profiler.start_profiler()
47+
1048
config.load()
1149

1250
# We can remove this hack and load utils in the same line as config when we fix
@@ -17,10 +55,6 @@
1755
raise
1856

1957

20-
VERSION = (0, 0, 1)
21-
__version__ = ".".join(map(str, VERSION))
22-
23-
2458
path = utils.get_config("common", "log")
2559

2660
logger = logging.getLogger()

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ dependencies = [
2727
"PyYAML==6.0.2",
2828
"recurring-ical-events==3.8.0",
2929
"requests==2.32.5",
30+
"sentry-sdk>=2.42.1",
3031
"sqlalchemy==1.3.24",
3132
"tenacity==9.1.2",
32-
"whatthepatch>=0.0.5"
33+
"whatthepatch>=0.0.5",
3334
]
3435

3536
[project.optional-dependencies]

uv.lock

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)