Skip to content

Commit

Permalink
feat: add sentry integration
Browse files Browse the repository at this point in the history
  • Loading branch information
JiaWeiXie committed Oct 12, 2023
1 parent 0357ae6 commit 7d1e7ce
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 2 deletions.
76 changes: 75 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Expand Up @@ -15,6 +15,7 @@ strawberry-graphql = {extras = ["channels"], version = "^0.209.6"}
daphne = "^4.0.0"
django-debug-toolbar = "^4.2.0"
graphql-sync-dataloaders = "^0.1.1"
sentry-sdk = {extras = ["django"], version = "^1.32.0"}


[tool.poetry.group.dev.dependencies]
Expand Down
1 change: 1 addition & 0 deletions server/app/blog/graph/queries.py
Expand Up @@ -18,3 +18,4 @@ class Query:
tags: list[blog_types.Tag] = strawberry_django.field()
categories: list[blog_types.Category] = strawberry_django.field()
comments: list[blog_types.Comment] = strawberry_django.field()
test_error: float = strawberry.field(resolver=lambda: 1 / 0)
25 changes: 24 additions & 1 deletion server/settings.py
Expand Up @@ -9,9 +9,13 @@
For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.2/ref/settings/
"""

import os
from pathlib import Path

import sentry_sdk
from sentry_sdk.integrations.django import DjangoIntegration
from sentry_sdk.integrations.strawberry import StrawberryIntegration

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent

Expand Down Expand Up @@ -146,3 +150,22 @@
"127.0.0.1",
"localhost",
]

sentry_sdk.init(
dsn=os.environ.get("SENTRY_DSN"),
# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for performance monitoring.
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,
integrations=[
# Set async_execution to True if you have at least one async resolver
StrawberryIntegration(async_execution=False),
DjangoIntegration(
transaction_style="url",
),
],
send_default_pii=True,
)

0 comments on commit 7d1e7ce

Please sign in to comment.