For debugging, eh, why not - but I've not previously had the need to enable this, let's say, application-wide (where I see the most advantage compared to just adding dumps of locals() per stack).
[0] https://docs.sentry.io/platforms/python/configuration/option...
In dev, sure (assuming local disk only). In prod, not in the form documented.
I could see it going either way. I would probably not use this globally on programs using secrets, but would consider opting-in occasionally where chances are low and value high.
You leave. New person takes over ownership, doesn't notice the import. Urgent business need says "add this feature to the daemon" and now it's processing secrets. Now, you can argue that the person who took ownership should have read the code more carefully, but perhaps it's their 5th day on the job when that request comes in, or they misread the import as something else.
I suppose you could do a code standard of "variables that containe a secret must always have 'secret' as a prefix", and could then do pattern matching, but humans are going to human and make a mistake.
I'd probably lean towards opt-in, decorator/context only - maybe "@traceback_with_variables_can_log_secrets" as the name...
Opt-out is risky and I’d not want to use it in sensitive applications.
Instead, opt-in would be as good as deliberately logging variables but without the additional log/print statements and try/catch blocks.
It requires no changes to your code, you can install it system-wide and all tracebacks will be prettified.