With raven-python we could add extra param to captureMessage. Now with sentry-python capture_message does not accept extra param.
Can we add extra data to event or message ?
Hi, it's no longer available as kwargs, but you can do this: https://docs.sentry.io/learn/context/?platform=python#extra-context
from sentry_sdk import configure_scope
with configure_scope() as scope:
scope.set_extra("character_name", "Mighty Fighter")
# all capture_message here have the extra set
with push_scope() as scope:
scope.set_extra("character_name", "All Might")
# different extra value inside of this with-statement
Oh yeah !
But when we are using python logging (which accept extra params), is sentry-python could update the scope automatically ?
Right now this doesn't work, you'd have to write something like this:
with push_scope() as scope:
scope.set_extra(..)
log.debug("hi")
We will probably try to add this at some later point but we don't want too many APIs for doing the same thing
@mitsuhiko any opinion on this?
@untitaker extra from log records should be added automatically.
@mitsuhiko do we want to support more than event.extra? Like, user, request, tags...
@untitaker we want to match the old behavior. You can see what it did there.
We internally decided to just support extra and nothing else FWIW
If I want to set a custom error message that is more specific than the one on the caught exception, do I do so by setting scope.set_extra("message", "My custom message")?
Also, is there a way to provide raw format string style messages? https://docs.sentry.io/clientdev/interfaces/message/
@danielcompton you would have to modify the event payload in before_send for either usecase
@danielcompton depending on what you want to do there might be nicer things to achieve that goal. It would be interesting to see the usecase.
thank you, I hated that I had the option to add some extra information to help me debug the warnings without writing any extra line of code. Forcing us to upgrade helped us to reap this benefit.
@EralpB instead of leaving this kind of comment please describe the actual problem you have. We do our best to balance api simplicity with convenience, and as such the sdk has come a long way since the issue you're commenting on has been created.
Also note that this issue has been resolved with a PR, not as wontfix.