-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
jschaff
committed
Dec 2, 2024
1 parent
1d2a4bc
commit 8aa944a
Showing
4 changed files
with
67 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from typing import Dict, List | ||
|
||
from .sentry import initialize_sentry | ||
|
||
|
||
def build_listeners() -> List[Dict]: | ||
""" | ||
Basic method for aggregating all of listeners created | ||
for the annotator service | ||
""" | ||
sentry_listener = {"listener": initialize_sentry, "event": "before_server_start", "priority": 0} | ||
listener_collection = [sentry_listener] | ||
return listener_collection |
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,39 @@ | ||
""" | ||
Listener for configuring the sentry support for the | ||
sanic web-app associated with the annotator service | ||
""" | ||
|
||
import sanic | ||
|
||
import sentry_sdk | ||
from sentry_sdk.integrations.asyncio import AsyncioIntegration | ||
from sentry_sdk.integrations.sanic import SanicIntegration | ||
|
||
|
||
async def initialize_sentry(application_instance: sanic.Sanic) -> None: | ||
""" | ||
Listener for initializing our sentry logging | ||
Set the sample rate for transactions | ||
https://docs.sentry.io/platforms/python/configuration/options/#traces-sample-rate | ||
Set the profiles sample rate for transactions | ||
https://docs.sentry.io/platforms/python/profiling/ | ||
""" | ||
# https://docs.sentry.io/platforms/python/integrations/asyncio/ | ||
async_integration = AsyncioIntegration() | ||
|
||
# https://docs.sentry.io/platforms/python/integrations/sanic/ | ||
sanic_integration = SanicIntegration( | ||
# Configure the Sanic integration so that we generate | ||
# transactions for all HTTP status codes, including 404 | ||
unsampled_statuses=None, | ||
) | ||
sentry_configuration = application_instance.config.get("sentry", {}) | ||
sentry_key = sentry_configuration.get("SENTRY_CLIENT_KEY", "") | ||
sentry_sdk.init( | ||
dsn=sentry_key, | ||
traces_sample_rate=0.20, | ||
profiles_sample_rate=0.20, | ||
integrations=[async_integration, sanic_integration], | ||
) |