Skip to content
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

Don't cause NoMethodError when calling Sentry.* with an uninitialized SDK #1706

Closed
st0012 opened this issue Feb 1, 2022 · 2 comments · Fixed by #1713
Closed

Don't cause NoMethodError when calling Sentry.* with an uninitialized SDK #1706

st0012 opened this issue Feb 1, 2022 · 2 comments · Fixed by #1713
Assignees

Comments

@st0012
Copy link
Collaborator

st0012 commented Feb 1, 2022

It should be either no-op or raising an exception, as the SDK should always be initialized (this is a requirement across all Sentry SDKs).

I prefer raising exceptions for such condition and have proposed it in a recent discord discussion as well. But we also have methods like Sentry.capture_* that current does nothing instead of raising an exception. So my concerns are:

  • If I make methods like Sentry.set_tags raise exceptions, should I also change Sentry.capture_*'s behaviors.
  • If the answer is yes, should we consider that as a breaking change?

As maintainers we can argue that it's a bug fix so it's not a breaking change (can go out at any patch). But to some (probably few) users, it'll be a change that break their app without actually providing visible benefits to them (should be in a major release).

So I think the first step would be to stop causing the NoMethodError. And then we can discuss when to start raising the exception.

@sl0thentr0py
Copy link
Member

@st0012 so python no-ops on capture_* stuff without an init. set_tag still works since the hub has a scope attached (but no client). I think we prefer no-ops because the first priority is to never break user apps due to whatever reason. If they make an init mistake and don't see events, that can be resolved subsequently but at least it doesn't break their production unexpectedly by throwing an exception.

@st0012
Copy link
Collaborator Author

st0012 commented Feb 5, 2022

@sl0thentr0py In sentry-ruby, there will be no hub and no scopes if the SDK is not initialized. So methods like set_tags won't work. How does sentry-python create hub and scopes when it's not initialized? Is it done upon import?

Anyway, I'm fine with the no-op approach since it aligns with other SDKs. Will open a PR shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants