Skip to content

Commit 25712df

Browse files
authored
Migrate sampling_context to use SDK 3.0 attributes (#94022)
See the Celery and WSGI sections [in the migration guide](https://docs.sentry.io/platforms/python/migration/2.x-to-3.x#sampling) Closes getsentry/sentry-python#4505
1 parent 0522d95 commit 25712df

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/sentry/utils/sdk.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,8 @@ def get_project_key():
178178

179179

180180
def traces_sampler(sampling_context):
181-
wsgi_path = sampling_context.get("wsgi_environ", {}).get("PATH_INFO")
182-
if wsgi_path and wsgi_path in SAMPLED_ROUTES:
181+
wsgi_path = sampling_context.get("url.path")
182+
if wsgi_path in SAMPLED_ROUTES:
183183
return SAMPLED_ROUTES[wsgi_path]
184184

185185
# Apply sample_rate from custom_sampling_context
@@ -192,8 +192,7 @@ def traces_sampler(sampling_context):
192192
return sampling_context["parent_sampled"]
193193

194194
if "celery_job" in sampling_context:
195-
task_name = sampling_context["celery_job"].get("task")
196-
195+
task_name = sampling_context.get("celery.job.task")
197196
if task_name in SAMPLED_TASKS:
198197
return SAMPLED_TASKS[task_name]
199198

0 commit comments

Comments
 (0)