-
-
Notifications
You must be signed in to change notification settings - Fork 147
No way to send custom extra data #125
Comments
+1. Add "extra" interface, please, or what choice do I have, but to use tags for passing down internal unique message IDs. Which is definitely a not kind of info to be indexed. |
You can get around it by writing your own CaptureMessage function. I ended up doing something like this in my util package: type Ctx map[string]interface{}
func SentryCaptureMessage(message string, ctx *Ctx) {
packet := &raven.Packet{
Message: message,
Interfaces: []raven.Interface{
&raven.Message{
Message: message,
Params: nil,
},
},
Extra: *ctx,
}
raven.Capture(packet, nil)
} And in my code I use it like this: util.SentryCaptureMessage("Some error message", &util.Ctx{"variable 1": var1, "variable 2": var2}) Now var1 and var2 appear in "Additional data" section |
This is probably what your looking for: https://docs.sentry.io/clients/go/#additional-context |
@zkanda There's a difference though. In the Go client you pass Line 610 in 8f3acae
while in the Python client you can pass both |
Ahh indeed, there's actually extra but it's not exposed: Line 158 in 8f3acae
|
@zkanda On it. |
I agree that this should be a feature, but I thought I would offer a work around until the PR is merged. If your additional data is json marshalable you can implement When implementing |
For the next person stumbling on this, concretely the workaround by @jpatters works like this: type Foo struct {
MyVal string `json:"myval"`
}
// Implements raven.Interface, and raven-go will then shove the JSONified struct into "extra"
func (f *Foo) Class() string {
return "extra"
} |
For the next person stumbling on this, you can now use the following snippet: raven.CaptureError(
raven.WrapWithExtra(err, map[string]interface{}{
"extra1": "my-extra-data",
"extra2": 1234,
}),
map[string]string{"tag1": "tag"}) |
It seems like |
As the original issue is resolved, I'll close this one and create new one for Panics – #235 |
Python client provides a way to send custom extra data
client.captureMessage('message', extra={'foo': 'bar'})
, but Go client doesn't.The text was updated successfully, but these errors were encountered: