-
-
Notifications
You must be signed in to change notification settings - Fork 149
Conversation
Includes ability to merge event info. That’s pretty much it. A refactor thrown in while I was trying to make sense of life.
Oops, fixed a big bug. Wasn't merging interfaces. Okay now. |
Hey @titanous, let me know what you think of all this! Thanks! |
@tylrtrmbl Sorry for not getting to this quickly, it might be a couple more days. My week is really busy. |
@titanous np, just checking in. Good luck with your things! 🍀 |
// when client is nil. A channel is provided if it is important to check for a | ||
// send's success. | ||
func (client *Client) Capture(packet *Packet, captureTags map[string]string) (eventID string, ch chan error) { | ||
func (client *Client) Capture(message string, eventInfo *EventInfo) (eventID string, ch chan error) { |
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.
What is the difference between Capture
and CaptureMessage
, their signatures are the same. I don't think Capture
should take a message
.
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.
Does it make sense to call this Send
? Should it be capturing anything? Isn't it what all of the Capture* methods use to actually send the packet after building it?
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.
I added Capture
for parity with the Python client. I messed up the signature badly though. Will change it and let you know.
It might also make sense to see if it just becomes Send
.
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.
Changed. This might be ready to take a look at.
Overall I think this is a reasonable approach, let me know when you want me to do a complete review. |
if res.StatusCode != 200 { | ||
return fmt.Errorf("raven: got http status %d", res.StatusCode) | ||
|
||
// Merge interfaces together |
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.
Hmm, shouldn't all of this merging code be in event.go
with the rest?
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.
This was different because it was "defaults", but this is done differently now and is more obvious. thank you for catching that!
Regarding the signature, is there somethign wrong with doing: func (client *Client) CaptureMessage(message string, contexts ...*Context) string That way you can utilize context/types/merging, and still keep the signature variadic. This will allow both the common case of: client.CaptureMessage("lol broken") and client.CaptureMessage("lol broken", &Context{Level: "error"}) |
I like that. It's sort of a marriage of #14 and this one, and is sort of like how we do "optional interfaces" right now. |
That's generally how the other clients work, and imo, it'd be awkward to need to define an "empty" object if you're not passing anything. The "extra" is just that. They're meant to be optional. So the normal case is typically: And it'd be awkward to have to switch to a different method entirely to do something like: And just as awkward would be: Just to satisfy the signature. This approach could also technically allow passing a bunch of contexts (for whatever reason) and merge them all together. So |
Right on. ✌️ Fully with ya. |
+1, I like this approach. |
Anything I can do to help with this? |
I'm coming back. I have a clear vision for how I'd like to finish this pull request, so the best thing you all can do to help is be available to give me feedback! I am committed to finishing this for the new year. Keep me honest! |
Also initialize events in *Event method Also rename EventInfo to Event throughout.
Need some tests for merging. I keep getting them backwards and that needs to break shit.
Made some progress on this today, addressed some feedback. Not ready for a second round of review though; will let you know! |
Conflicts: client.go client_test.go Had to manually move some code that got copied into new files. Hopefully I got everything! Here’s what changed in master since I started: https://github.com/getsentry/raven-go/compare/30337dc77126a66b25ac836918 f31b63f10f969a...master
Remove CheckError example: need to replace with better example that makes better use of CaptureError and uses a persistent client.
Holy passing tests batman! Still not ready for a good set of eyes, should be in a few days. Just wanted to celebrate this finally turning into a check mark. 😄 |
@mattrobenolt's awesome API is now implemented! 💃 If you're feeling adventurous, you can dig in and try to look at the code as it is right now. I think I've done what I wanted to do with actual implementation. I still need to:
Expect these to come over the next couple days, followed by a request for a thorough review. Since this touches most of the existing code, I'm expecting to have to make changes! |
Dominantly client.go
What's the ETA on this PR? Is it going to be merged / continued any time soon? Anything we can do to help? |
Remember #14? It was all about trying to pass additional info into the
Capture*
methods. Unfortunately, the way I chose to do it (variadics pulled apart by type switches) wasn't type safe, which isn't great.However, there is an obvious way to make type safety work: instead of variadics, just introduce the ability to merge packets.
Current
master
Only allows tags and interfaces 😦
Bad Variadic Solution
Not type safe like at all 😩
This Pull Request
The actual signature is a little more descriptive, but this does everything both of us want (I think)!☺️
What's Next
Before I get going on:
I want to know what you think of this direction! Like last time, the change isn't as big as it looks. Mainly,
Capture*
methods now take what used to be aPacket
in and merging happens now.Client
also dispenses the packets like last time.writer.go
nicely demos how this looks:I ended up renaming some things to make more sense to me, and factoring things into different files while trying to make sense of the world 😉 but I I did like the changes in the end.
Thanks for looking this over again! Let me know if you have any questions.
Closes #19