-
Notifications
You must be signed in to change notification settings - Fork 213
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
feat: Allow some non-Golang interfaces to be passed through in Events. #606
feat: Allow some non-Golang interfaces to be passed through in Events. #606
Conversation
Codecov ReportPatch coverage has no change and project coverage change:
Additional details and impacted files@@ Coverage Diff @@
## master #606 +/- ##
==========================================
+ Coverage 78.83% 78.99% +0.15%
==========================================
Files 38 38
Lines 3851 3851
==========================================
+ Hits 3036 3042 +6
+ Misses 712 708 -4
+ Partials 103 101 -2
... and 1 file with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
I'm not quite sure why you would proxy events through the Go SDK. |
@cleptric asked:
In our case, our mobile and web apps (iOS, Android, web, ...) do their own logging and then communicate events through an endpoint on our own servers, which then relays events up to Sentry (and, previously, to our previous error reporting provider). We'd like to keep this behavior (and we'd like to maintain compatibility with our clients in the field, rather than having to ship new client binary versions to support Sentry). Most of our back end -- including our exception relay endpoint, |
Some users may wish to use sentry-go as a mechanism to proxy non-Golang events -- for instance, if reporting errors from a mobile or web application. We add Sentry event payload interfaces that make it easier to support other platforms, including stack frame interface members for "C-like" applications, and including the Debug Meta interface that allows the Sentry backend to symbolicate application backtraces. This change was authored under contract for FullStory.
c669687
to
bf2389d
Compare
Force pushed to fix linter complaints. (I am not a native Gopher, so please feel free to correct me on any other style issues!) |
Sounds reasonable. Let me run this by some folks internally to check if we run into any issues during ingestion. |
Thanks! Here's a snippet of the other workaround we have to make this behave as we'd like: func mangleSentryMobileEvent(ev *sentry.Event, evhint *sentry.EventHint) *sentry.Event {
if ev.Tags["device.osName"] == "Android" {
ev.Platform = "java"
} else {
ev.Platform = "cocoa"
}
// XXX FUTURE: fill in ev.Release
ev.Sdk.Name = "fs-recbugs"
ev.Sdk.Version = "unknown"
ev.Sdk.Integrations = nil
ev.Sdk.Packages = nil
return ev
}
...
client, err := sentry.NewClient(sentry.ClientOptions{
...,
BeforeSend: mangleSentryMobileEvent,
Integrations: func([]sentry.Integration) []sentry.Integration { return nil },
Release: "unset",
}) |
Using |
I just tested this end-to-end and have successfully recorded an event with it. |
Hiya @cleptric , any news on whether you'd be able to merge this? We'd really like to get this in upstream so that we can put a build dependency on it. Thanks! |
Hey @jwise , the changes look good from my side, but I'd still like to ask you to add a basic test for the fields you've added. The idea is for those test(s) to fail if some of those new public fields are changed or removed from Event struct in the future (accidentally or not), which would also help us as maintainers to promptly detect that. Something similar to https://github.com/getsentry/sentry-go/blob/master/interfaces_test.go#L137-L161 would do. Thank you! After that's done, we can merge it, and it'll be included in the next release, which will go out probably somewhere in the next couple weeks. |
Hi @tonyo , thanks for the suggestion for where those could go! I've added tests for a handful of those fields in 810c51d, but not all of them, since I didn't see precedent elsewhere in (Please forgive me if the JSON string concatenation is unidiomatic. I do not natively speak Go!) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To sum up, let's move the new additions to two separate tests, where we test just those changes. Otherwise, looks good!
interfaces_test.go
Outdated
ImageAddr: "0xabcd0000", | ||
}, | ||
}, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move your additions to a new test (a new function that starts with "Test", e.g. TestMarshalEventWithDebugMeta
), and preferably include all newly added fields there (e.g. with two images, "macho" and "proguard", to cover all the fields in DebugMetaImage).
The preamble (event := NewEvent()
) will stay the same in the new test, but everything else will be purely about DebugMeta testing.
810c51d
to
8b47c36
Compare
@tonyo Force-pushed a new version that splits those tests out, and tests every element of the struct. What do you think of these instead? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, thanks!
The GOPATH test failure seems to be unrelated (it's now failing on master too, probably something changed on the GitHub runner side), so merging. |
Wow, that was amazingly fast! That makes it much easier for me to set a dep on it internally. Thanks so much!! |
Some users may wish to use sentry-go as a mechanism to proxy non-Golang events -- for instance, if reporting errors from a mobile or web application. We add Sentry event payload interfaces that make it easier to support other platforms, including stack frame interface members for "C-like" applications, and including the Debug Meta interface that allows the Sentry backend to symbolicate application backtraces.
This change does not include test changes, because the JSON serialization interface does not appear to presently have other test coverage.
This change was authored under contract for FullStory.