-
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
11 changed files
with
116 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
"""Sentry integration helpers.""" | ||
|
||
import random | ||
from collections.abc import Callable | ||
from typing import Any | ||
|
||
|
||
def make_traces_sampler( | ||
sample_rate: float, | ||
) -> Callable[[dict[str, Any]], float | bool]: | ||
"""Don't sample probes, sample other requests at the configured rate. | ||
Sentry can be configured either with ``traces_sample_rate`` or | ||
traces_sampler, but not both, so we have to re-implement the sampling rate | ||
logic. | ||
https://github.com/getsentry/sentry/issues/78457 | ||
""" | ||
|
||
def filter_transactions(context: dict[str, Any]) -> float | bool: | ||
try: | ||
headers = context["asgi_scope"]["headers"] | ||
user_agent = ( | ||
header[1] | ||
for header in headers | ||
if header[0].lower() == "user-agent" | ||
).__next__() | ||
if user_agent.startswith("kube-probe"): | ||
return False | ||
except (IndexError, StopIteration): | ||
pass | ||
|
||
return random.random() < float(sample_rate) | ||
|
||
return filter_transactions |
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 | ||
|