Skip to content

Commit 1fb4958

Browse files
committed
add sentry
Signed-off-by: Bradley Reynolds <[email protected]>
1 parent 48fcdc1 commit 1fb4958

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

docs/source/changelog.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
Changelog
55
=========
66

7+
- :release:`1.2.0 <20th February 2023>`
8+
- :feature:`5` Add Sentry.io
9+
710
- :release:`1.1.0 <13th February 2023>`
811
- :feature:`2` Bump fastapi from 0.90.1 to 0.91.0
912

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[project]
22
name = "api.letsbuilda.dev"
33
description = "Public API for our projects"
4-
version = "1.1.0"
4+
version = "1.2.0"
55
authors = [
66
{ name = "Bradley Reynolds", email = "[email protected]" },
77
]
@@ -12,6 +12,7 @@ dependencies = [
1212
"fastapi==0.92.0",
1313
"uvicorn[standard]==0.20.0",
1414
"imsosorry==1.2.0",
15+
"sentry-sdk[fastapi]==1.15.0",
1516
]
1617

1718
[project.urls]

src/api/server.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
"""API server definition"""
22

3+
from os import getenv
4+
5+
import sentry_sdk
36
from fastapi import APIRouter, FastAPI
47
from imsosorry import uwuify
58

@@ -8,6 +11,19 @@
811

912
from . import __version__
1013

14+
release_prefix = getenv("API_SENTRY_RELEASE_PREFIX", "api")
15+
git_sha = getenv("GIT_SHA", "development")
16+
sentry_sdk.init(
17+
dsn=getenv("API_SENTRY_DSN"),
18+
environment=getenv("API_SENTRY_ENV"),
19+
send_default_pii=True,
20+
traces_sample_rate=1.0,
21+
_experiments={
22+
"profiles_sample_rate": 1.0,
23+
},
24+
release=f"{release_prefix}@{git_sha}",
25+
)
26+
1127

1228
class TextModel(BaseModel):
1329
"""Generic model for accepting arbitrary plain-text input"""

0 commit comments

Comments
 (0)