sentry: More gracefully handle a value of 0.

If the value at runtime is actually an int, not a float, we should not
try to treat it as a dict.
This commit is contained in:
Alex Vandiver 2024-05-23 20:00:37 +00:00 committed by Tim Abbott
parent 959c78e1e1
commit 5f3d6ac983
1 changed files with 3 additions and 3 deletions

View File

@ -55,10 +55,10 @@ def traces_sampler(sampling_context: Dict[str, Any]) -> Union[float, bool]:
queue = sampling_context.get("queue")
if queue is not None and isinstance(queue, str):
if isinstance(settings.SENTRY_TRACE_WORKER_RATE, float):
return settings.SENTRY_TRACE_WORKER_RATE
else:
if isinstance(settings.SENTRY_TRACE_WORKER_RATE, dict):
return settings.SENTRY_TRACE_WORKER_RATE.get(queue, 0.0)
else:
return settings.SENTRY_TRACE_WORKER_RATE
else:
return settings.SENTRY_TRACE_RATE