You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Loguru integration does not support disabled_integrations? #4398
This means the above code does not actually disable Loguru integration at all, it actually enables it earlier. I don't want to have to disable all automatic integrations just to disable this one.
(Also, given sentry_sdk.init is a context manager, I would expect Loguru integration to be disabled once the context manager was exited -- this would help with running test suites :) )
Hey @alicederyn, thanks for raising this. When we introduced disabled_integrations we overlooked that Loguru is special in that it doesn't use setup_once. 🙃
We'll need to do the following:
Instruct folks to provide the class, not an instance of it, in disabled_integrations, so that the class is not instantiated. (This already works now, you can do either, but in the docs we're using instances which won't work in this case.)
Fix up our integration setup code so that it doesn't instantiate disabled integrations (because right now it does, so the first bullet point is not enough).
Alternatively, maybe it's possible to move the Loguru setup code to setup_once (which would be the preferred solution), but not sure atm.
I think Loguru not using setup_once also breaks the ability for users to customize it? Since it'll be registered with their settings, then immediately deregistered by the new version created during sentry_sdk.init. Users would also need to add the class to disabled_integrations. If I'm right, I think having the code moved would be better?
Yeah I'm also not happy about the code being in the __init__ -- we have setup_once exactly because the setup code should not run multiple times.
Will def investigate if we can move it. Right now there's a comment that suggests that's not possible, but the LoggingIntegration needs to do similar things in order to get set up and it manages to do them in setup_once, so I'm hoping it's possible.
Activity
sentrivana commentedon May 19, 2025
Hey @alicederyn, thanks for raising this. When we introduced
disabled_integrationswe overlooked that Loguru is special in that it doesn't usesetup_once. 🙃We'll need to do the following:
disabled_integrations, so that the class is not instantiated. (This already works now, you can do either, but in the docs we're using instances which won't work in this case.)Alternatively, maybe it's possible to move the Loguru setup code to
setup_once(which would be the preferred solution), but not sure atm.I'll take a look at this soon.
alicederyn commentedon May 19, 2025
I think
Logurunot usingsetup_oncealso breaks the ability for users to customize it? Since it'll be registered with their settings, then immediately deregistered by the new version created duringsentry_sdk.init. Users would also need to add the class todisabled_integrations. If I'm right, I think having the code moved would be better?sentrivana commentedon May 19, 2025
Yeah I'm also not happy about the code being in the
__init__-- we havesetup_onceexactly because the setup code should not run multiple times.Will def investigate if we can move it. Right now there's a comment that suggests that's not possible, but the
LoggingIntegrationneeds to do similar things in order to get set up and it manages to do them insetup_once, so I'm hoping it's possible.fix(loguru): Move integration setup from `__init__` to `setup_once` (#…
sentrivana commentedon May 19, 2025
Should be fixed in 2.29.0 :)
alicederyn commentedon May 20, 2025
Thanks for the prompt turnaround!