-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DM-48476: Sentry - the most basic integration possible
Let's use Sentry in the most basic possible way and see what happens.
- Loading branch information
Showing
13 changed files
with
129 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,4 +27,5 @@ markdown-it-py[linkify,plugins] | |
mdformat | ||
mdformat-gfm | ||
PyYAML | ||
sentry-sdk | ||
sse-starlette |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
"""Sentry integration helpers.""" | ||
|
||
import re | ||
from collections.abc import Callable | ||
from typing import Any | ||
|
||
__all__ = ["make_traces_sampler"] | ||
|
||
EVENTS_REGEX = re.compile("/pages/.*/events$") | ||
|
||
|
||
def make_traces_sampler( | ||
original_rate: float, | ||
) -> Callable[[dict[str, Any]], float]: | ||
"""Don't instrument events SSE endpoint to avoid leaking memory. | ||
Sample every other trace at the configured rate. | ||
When an SSE endpoint is instrumented, Sentry accumlates spans for every | ||
sent event in memory until the initial connection is closed. Without Sentry | ||
tracing instrumentation, SSE endpoints don't leak memory. | ||
""" | ||
|
||
def traces_sampler(context: dict[str, Any]) -> float: | ||
try: | ||
path = context["asgi_scope"]["path"] | ||
if EVENTS_REGEX.search(path): | ||
return 0 | ||
except IndexError: | ||
pass | ||
return original_rate | ||
|
||
return traces_sampler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,7 @@ setenv = | |
SAFIR_PROFILE = development | ||
TS_ALEMBIC_CONFIG_PATH = {toxinidir}/alembic.ini | ||
TS_ENVIRONMENT_URL = https://test.example.com | ||
TS_ENVIRONMENT_NAME = testing | ||
TS_DATABASE_URL = postgresql://timessquare@localhost:5433/timessquare | ||
TS_DATABASE_PASSWORD = INSECURE-PASSWORD | ||
TS_REDIS_URL = redis://localhost:6379/0 | ||
|
@@ -86,6 +87,7 @@ commands = pre-commit run --all-files | |
description = Run Alembic against a test database | ||
setenv = | ||
TS_ENVIRONMENT_URL = https://test.example.com | ||
TS_ENVIRONMENT_NAME = testing | ||
TS_PATH_PREFIX = /times-square/api | ||
TS_ALEMBIC_CONFIG_PATH = {toxinidir}/alembic.ini | ||
TS_DATABASE_URL = postgresql://[email protected]:5432/timessquare | ||
|
@@ -107,6 +109,7 @@ commands = | |
times-square {posargs} | ||
setenv = | ||
TS_ENVIRONMENT_URL = https://test.example.com | ||
TS_ENVIRONMENT_NAME = testing | ||
TS_PATH_PREFIX = /times-square/api | ||
TS_ALEMBIC_CONFIG_PATH = {toxinidir}/alembic.ini | ||
TS_DATABASE_URL = postgresql://[email protected]:5432/timessquare | ||
|
@@ -126,6 +129,7 @@ whitelist_externals = | |
setenv = | ||
SAFIR_PROFILE = development | ||
TS_ENVIRONMENT_URL = https://test.example.com | ||
TS_ENVIRONMENT_NAME = testing | ||
TS_PATH_PREFIX = /times-square/api | ||
TS_ALEMBIC_CONFIG_PATH = {toxinidir}/alembic.ini | ||
TS_DATABASE_URL = postgresql://[email protected]:5432/timessquare | ||
|
@@ -148,6 +152,7 @@ commands_pre = | |
description = Build documentation (HTML) with Sphinx. | ||
setenv = | ||
TS_ENVIRONMENT_URL = https://test.example.com | ||
TS_ENVIRONMENT_NAME = testing | ||
TS_DATABASE_URL = postgresql://timessquare@localhost:5433/timessquare | ||
TS_DATABASE_PASSWORD = INSECURE-PASSWORD | ||
TS_GAFAELFAWR_TOKEN = gt-eOfLolxU8FJ1xr08U7RTbg.Jr-KHSeISXwR5GXHiLemhw | ||
|
@@ -165,6 +170,7 @@ commands = | |
description = Check links in documentation. | ||
setenv = | ||
TS_ENVIRONMENT_URL = https://test.example.com | ||
TS_ENVIRONMENT_NAME = testing | ||
TS_DATABASE_URL = postgresql://timessquare@localhost:5433/timessquare | ||
TS_DATABASE_PASSWORD = INSECURE-PASSWORD | ||
TS_GAFAELFAWR_TOKEN = gt-eOfLolxU8FJ1xr08U7RTbg.Jr-KHSeISXwR5GXHiLemhw | ||
|