SciPost Code Repository
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SciPost
Manage
Activity
Members
Labels
Plan
Issues
118
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SciPost
SciPost
Commits
8d213976
Commit
8d213976
authored
1 year ago
by
George Katsikas
Browse files
Options
Downloads
Patches
Plain Diff
add trace samples for sentry performance metrics
parent
b1ea22e5
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scipost_django/SciPost_v1/settings/production_do1.py
+48
-0
48 additions, 0 deletions
scipost_django/SciPost_v1/settings/production_do1.py
with
48 additions
and
0 deletions
scipost_django/SciPost_v1/settings/production_do1.py
+
48
−
0
View file @
8d213976
import
re
import
sentry_sdk
from
sentry_sdk.integrations.django
import
DjangoIntegration
from
sentry_sdk.integrations.celery
import
CeleryIntegration
...
...
@@ -78,11 +79,58 @@ LOGGING["handlers"]["submission_fellowship_updates"][
# Mailgun credentials
MAILGUN_API_KEY
=
get_secret
(
"
MAILGUN_API_KEY
"
)
# Sentry trace sampling
def
traces_sampler
(
sampling_context
):
def
_matches_in
(
s
):
return
lambda
patterns
:
any
(
re
.
search
(
p
,
s
)
for
p
in
patterns
)
name
=
sampling_context
[
"
transaction_context
"
][
"
name
"
]
name_matches
=
_matches_in
(
name
)
# We get approx 20k a day, and we need to stay under 3k
# a 10% sample rate should be fine
BASE_RATE
=
0.1
INVALID
=
[
"
wp-login.php
"
,
"
xmlrpc.php
"
,
]
JUNK
=
[
"
/messages
"
,
"
/pdf
"
,
"
_hx_sponsors
"
,
"
/rss
"
,
]
VERY_COMMON
=
[
"
journal_tag
"
,
# Publications detail
"
/login
"
,
"
/contributor
"
,
]
COMMON
=
[
"
/personal_page
"
,
"
/submissions
"
,
]
if
name_matches
(
JUNK
+
INVALID
):
return
0.0
elif
name_matches
(
VERY_COMMON
):
return
BASE_RATE
*
0.05
elif
name_matches
(
COMMON
):
return
BASE_RATE
*
0.2
return
BASE_RATE
# Sentry
sentry_sdk
.
init
(
dsn
=
get_secret
(
"
SENTRY_DSN
"
),
integrations
=
[
DjangoIntegration
(),
CeleryIntegration
()],
enable_tracing
=
True
,
traces_sampler
=
traces_sampler
,
)
CSP_REPORT_URI
=
get_secret
(
"
CSP_SENTRY
"
)
CSP_REPORT_ONLY
=
False
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment