Skip to content

profiles_sample_rate as string causes Django to not bootstrap. #4294

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jreeter opened this issue Apr 14, 2025 · 1 comment
Closed

profiles_sample_rate as string causes Django to not bootstrap. #4294

jreeter opened this issue Apr 14, 2025 · 1 comment

Comments

@jreeter
Copy link

jreeter commented Apr 14, 2025

How do you use Sentry?

Sentry Saas (sentry.io)

Version

2.22.0

Steps to Reproduce

Set traces and profile rates to strings:

traces_sample_rate="1",
profiles_sample_rate="1",

Expected Result

For Django to bootstrap and run and/or for traces and profiles sample rates to either both accept strings or both fail, either way they should be consistent it seems.

Actual Result

To adjust profile and sample rates on the fly we add them to a centralized store as strings. However,
this surfaced an inconsistency, setting profiles_sample_rate as a string causes Django to not bootstrap.

Output

 File "/Users/jree/.pyenv/versions/3.11.4/envs/shepherd-3.11/lib/python3.11/site-packages/sentry_sdk/profiler/transaction_profiler.py", line 127, in has_profiling_enabled
    if profiles_sample_rate is not None and profiles_sample_rate > 0:
                                            ^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: '>' not supported between instances of 'str' and 'int'

This only affects profiles_sample_rate, traces_sample_rate is not affected by this.

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Apr 14, 2025
@szokeasaurusrex
Copy link
Member

szokeasaurusrex commented Apr 15, 2025

@jreeter profiles_sample_rate and traces_sample_rate are both typed as Optional[float]. Passing any other type, including str, is not supported. The SDK's behavior when passing an invalid type is undefined, meaning that it might work fine or it might not; it might error, or could fail silently; it could get stuck in an infinite loop, or your app could crash. In particular, we don't guarantee that passing invalid types will result in the same behavior for both traces_sample_rate and profiles_sample_rate.

tldr: the SDK is behaving as expected, from our end there is nothing to do here; please pass float values instead of str for both of these. If you are storing the values as strings, you need to convert them to float values before passing them to the SDK.

@szokeasaurusrex szokeasaurusrex closed this as not planned Won't fix, can't repro, duplicate, stale Apr 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

2 participants