Skip to content

Commit aaa3340

Browse files
authored
tools: Add release & taskcluster infos in Sentry (#197)
1 parent 43af712 commit aaa3340

File tree

1 file changed

+14
-2
lines changed
  • tools/code_coverage_tools

1 file changed

+14
-2
lines changed

tools/code_coverage_tools/log.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,26 @@ def setup_sentry(name, channel, dsn):
5050
"""
5151

5252
# Detect environment
53-
if "TASK_ID" in os.environ:
53+
task_id = os.environ.get("TASK_ID")
54+
if task_id is not None:
5455
site = "taskcluster"
5556
elif "DYNO" in os.environ:
5657
site = "heroku"
5758
else:
5859
site = "unknown"
5960

60-
sentry_client = raven.Client(dsn=dsn, site=site, name=name, environment=channel)
61+
sentry_client = raven.Client(
62+
dsn=dsn,
63+
site=site,
64+
name=name,
65+
environment=channel,
66+
release=raven.fetch_package_version(f"code-coverage-{name}"),
67+
)
68+
69+
if task_id is not None:
70+
# Add a Taskcluster task id when available
71+
# It will be shown in the Additional Data section on the dashboard
72+
sentry_client.context.merge({"extra": {"task_id": task_id}})
6173

6274
sentry_handler = raven.handlers.logbook.SentryHandler(
6375
sentry_client, level=logbook.WARNING, bubble=True

0 commit comments

Comments
 (0)