Skip to content

Commit

Permalink
Sample only 1% of api status calls (#1464)
Browse files Browse the repository at this point in the history
* Sample only 1% of api status calls

* check if path exist in request context
  • Loading branch information
bryantran04 authored Feb 18, 2023
1 parent 725e5db commit 09ede1a
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions server/api/code/lacity_data_api/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,21 @@

app = get_app()

sample_rate_for_api_calls = {
"/status/api": 0.01,
}


def traces_sampler(ctx):
if ctx.get("path") and ctx["path"] in sample_rate_for_api_calls:
return sample_rate_for_api_calls[ctx["path"]]
return 1.0 # Trace all


if SENTRY_URL:
sentry_sdk.init(
SENTRY_URL,
traces_sample_rate=1.0,
integrations=[SqlalchemyIntegration(), RedisIntegration()]
traces_sampler=traces_sampler,
integrations=[SqlalchemyIntegration(), RedisIntegration()],
)
app = SentryAsgiMiddleware(app)

0 comments on commit 09ede1a

Please sign in to comment.