Skip to content

Commit

Permalink
Merge pull request #1172 from python-discord/update-sentry-config
Browse files Browse the repository at this point in the history
Enable tracing and include source for slow queries
  • Loading branch information
jchristgit committed Dec 12, 2023
2 parents 6ec6fff + ab17a7a commit efd5858
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
19 changes: 8 additions & 11 deletions pydis_site/apps/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,30 +261,27 @@ class GitHubWebhookFilterView(APIView):
def post(self, request: Request, *, webhook_id: str, webhook_token: str) -> Response:
"""Filter a webhook POST from GitHub before sending it to Discord."""
sender = request.data.get('sender', {})
sender_name = sender.get('login', '')
event = request.headers.get('X-GitHub-Event')
sender_name = sender.get('login', '').lower()
event = request.headers.get('X-GitHub-Event', '').lower()
repository = request.data.get('repository', {})

is_coveralls = 'coveralls' in sender_name
is_github_bot = sender.get('type') == 'bot'
is_github_bot = sender.get('type', '').lower() == 'bot'
is_sentry = 'sentry-io' in sender_name
is_dependabot_branch_deletion = (
'dependabot' in request.data.get('ref', '')
'dependabot' in request.data.get('ref', '').lower()
and event == 'delete'
)
is_bot_pr_approval = (
'[bot]' in request.data.get('pull_request', {}).get('user', {}).get('login', '')
and event == 'pull_request_review'
)
is_bot_pr_approval = is_github_bot and event == 'pull_request_review'
is_empty_review = (
request.data.get('review', {}).get('state') == 'commented'
request.data.get('review', {}).get('state', '').lower() == 'commented'
and event == 'pull_request_review'
and request.data.get('review', {}).get('body') is None
)
is_black_non_main_push = (
request.data.get('ref') != 'refs/heads/main'
and repository.get('name') == 'black'
and repository.get('owner', {}).get('login') == 'psf'
and repository.get('name', '').lower() == 'black'
and repository.get('owner', {}).get('login', '').lower() == 'psf'
and event == 'push'
)

Expand Down
5 changes: 4 additions & 1 deletion pydis_site/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@
integrations=[DjangoIntegration(), LoggingIntegration(level=logging.DEBUG, event_level=logging.ERROR)],
send_default_pii=True,
release=f"site@{GIT_SHA}",
profiles_sample_rate=0.5,
profiles_sample_rate=1.0,
enable_tracing=True,
enable_db_query_source=True,
db_query_source_threshold_ms=100, # Queries slower that 100ms will include the source in the event
)

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
Expand Down

0 comments on commit efd5858

Please sign in to comment.