feat(sentry): remove health endpoint (#2257)

This pull request removes the healthz endpoint from the Sentry
integration. The `before_send` function has been updated to drop
transaction events that contain 'healthz' in the transaction name. This
change ensures that healthz transactions are not sent to Sentry.
This commit is contained in:
Stan Girard 2024-02-23 19:32:32 -08:00 committed by GitHub
parent 29da8c70b0
commit 166b823d25
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -38,6 +38,17 @@ if os.getenv("DEV_MODE") == "true":
debugpy.listen(("0.0.0.0", 5678))
def before_send(event, hint):
# If this is a transaction event
if event["type"] == "transaction":
# And the transaction name contains 'healthz'
if "healthz" in event["transaction"]:
# Drop the event by returning None
return None
# For other events, return them as is
return event
sentry_dsn = os.getenv("SENTRY_DSN")
if sentry_dsn:
sentry_sdk.init(
@ -46,9 +57,10 @@ if sentry_dsn:
enable_tracing=True,
traces_sample_rate=0.1,
integrations=[
StarletteIntegration(transaction_style="endpoint"),
FastApiIntegration(transaction_style="endpoint"),
StarletteIntegration(transaction_style="url"),
FastApiIntegration(transaction_style="url"),
],
before_send=before_send,
)
app = FastAPI()